From 7005ab67b71dcb79056c2d8a440330b5998d6a2a Mon Sep 17 00:00:00 2001 From: AmirReza Jamali Date: Sat, 22 Nov 2025 15:22:44 +0330 Subject: [PATCH] feat(customers): Add filtering functionality to customer list table - Create new CustomerListFilters component with status, role, and type filter options - Integrate filter modal into customer list table with open/close functionality - Add filter form handling with react-hook-form for managing filter state - Implement search functionality triggered by filter form submission - Add EmptyListWrapper component to display message when no customers found - Replace inline create button with reusable ListHeader component - Add clearable select fields for better filter UX - Update customer table to safely handle optional customer properties - Add new CustomerStatus and CustomerType enums to support filtering options - Improve table organization with proper imports and component structure --- .../Tables/customers/CustomerListFilters.tsx | 90 +++++++ src/components/Tables/customers/index.tsx | 232 ++++++++++-------- .../customers/useCustomerListPresenter.ts | 51 +++- src/constants/enums.ts | 10 + 4 files changed, 278 insertions(+), 105 deletions(-) create mode 100644 src/components/Tables/customers/CustomerListFilters.tsx diff --git a/src/components/Tables/customers/CustomerListFilters.tsx b/src/components/Tables/customers/CustomerListFilters.tsx new file mode 100644 index 0000000..1f75d5b --- /dev/null +++ b/src/components/Tables/customers/CustomerListFilters.tsx @@ -0,0 +1,90 @@ +import { Select } from "@/components/FormElements/select"; +import { AdminRoles, CustomerStatus, CustomerType } from "@/constants/enums"; +import { getEnumAsArray } from "@/utils/shared"; +import { + FieldValues, + UseFormHandleSubmit, + UseFormRegister, + UseFormSetValue, + UseFormWatch, +} from "react-hook-form"; + +interface CustomerListFiltersProps { + filterRegister: UseFormRegister; + setIsFilterModalOpen: (isOpen: boolean) => void; + isMutating: number; + handleFilterSubmit: UseFormHandleSubmit; + search: (data: any) => void; + watch: UseFormWatch; + setValue: UseFormSetValue; +} + +const CustomerListFilters = ({ + filterRegister, + setIsFilterModalOpen, + isMutating, + handleFilterSubmit, + search, + watch, + setValue, +}: CustomerListFiltersProps) => { + return ( +
+ setValue("role", undefined)} + /> +