refactor(FE-add-param): Update MarketingFilter to refine API calls and

options handling
This commit is contained in:
rstubryan
2026-04-13 14:23:21 +07:00
parent 34a45d084b
commit 73d05d6b4b
@@ -41,9 +41,12 @@ const MarketingFilterModal = ({
isLoadingOptions: isLoadingProductsOptions, isLoadingOptions: isLoadingProductsOptions,
setInputValue: setProductsInputValue, setInputValue: setProductsInputValue,
loadMore: loadMoreProducts, loadMore: loadMoreProducts,
} = useSelect<BaseMarketing>(MarketingApi.basePath, 'id', 'so_number', '', { } = useSelect<BaseMarketing>(
limit: 'limit', MarketingApi.basePath,
}); 'id',
'so_number',
'search'
);
const productsOptions = useMemo(() => { const productsOptions = useMemo(() => {
if (!productsRawData || !isResponseSuccess(productsRawData)) return []; if (!productsRawData || !isResponseSuccess(productsRawData)) return [];
@@ -70,18 +73,15 @@ const MarketingFilterModal = ({
isLoadingOptions: isLoadingCustomersOptions, isLoadingOptions: isLoadingCustomersOptions,
setInputValue: setCustomersInputValue, setInputValue: setCustomersInputValue,
loadMore: loadMoreCustomers, loadMore: loadMoreCustomers,
} = useSelect(MarketingApi.basePath, 'customer.id', 'customer.name', '', { } = useSelect(
limit: 'limit', MarketingApi.basePath,
}); 'customer.id',
'customer.name',
const salesCustomerOptions = useMemo(() => { 'search',
const seen = new Set<string | number>(); {
return customersOptions.filter((customer) => { has_marketing: 'true',
if (seen.has(customer.value)) return false; }
seen.add(customer.value); );
return true;
});
}, [customersOptions]);
const statusOptions = [ const statusOptions = [
...MARKETING_APPROVAL_LINE.map((item) => ({ ...MARKETING_APPROVAL_LINE.map((item) => ({
@@ -190,7 +190,7 @@ const MarketingFilterModal = ({
label='Customer' label='Customer'
isClearable isClearable
placeholder='Pilih customer' placeholder='Pilih customer'
options={salesCustomerOptions} options={customersOptions}
isLoading={isLoadingCustomersOptions} isLoading={isLoadingCustomersOptions}
value={formik.values.customer} value={formik.values.customer}
onChange={customerChangeHandler} onChange={customerChangeHandler}