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 Wilson33edcf48f4eb
diff --git a/apps/web/ui/partners/program-application-sheet.tsx b/apps/web/ui/partners/program-application-sheet.tsxindex 69130fc8d5..a4bf68b36d 100644--- a/apps/web/ui/partners/program-application-sheet.tsx+++ b/apps/web/ui/partners/program-application-sheet.tsx@@ -17,6 +17,7 @@ import {CircleCheckFill,Grid,Link4,+ LoadingSpinner,Sheet,} from "@dub/ui";import { cn, fetcher, OG_AVATAR_URL } from "@dub/utils";@@ -59,7 +60,9 @@ function ProgramApplicationSheetContent({program?.defaultGroupId ||DEFAULT_PARTNER_GROUP.slug;- const { data: group } = useSWR<z.infer<typeof PartnerProgramGroupSchema>>(+ const { data: group, isLoading: isGroupLoading } = useSWR<+ z.infer<typeof PartnerProgramGroupSchema>+ >(groupIdOrSlug? `/api/partner-profile/programs/${program.id}/groups/${groupIdOrSlug}`: null,@@ -159,62 +162,69 @@ function ProgramApplicationSheetContent({</Sheet.Close></div>- <div className="flex flex-col gap-6 p-5 sm:p-8">- {fields?.length ? (- fields.map((field, index) => {- return (- <ProgramApplicationFormField- key={field.id}- field={field}- keyPath={`formData.fields.${index}`}- />- );- })- ) : (- <p className="text-content-subtle flex items-center gap-1 text-sm">- <CircleCheck className="inline-block size-4 text-green-500" />- No additional information required to apply- </p>- )}+ {isGroupLoading ? (+ <div className="flex items-center justify-center py-8">+ <LoadingSpinner />+ </div>+ ) : (+ <div className="flex flex-col gap-6 p-5 sm:p-8">+ {fields?.length ? (+ fields.map((field, index) => {+ return (+ <ProgramApplicationFormField+ key={field.id}+ field={field}+ keyPath={`formData.fields.${index}`}+ />+ );+ })+ ) : (+ <p className="text-content-subtle flex items-center gap-1 text-sm">+ <CircleCheck className="inline-block size-4 text-green-500" />+ No additional information required to apply+ </p>+ )}- {program.termsUrl && (- <div className="flex items-center gap-2">- <input- type="checkbox"- id="termsAgreement"- className={cn(- "h-4 w-4 rounded border-neutral-300 text-[var(--brand)] focus:ring-[var(--brand)]",- errors.termsAgreement &&- "border-red-400 focus:ring-red-500",- )}- {...register("termsAgreement", {- required: true,- validate: (v) => v === true,- })}- />- <label- htmlFor="termsAgreement"- className="text-sm text-neutral-800"- >- I agree to the{" "}- <a- href={program.termsUrl}- target="_blank"- rel="noopener noreferrer"- className="text-[var(--brand)] underline hover:opacity-80"+ {program.termsUrl && (+ <div className="flex items-center gap-2">+ <input+ type="checkbox"+ id="termsAgreement"+ className={cn(+ "h-4 w-4 rounded border-neutral-300 text-[var(--brand)] focus:ring-[var(--brand)]",+ errors.termsAgreement &&+ "border-red-400 focus:ring-red-500",+ )}+ {...register("termsAgreement", {+ required: true,+ validate: (v) => v === true,+ })}+ />+ <label+ htmlFor="termsAgreement"+ className="text-sm text-neutral-800">- {program.name} Affiliate Program Terms ↗- </a>- </label>- </div>- )}- </div>+ I agree to the{" "}+ <a+ href={program.termsUrl}+ target="_blank"+ rel="noopener noreferrer"+ className="text-[var(--brand)] underline hover:opacity-80"+ >+ {program.name} Affiliate Program Terms ↗+ </a>+ </label>+ </div>+ )}+ </div>+ )}<div className="flex grow flex-col justify-end p-5"><Buttontype="submit"variant="primary"text="Submit application"+ disabled={isGroupLoading}loading={isSubmitting}/></div>