The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add drag to reorder, change APi route
Steven Tey02a7e0d441ac
diff --git a/apps/web/app/api/oauth/apps/[appId]/route.ts b/apps/web/app/api/oauth/apps/[appId]/route.tsindex 55e4e50231..5aeced6a05 100644--- a/apps/web/app/api/oauth/apps/[appId]/route.ts+++ b/apps/web/app/api/oauth/apps/[appId]/route.ts@@ -186,11 +186,13 @@ const deleteScreenshots = async (screenshots: Prisma.JsonValue | null) => {return;}- await Promise.all(+ const res = await Promise.all(images.map(async (image: string) => {if (image.startsWith(`${R2_URL}/integration-screenshots`)) {return storage.delete(image.replace(`${R2_URL}/`, ""));}}),);++ console.log({ res });};diff --git a/apps/web/app/api/oauth/apps/screenshots/upload/route.ts b/apps/web/app/api/oauth/apps/upload-url/route.tssimilarity index 74%rename from apps/web/app/api/oauth/apps/screenshots/upload/route.tsrename to apps/web/app/api/oauth/apps/upload-url/route.tsindex 746852f0c8..2291c6b8e0 100644--- a/apps/web/app/api/oauth/apps/screenshots/upload/route.ts+++ b/apps/web/app/api/oauth/apps/upload-url/route.ts@@ -3,11 +3,12 @@ import { storage } from "@/lib/storage";import { nanoid } from "@dub/utils";import { NextResponse } from "next/server";-// POST /api/oauth/apps/screenshots/upload – get a signed URL to upload an integration screenshot+// POST /api/oauth/apps/upload-url – get a signed URL to upload an integration screenshotexport const POST = withWorkspace(async () => {const key = `integration-screenshots/${nanoid(16)}`;const signedUrl = await storage.getSignedUrl(key);+ console.log({ key, signedUrl });return NextResponse.json({ key, signedUrl });});diff --git a/apps/web/ui/integrations/add-edit-integration-form.tsx b/apps/web/ui/integrations/add-edit-integration-form.tsxindex 1ff80ac909..b6041fa643 100644--- a/apps/web/ui/integrations/add-edit-integration-form.tsx+++ b/apps/web/ui/integrations/add-edit-integration-form.tsx@@ -15,6 +15,7 @@ import {} from "@dub/ui";import { nanoid } from "@dub/utils";import slugify from "@sindresorhus/slugify";+import { Reorder } from "framer-motion";import { Paperclip, Trash2 } from "lucide-react";import { redirect, useRouter } from "next/navigation";import { FormEvent, useEffect, useMemo, useState } from "react";@@ -144,9 +145,9 @@ export default function AddEditIntegrationForm({setScreenshots((prev) => [...prev, { file, uploading: true }]);const response = await fetch(- `/api/oauth/apps/screenshots/upload?workspaceId=${workspaceId}`,+ `/api/oauth/apps/upload-url?workspaceId=${workspaceId}`,{- method: "GET",+ method: "POST",},);@@ -306,11 +307,19 @@ export default function AddEditIntegrationForm({<h2 className="text-sm font-medium text-gray-900">Screenshots</h2><InfoTooltip content="You can upload up to 4 screenshots that will be displayed on the integration page." /></label>- <div className="mt-2 grid w-full gap-2">+ <Reorder.Group+ values={screenshots}+ onReorder={setScreenshots}+ className="mt-2 grid w-full gap-2"+ >{screenshots.map((screenshot) => (- <div+ <Reorder.Itemkey={screenshot.key}- className="flex w-full items-center justify-between rounded-md border border-gray-200"+ value={screenshot}+ drag="y"+ dragConstraints={{ left: 0, right: 0, top: 0, bottom: 0 }}+ dragMomentum={false}+ className="group flex w-full items-center justify-between rounded-md border border-gray-200 bg-white transition-shadow hover:cursor-grab active:cursor-grabbing active:shadow-lg"><div className="flex flex-1 items-center space-x-2 p-2">{screenshot.uploading ? (@@ -332,9 +341,9 @@ export default function AddEditIntegrationForm({><Trash2 className="h-4 w-4 text-gray-500" /></button>- </div>+ </Reorder.Item>))}- </div>+ </Reorder.Group>{screenshots.length < 4 && (<FileUpload