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 CustomerSelector

Steven Tey2823a6ec93d4
diff --git a/apps/web/ui/customers/customer-selector.tsx b/apps/web/ui/customers/customer-selector.tsx
index 270d03836c..9c7f41ac94 100644
--- a/apps/web/ui/customers/customer-selector.tsx
+++ b/apps/web/ui/customers/customer-selector.tsx
@@ -1,8 +1,7 @@
import useCustomers from "@/lib/swr/use-customers";
-import { CUSTOMERS_MAX_PAGE_SIZE } from "@/lib/zod/schemas/customers";
import { Combobox, ComboboxProps } from "@dub/ui";
import { cn } from "@dub/utils";
-import { useEffect, useMemo, useState } from "react";
+import { useMemo, useState } from "react";
import { useDebounce } from "use-debounce";
import {
AddCustomerModal,
@@ -25,12 +24,11 @@ export function CustomerSelector({
...rest
}: CustomerSelectorProps) {
const [search, setSearch] = useState("");
- const [useAsync, setUseAsync] = useState(false);
const [debouncedSearch] = useDebounce(search, 500);
const [openPopover, setOpenPopover] = useState(false);
const { customers, loading } = useCustomers({
- query: useAsync ? { search: debouncedSearch } : undefined,
+ query: { search: debouncedSearch },
});
const { customers: selectedCustomers, loading: selectedCustomersLoading } =
@@ -40,12 +38,6 @@ export function CustomerSelector({
: undefined,
});
- useEffect(() => {
- if (customers && !useAsync && customers.length >= CUSTOMERS_MAX_PAGE_SIZE) {
- setUseAsync(true);
- }
- }, [customers, useAsync]);
-
const [showAddCustomerModal, setShowAddCustomerModal] = useState(false);
const [initialData, setInitialData] = useState<
AddCustomerInitialData | undefined
@@ -54,7 +46,7 @@ export function CustomerSelector({
const customerOptions = useMemo(() => {
return (
customers?.map((customer) => ({
- value: customer.email || customer.id,
+ value: customer.id,
label: customer.name || customer.email || customer.externalId,
icon: (
<span className="shrink-0 text-neutral-600">
@@ -133,7 +125,7 @@ export function CustomerSelector({
return true;
},
})}
- shouldFilter={!useAsync}
+ shouldFilter={false}
matchTriggerWidth
open={openPopover}
onOpenChange={setOpenPopover}