Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update create-commission-sheet.tsx

Kiran K8a000184974d
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/create-commission-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/create-commission-sheet.tsx
index 390d338cfd..d4b38942a1 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/create-commission-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/create-commission-sheet.tsx
@@ -33,10 +33,10 @@ function CreateCommissionSheetContent({
const { program } = useProgram();
const { partners } = usePartners();
const { id: workspaceId } = useWorkspace();
+ const [hasInvoiceId, setHasInvoiceId] = useState(false);
const [isNewCustomer, setIsNewCustomer] = useState(false);
const [hasDifferentCreationDate, setHasDifferentCreationDate] =
useState(false);
- const [hasInvoiceId, setHasInvoiceId] = useState(false);
const {
register,
@@ -60,6 +60,12 @@ function CreateCommissionSheetContent({
}
}, [hasDifferentCreationDate, setValue]);
+ useEffect(() => {
+ if (customerId) {
+ setValue("customerId", customerId, { shouldValidate: true });
+ }
+ }, [customerId, setValue]);
+
const partnerOptions = useMemo(() => {
return partners?.map((partner) => ({
value: partner.id,
@@ -201,7 +207,9 @@ function CreateCommissionSheetContent({
errors.saleDate &&
"border-red-600 focus:border-red-500 focus:ring-red-600",
)}
- {...register("saleDate")}
+ {...register("saleDate", {
+ required: programDefaultReward?.event === "sale",
+ })}
value={
saleDate
? new Date(saleDate).toISOString().split("T")[0]
@@ -242,6 +250,7 @@ function CreateCommissionSheetContent({
min: 0,
onChange: handleMoneyInputChange,
setValueAs: (value) => (value === "" ? null : value),
+ required: programDefaultReward?.event === "sale",
})}
placeholder="0.00"
/>
@@ -434,7 +443,7 @@ function CreateCommissionSheetContent({
text="Create commission"
className="w-fit"
loading={isPending}
- disabled={!partnerId || !linkId}
+ disabled={!partnerId || !linkId || !customerId}
/>
</div>
</div>