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,
setInputValue: setProductsInputValue,
loadMore: loadMoreProducts,
} = useSelect<BaseMarketing>(MarketingApi.basePath, 'id', 'so_number', '', {
limit: 'limit',
});
} = useSelect<BaseMarketing>(
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<string | number>();
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}