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.

fix PartnerSelector + add all reward types to commission sheet

Steven Tey5c1bbabbbaa5
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
index de3555a1ce..697705a380 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
@@ -1,7 +1,6 @@
import { createManualCommissionAction } from "@/lib/actions/partners/create-manual-commission";
import { handleMoneyKeyDown } from "@/lib/form-utils";
import { mutatePrefix } from "@/lib/swr/mutate";
-import useRewards from "@/lib/swr/use-rewards";
import useWorkspace from "@/lib/swr/use-workspace";
import { CustomerActivityResponse } from "@/lib/types";
import { createCommissionSchema } from "@/lib/zod/schemas/commissions";
@@ -50,7 +49,6 @@ function CreateCommissionSheetContent({
const { id: workspaceId, defaultProgramId, slug } = useWorkspace();
const [hasInvoiceId, setHasInvoiceId] = useState(false);
const [hasProductId, setHasProductId] = useState(false);
- const { rewards, loading: rewardsLoading } = useRewards();
const [hasCustomLeadEventDate, setHasCustomLeadEventDate] = useState(false);
const [hasCustomLeadEventName, setHasCustomLeadEventName] = useState(false);
@@ -172,10 +170,6 @@ function CreateCommissionSheetContent({
});
};
- const rewardEventTypes = useMemo(() => {
- return rewards?.map((reward) => reward.event);
- }, [rewards]);
-
// Filter events based on commission type
const filteredEvents = useMemo(() => {
if (!customerActivity?.events) return [];
@@ -339,31 +333,20 @@ function CreateCommissionSheetContent({
Commission type
</h2>
</label>
- {!rewardsLoading ? (
- <ToggleGroup
- className="mt-2 flex w-full items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 p-1"
- optionClassName="h-8 flex items-center justify-center rounded-md flex-1 text-sm"
- indicatorClassName="bg-white"
- options={[
- { value: "custom", label: "One-time" },
- ...(rewardEventTypes?.includes("sale")
- ? [{ value: "sale", label: "Sale" }]
- : []),
- ...(rewardEventTypes?.includes("lead")
- ? [{ value: "lead", label: "Lead" }]
- : []),
- ]}
- selected={commissionType}
- selectAction={(id: CommissionType) =>
- setCommissionType(id)
- }
- />
- ) : (
- <div className="mt-2 flex w-full items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 p-1">
- <div className="h-8 flex-1 animate-pulse rounded-md bg-neutral-200" />
- <div className="h-8 flex-1 animate-pulse rounded-md bg-neutral-200" />
- </div>
- )}
+ <ToggleGroup
+ className="mt-2 flex w-full items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 p-1"
+ optionClassName="h-8 flex items-center justify-center rounded-md flex-1 text-sm"
+ indicatorClassName="bg-white"
+ options={[
+ { value: "custom", label: "One-time" },
+ { value: "lead", label: "Lead" },
+ { value: "sale", label: "Sale" },
+ ]}
+ selected={commissionType}
+ selectAction={(id: CommissionType) =>
+ setCommissionType(id)
+ }
+ />
</div>
{commissionType !== "custom" && (
diff --git a/apps/web/ui/partners/partner-selector.tsx b/apps/web/ui/partners/partner-selector.tsx
index 5987c15abd..d4c72aa7dc 100644
--- a/apps/web/ui/partners/partner-selector.tsx
+++ b/apps/web/ui/partners/partner-selector.tsx
@@ -87,14 +87,14 @@ export function PartnerSelector({
}}
selected={selectedOption}
icon={
- !selectedOption?.icon ? (
+ variant === "header" && !selectedOption?.icon ? (
<div className="size-5 flex-none animate-pulse rounded-full bg-neutral-200" />
) : (
selectedOption?.icon
)
}
caret={true}
- placeholder={selectedPartnersLoading ? "" : "Select partner"}
+ placeholder={variant === "header" ? "" : "Select partner"}
searchPlaceholder="Search partners..."
onSearchChange={setSearch}
shouldFilter={!useAsync}
@@ -130,10 +130,10 @@ export function PartnerSelector({
})}
{...rest}
>
- {!selectedOption?.label ? (
+ {variant === "header" && !selectedOption?.label ? (
<div className="h-6 w-[120px] animate-pulse rounded bg-neutral-100" />
) : (
- selectedOption.label
+ selectedOption?.label
)}
</Combobox>
);