The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix invite partner sheet
Steven Tey921e41a57344
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/partners/invite-partner-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/partners/invite-partner-sheet.tsxindex ab5c9e0a49..df05c94657 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/partners/invite-partner-sheet.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/partners/invite-partner-sheet.tsx@@ -21,6 +21,7 @@ import {} from "@dub/ui";import { cn } from "@dub/utils/src";import { motion } from "framer-motion";+import { ChevronDown } from "lucide-react";import { useAction } from "next-safe-action/hooks";import { Dispatch, memo, SetStateAction, useMemo, useState } from "react";import { useForm } from "react-hook-form";@@ -101,6 +102,8 @@ function InvitePartnerSheetContent({ setIsOpen }: InvitePartnerSheetProps) {return result.id;};+ const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);+const onSubmit = async (data: InvitePartnerFormData) => {if (!workspaceId || !program?.id) {return;@@ -126,8 +129,8 @@ function InvitePartnerSheetContent({ setIsOpen }: InvitePartnerSheetProps) {return (<form onSubmit={handleSubmit(onSubmit)} className="flex h-full flex-col">- <div>- <div className="flex items-start justify-between border-b border-neutral-200 p-6">+ <div className="sticky top-0 z-10 border-b border-neutral-200 bg-white">+ <div className="flex items-start justify-between p-6"><Sheet.Title className="text-xl font-semibold">Invite partner</Sheet.Title>@@ -139,6 +142,9 @@ function InvitePartnerSheetContent({ setIsOpen }: InvitePartnerSheetProps) {/></Sheet.Close></div>+ </div>++ <div className="flex-1 overflow-y-auto"><div className="p-6"><div className="grid gap-6"><div>@@ -219,59 +225,88 @@ function InvitePartnerSheetContent({ setIsOpen }: InvitePartnerSheetProps) {</div><div>- <label htmlFor="rewardId" className="flex items-center space-x-2">- <h2 className="text-sm font-medium text-neutral-900">- Sale reward{" "}- <span className="text-neutral-500">(optional)</span>- </h2>- </label>- <div className="relative mt-2 rounded-md shadow-sm">- <select- className={cn(- "block w-full rounded-md border-neutral-300 text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",- errors.rewardId && "border-red-600",- rewardsLoading && "opacity-50",- )}- {...register("rewardId")}- disabled={rewardsLoading}- >- <option value="">Select a reward</option>- {salesRewards?.map((reward) => (- <option value={reward.id} key={reward.id}>- {reward.name || formatRewardDescription({ reward })}- </option>- ))}- </select>- </div>- </div>-- <div>- <label- htmlFor="discountId"- className="flex items-center space-x-2"+ <button+ type="button"+ className="flex w-full items-center gap-2"+ onClick={() => setShowAdvancedOptions(!showAdvancedOptions)}>- <h2 className="text-sm font-medium text-neutral-900">- Discount <span className="text-neutral-500">(optional)</span>- </h2>- </label>- <div className="relative mt-2 rounded-md shadow-sm">- <select- className={cn(- "block w-full rounded-md border-neutral-300 text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",- errors.discountId && "border-red-600",- discountsLoading && "opacity-50",- )}- {...register("discountId")}- disabled={discountsLoading}+ <p className="text-sm text-neutral-600">+ {showAdvancedOptions ? "Hide" : "Show"} advanced settings+ </p>+ <motion.div+ animate={{ rotate: showAdvancedOptions ? 180 : 0 }}+ className="text-neutral-600">- <option value="">Select a discount</option>- {discounts?.map((discount) => (- <option value={discount.id} key={discount.id}>- {formatDiscountDescription({ discount })}- </option>- ))}- </select>- </div>+ <ChevronDown className="size-4" />+ </motion.div>+ </button>++ <AnimatedSizeContainer height>+ {showAdvancedOptions && (+ <div className="grid gap-6 py-6">+ <div>+ <label+ htmlFor="rewardId"+ className="flex items-center space-x-2"+ >+ <h2 className="text-sm font-medium text-neutral-900">+ Reward{" "}+ <span className="text-neutral-500">(optional)</span>+ </h2>+ </label>+ <div className="relative mt-2 rounded-md shadow-sm">+ <select+ className={cn(+ "block w-full rounded-md border-neutral-300 text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",+ errors.rewardId && "border-red-600",+ rewardsLoading && "opacity-50",+ )}+ {...register("rewardId")}+ disabled={rewardsLoading}+ >+ <option value="">Select a reward</option>+ {salesRewards?.map((reward) => (+ <option value={reward.id} key={reward.id}>+ {reward.name ||+ formatRewardDescription({ reward })}+ </option>+ ))}+ </select>+ </div>+ </div>++ <div>+ <label+ htmlFor="discountId"+ className="flex items-center space-x-2"+ >+ <h2 className="text-sm font-medium text-neutral-900">+ Discount{" "}+ <span className="text-neutral-500">(optional)</span>+ </h2>+ </label>+ <div className="relative mt-2 rounded-md shadow-sm">+ <select+ className={cn(+ "block w-full rounded-md border-neutral-300 text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",+ errors.discountId && "border-red-600",+ discountsLoading && "opacity-50",+ )}+ {...register("discountId")}+ disabled={discountsLoading}+ >+ <option value="">Select a discount</option>+ {discounts?.map((discount) => (+ <option value={discount.id} key={discount.id}>+ {formatDiscountDescription({ discount })}+ </option>+ ))}+ </select>+ </div>+ </div>+ </div>+ )}+ </AnimatedSizeContainer></div></div>@@ -279,8 +314,8 @@ function InvitePartnerSheetContent({ setIsOpen }: InvitePartnerSheetProps) {</div></div>- <div className="flex grow flex-col justify-end">- <div className="flex items-center justify-end gap-2 border-t border-neutral-200 p-5">+ <div className="sticky bottom-0 z-10 border-t border-neutral-200 bg-white">+ <div className="flex items-center justify-end gap-2 p-5"><Buttontype="button"variant="secondary"@@ -308,7 +343,7 @@ function EmailPreview() {const [showPreview, setShowPreview] = useLocalStorage("show-partner-invite-email-preview",- false,+ true,);return (diff --git a/apps/web/lib/zod/schemas/auth.ts b/apps/web/lib/zod/schemas/auth.tsindex 5b53348467..adf97a7c06 100644--- a/apps/web/lib/zod/schemas/auth.ts+++ b/apps/web/lib/zod/schemas/auth.ts@@ -3,6 +3,7 @@ import z from "@/lib/zod";export const passwordSchema = z.string().min(8, "Password must be at least 8 characters")+ .max(1000, "Password must be less than 1000 characters").regex(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$/,"Password must contain at least one number, one uppercase, and one lowercase letter",