|
|
@@ -1,7 +1,7 @@ |
|
|
|
"use client"; |
|
|
|
|
|
|
|
import { Customer } from "@/app/api/customer"; |
|
|
|
import React, { useCallback, useMemo, useState } from "react"; |
|
|
|
import React, { useCallback, useEffect, useMemo, useState } from "react"; |
|
|
|
import SearchBox, { Criterion } from "../SearchBox"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import SearchResults, { Column } from "../SearchResults"; |
|
|
@@ -24,6 +24,9 @@ const CustomerSearch: React.FC<Props> = ({ customers }) => { |
|
|
|
const searchParams = useSearchParams() |
|
|
|
|
|
|
|
const [filteredCustomers, setFilteredCustomers] = useState(customers); |
|
|
|
useEffect(() => { |
|
|
|
setFilteredCustomers(customers) |
|
|
|
}, [customers]) |
|
|
|
const searchCriteria: Criterion<SearchParamNames>[] = useMemo( |
|
|
|
() => [ |
|
|
|
{ label: t("Customer Code"), paramName: "code", type: "text" }, |
|
|
@@ -47,8 +50,6 @@ const CustomerSearch: React.FC<Props> = ({ customers }) => { |
|
|
|
await deleteCustomer(customer.id) |
|
|
|
|
|
|
|
successDialog("Delete Success", t) |
|
|
|
|
|
|
|
setFilteredCustomers((prev) => prev.filter((obj) => obj.id !== customer.id)) |
|
|
|
}, t) |
|
|
|
}, []); |
|
|
|
|
|
|
|