From 73d05d6b4b6d1bece02169ae7224e6df610b94bf Mon Sep 17 00:00:00 2001 From: rstubryan Date: Mon, 13 Apr 2026 14:23:21 +0700 Subject: [PATCH] refactor(FE-add-param): Update MarketingFilter to refine API calls and options handling --- .../pages/marketing/MarketingFilter.tsx | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/pages/marketing/MarketingFilter.tsx b/src/components/pages/marketing/MarketingFilter.tsx index 624c573c..0142cf07 100644 --- a/src/components/pages/marketing/MarketingFilter.tsx +++ b/src/components/pages/marketing/MarketingFilter.tsx @@ -41,9 +41,12 @@ const MarketingFilterModal = ({ isLoadingOptions: isLoadingProductsOptions, setInputValue: setProductsInputValue, loadMore: loadMoreProducts, - } = useSelect(MarketingApi.basePath, 'id', 'so_number', '', { - limit: 'limit', - }); + } = useSelect( + MarketingApi.basePath, + 'id', + 'so_number', + 'search' + ); const productsOptions = useMemo(() => { if (!productsRawData || !isResponseSuccess(productsRawData)) return []; @@ -70,18 +73,15 @@ const MarketingFilterModal = ({ isLoadingOptions: isLoadingCustomersOptions, setInputValue: setCustomersInputValue, loadMore: loadMoreCustomers, - } = useSelect(MarketingApi.basePath, 'customer.id', 'customer.name', '', { - limit: 'limit', - }); - - const salesCustomerOptions = useMemo(() => { - const seen = new Set(); - return customersOptions.filter((customer) => { - if (seen.has(customer.value)) return false; - seen.add(customer.value); - return true; - }); - }, [customersOptions]); + } = useSelect( + MarketingApi.basePath, + 'customer.id', + 'customer.name', + 'search', + { + has_marketing: 'true', + } + ); const statusOptions = [ ...MARKETING_APPROVAL_LINE.map((item) => ({ @@ -190,7 +190,7 @@ const MarketingFilterModal = ({ label='Customer' isClearable placeholder='Pilih customer' - options={salesCustomerOptions} + options={customersOptions} isLoading={isLoadingCustomersOptions} value={formik.values.customer} onChange={customerChangeHandler}