The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixes
Steven Teyff65bd9a4a74
diff --git a/apps/web/lib/actions/partners/create-account-link.ts b/apps/web/lib/actions/partners/create-account-link.tsindex 89e3d6b242..fa40afaf34 100644--- a/apps/web/lib/actions/partners/create-account-link.ts+++ b/apps/web/lib/actions/partners/create-account-link.ts@@ -14,7 +14,13 @@ export const createAccountLinkAction = authPartnerActionClient.action(// this should never happenif (!partner.email) {throw new Error(- "Partner does not have an email. Please contact support to update your email.",+ "Partner does not have a valid email. Please contact support to update your email.",+ );+ }++ if (!partner.country) {+ throw new Error(+ "You haven't set your country yet. Please go to partners.dub.co/onboarding to set your country.",);}diff --git a/apps/web/ui/partners/add-edit-reward-sheet.tsx b/apps/web/ui/partners/add-edit-reward-sheet.tsxindex 79266c77e2..3373b6718d 100644--- a/apps/web/ui/partners/add-edit-reward-sheet.tsx+++ b/apps/web/ui/partners/add-edit-reward-sheet.tsx@@ -680,27 +680,18 @@ function RewardSheetContent({ setIsOpen, event, reward }: RewardSheetProps) {/></div><div className="mt-4">- {!rewardPartners ? (- <div className="flex items-center justify-center py-8">- <LoadingSpinner className="size-4" />- </div>- ) : displayPartners.length > 0 ? (- <Table {...selectedPartnersTable} />- ) : (- <div className="flex flex-col items-center justify-center gap-4 rounded-lg bg-neutral-50 py-12">- <div className="flex items-center justify-center">- <Users className="size-6 text-neutral-800" />- </div>- <div className="flex flex-col items-center gap-1 px-4 text-center">- <p className="text-base font-medium text-neutral-900">- Eligible partners- </p>- <p className="text-sm text-neutral-600">- No eligible partners added yet- </p>- </div>- </div>- )}+ <PartnersTable+ partners={displayPartners}+ loading={isLoadingRewardPartners}+ partnerIds={partnerIds}+ setValue={setValue}+ setSelectedPartners={setSelectedPartners}+ pagination={reward ? pagination : undefined}+ setPagination={reward ? setPagination : undefined}+ partnersCount={+ reward ? partnersCount : selectedPartners.length+ }+ /></div></div>)}@@ -798,3 +789,114 @@ export function useRewardSheet(setIsOpen,};}++interface PartnersTableProps {+ partners: EnrolledPartnerProps[];+ loading: boolean;+ partnerIds: string[] | null;+ setValue: any; // TODO: Type this properly with UseFormSetValue+ setSelectedPartners: Dispatch<SetStateAction<EnrolledPartnerProps[]>>;+ pagination?: any; // TODO: Type this properly+ setPagination?: any; // TODO: Type this properly+ partnersCount: number;+}++function PartnersTable({+ partners,+ loading,+ partnerIds,+ setValue,+ setSelectedPartners,+ pagination,+ setPagination,+ partnersCount,+}: PartnersTableProps) {+ const table = useTable({+ data: partners,+ columns: [+ {+ header: "Partner",+ cell: ({ row }) => (+ <div className="flex items-center gap-2">+ <img+ src={+ row.original.image ||+ `${DICEBEAR_AVATAR_URL}${row.original.name}`+ }+ alt={row.original.name}+ className="size-6 rounded-full"+ />+ <span className="text-sm text-neutral-700">+ {row.original.name}+ </span>+ </div>+ ),+ },+ {+ header: "Email",+ cell: ({ row }) => (+ <div className="text-sm text-neutral-600">{row.original.email}</div>+ ),+ },+ {+ id: "actions",+ cell: ({ row }) => (+ <div className="flex justify-end">+ <Button+ variant="secondary"+ icon={<X className="size-4" />}+ className="h-8 w-8 rounded-md border-0 bg-neutral-50 p-0"+ onClick={() => {+ const newPartnerIds = (partnerIds || []).filter(+ (id) => id !== row.original.id,+ );+ setValue("partnerIds", newPartnerIds);+ setSelectedPartners((prev) =>+ prev.filter((p) => p.id !== row.original.id),+ );+ }}+ />+ </div>+ ),+ size: 50,+ },+ ],+ loading,+ thClassName: () => cn("border-l-0"),+ tdClassName: () => cn("border-l-0"),+ className: "[&_tr:last-child>td]:border-b-transparent",+ scrollWrapperClassName: "min-h-[40px]",+ resourceName: (p) => `eligible partner${p ? "s" : ""}`,+ pagination,+ onPaginationChange: setPagination,+ rowCount: partnersCount,+ });++ if (loading) {+ return (+ <div className="flex items-center justify-center rounded-lg border border-neutral-200 bg-white py-8">+ <LoadingSpinner className="size-4" />+ </div>+ );+ }++ if (partners.length === 0) {+ return (+ <div className="flex flex-col items-center justify-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 py-10">+ <div className="flex items-center justify-center">+ <Users className="size-5 text-neutral-500" />+ </div>+ <div className="flex flex-col items-center gap-1 px-4 text-center">+ <p className="text-sm font-medium text-neutral-600">+ Eligible partners+ </p>+ <p className="text-sm text-neutral-500">+ No eligible partners added yet+ </p>+ </div>+ </div>+ );+ }++ return <Table {...table} />;+}