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.

`preserveOrder` if `variant="header"`

Steven Teyb57281e577a9
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/groups-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/groups-table.tsx
index f77b9a018e..5f9af2261e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/groups-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/groups-table.tsx
@@ -231,7 +231,7 @@ export function GroupsTable() {
"totalConversions",
"totalSaleAmount",
"totalCommissions",
- // "netRevenue", // TODO: add back when we can sort by this again
+ "netRevenue",
],
sortBy,
sortOrder,
diff --git a/apps/web/lib/email/is-generic-email.ts b/apps/web/lib/email/is-generic-email.ts
index ba9fadd0f0..b2bad1916c 100644
--- a/apps/web/lib/email/is-generic-email.ts
+++ b/apps/web/lib/email/is-generic-email.ts
@@ -78,6 +78,7 @@ const GENERIC_EMAIL_DOMAINS = [
"okyre.com",
"pinmx.net",
"pingmx.net",
+ "telus.net",
];
const GENERIC_EMAIL_DOMAIN_PREFIXES = [
diff --git a/apps/web/lib/swr/use-groups.ts b/apps/web/lib/swr/use-groups.ts
index 889646948c..9c29fb3725 100644
--- a/apps/web/lib/swr/use-groups.ts
+++ b/apps/web/lib/swr/use-groups.ts
@@ -14,13 +14,15 @@ export default function useGroups<T extends GroupProps>({
query?: z.infer<typeof partialQuerySchema>;
enabled?: boolean;
} = {}) {
- const { id: workspaceId, defaultProgramId } = useWorkspace();
+ const { id: workspaceId, defaultProgramId, partnersUsage } = useWorkspace();
const { data, isLoading, error } = useSWR<T[]>(
enabled && workspaceId && defaultProgramId
? `/api/groups?${new URLSearchParams({
workspaceId,
sortBy: "totalSaleAmount",
+ includeExpandedFields:
+ partnersUsage && partnersUsage <= 100000 ? "true" : "false",
...(query as Record<string, string>),
}).toString()}`
: null,
diff --git a/apps/web/lib/zod/schemas/groups.ts b/apps/web/lib/zod/schemas/groups.ts
index 68d7bda5d2..cafa1fbc97 100644
--- a/apps/web/lib/zod/schemas/groups.ts
+++ b/apps/web/lib/zod/schemas/groups.ts
@@ -186,8 +186,10 @@ export const getGroupsQuerySchema = z
"totalSaleAmount",
"totalConversions",
"totalCommissions",
- // "netRevenue", // TODO: add back when we can sort by this again
+ "netRevenue",
])
+ // TODO: right now this only works if includeExpandedFields is true, else it sorts by group name by default
+ // we should make sort work without includeExpandedFields
.default("totalSaleAmount"),
sortOrder: z.enum(["asc", "desc"]).default("desc"),
includeExpandedFields: booleanQuerySchema.optional(),
diff --git a/apps/web/ui/partners/groups/group-selector.tsx b/apps/web/ui/partners/groups/group-selector.tsx
index cbe4a18185..530a098081 100644
--- a/apps/web/ui/partners/groups/group-selector.tsx
+++ b/apps/web/ui/partners/groups/group-selector.tsx
@@ -32,7 +32,7 @@ export function GroupSelector({
query: useAsync ? { search: debouncedSearch } : undefined,
});
- const { groups: selectedGroups, loading: selectedGroupsLoading } = useGroups({
+ const { groups: selectedGroups } = useGroups({
query: selectedGroupId ? { groupIds: [selectedGroupId] } : undefined,
});
@@ -81,7 +81,7 @@ export function GroupSelector({
selectedOption?.icon
)
}
- caret={true}
+ caret
placeholder={
<div className="h-4 w-32 animate-pulse rounded bg-neutral-200" />
}
@@ -91,6 +91,7 @@ export function GroupSelector({
matchTriggerWidth
open={openPopover}
onOpenChange={setOpenPopover}
+ preserveOrder={variant === "header"}
{...(variant === "header"
? {
popoverProps: {
diff --git a/packages/ui/src/combobox/index.tsx b/packages/ui/src/combobox/index.tsx
index 7a4f14c347..f501e5e4d4 100644
--- a/packages/ui/src/combobox/index.tsx
+++ b/packages/ui/src/combobox/index.tsx
@@ -70,6 +70,7 @@ export type ComboboxProps<
matchTriggerWidth?: boolean;
hideSearch?: boolean;
forceDropdown?: boolean;
+ preserveOrder?: boolean;
}>;
function isMultipleSelection(
@@ -113,6 +114,7 @@ export function Combobox({
matchTriggerWidth,
hideSearch = false,
forceDropdown = false,
+ preserveOrder = false,
children,
}: ComboboxProps<boolean | undefined, any>) {
const isMultiple = isMultipleSelection(multiple, setSelected);
@@ -165,7 +167,7 @@ export function Combobox({
const sortOptions = useCallback(
(options: ComboboxOption[], search: string) => {
- return search === ""
+ return search === "" && !preserveOrder
? [
...options.filter(
(o) => o.first && !selected.some((s) => s.value === o.value),