The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add loading state
Tim Wilson8eef9b86195b
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/page-client.tsxindex da49f827a5..81242f810a 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/resources/page-client.tsx@@ -3,7 +3,7 @@import { deleteProgramResourceAction } from "@/lib/actions/partners/program-resources/delete-program-resource";import useProgramResources from "@/lib/swr/use-program-resources";import useWorkspace from "@/lib/swr/use-workspace";-import { PROGRAM_RESOURCE_TYPES } from "@/lib/zod/schemas/program-resources";+import { ProgramResourceType } from "@/lib/zod/schemas/program-resources";import { ThreeDots } from "@/ui/shared/icons";import {AnimatedSizeContainer,@@ -39,7 +39,7 @@ export function ProgramResourcesPageClient() {});const handleDelete = async (- resourceType: (typeof PROGRAM_RESOURCE_TYPES)[number],+ resourceType: ProgramResourceType,resourceId: string,) => {const result = await executeAsync({@@ -65,7 +65,6 @@ export function ProgramResourcesPageClient() {{resources?.logos?.map((logo) => (<ResourceCardkey={logo.id}- resourceId={logo.id}resourceType="logo"icon={<div className="relative size-8 overflow-hidden">@@ -119,7 +118,7 @@ function Section({</div><div className="-m-1"><AnimatedSizeContainer- height+ height={!isLoading}transition={{ duration: 0.2, ease: "easeInOut" }}><div@@ -128,7 +127,7 @@ function Section({isValidating && "opacity-50",)}>- {children}+ {isLoading ? <ResourceCardSkeleton /> : children}<Buttontype="button"text={`Add ${resource}`}@@ -142,16 +141,26 @@ function Section({);}+function ResourceCardSkeleton() {+ return (+ <div className="flex w-full items-center gap-4 rounded-lg border border-neutral-200 p-4">+ <div className="flex size-10 shrink-0 animate-pulse items-center justify-center rounded-md bg-neutral-200" />+ <div className="flex min-w-0 animate-pulse flex-col gap-1">+ <div className="h-4 w-32 max-w-full rounded-md bg-neutral-200" />+ <div className="h-4 w-16 max-w-full rounded-md bg-neutral-200" />+ </div>+ </div>+ );+}+function ResourceCard({- resourceId,resourceType,title,description,icon,onDelete,}: {- resourceId: string;- resourceType: "logo" | "color" | "file";+ resourceType: ProgramResourceType;title: string;description: string;icon: ReactNode;@@ -161,14 +170,18 @@ function ResourceCard({const [isDeleting, setIsDeleting] = useState(false);return (- <div className="flex w-full items-center justify-between gap-4 rounded-lg border border-neutral-200 p-4">- <div className="flex items-center gap-4">- <div className="flex size-10 items-center justify-center rounded-md border border-neutral-200">+ <div className="flex w-full items-center justify-between gap-4 rounded-lg border border-neutral-200 p-4 shadow-sm">+ <div className="flex min-w-0 items-center gap-4">+ <div className="flex size-10 shrink-0 items-center justify-center rounded-md border border-neutral-200">{icon}</div>- <div className="flex flex-col">- <span className="text-sm font-medium text-neutral-800">{title}</span>- <span className="text-xs text-neutral-500">{description}</span>+ <div className="flex min-w-0 flex-col">+ <span className="truncate text-sm font-medium text-neutral-800">+ {title}+ </span>+ <span className="truncate text-xs text-neutral-500">+ {description}+ </span></div></div><div className="relative">diff --git a/apps/web/lib/zod/schemas/program-resources.ts b/apps/web/lib/zod/schemas/program-resources.tsindex 8cbe4c35e4..6746bbab9d 100644--- a/apps/web/lib/zod/schemas/program-resources.ts+++ b/apps/web/lib/zod/schemas/program-resources.ts@@ -2,6 +2,8 @@ import { z } from "zod";export const PROGRAM_RESOURCE_TYPES = ["logo", "file", "color"] as const;+export type ProgramResourceType = (typeof PROGRAM_RESOURCE_TYPES)[number];+export const programResourceFileSchema = z.object({id: z.string(),name: z.string(),