diff --git a/src/components/pages/report/logistic-stock/tab/PurchasesPerSupplierTab.tsx b/src/components/pages/report/logistic-stock/tab/PurchasesPerSupplierTab.tsx index 881c85f7..90018e98 100644 --- a/src/components/pages/report/logistic-stock/tab/PurchasesPerSupplierTab.tsx +++ b/src/components/pages/report/logistic-stock/tab/PurchasesPerSupplierTab.tsx @@ -102,6 +102,14 @@ const PurchasesPerSupplierTab = () => { [] ); + const sortByOptions = useMemo( + () => [ + { value: 'ASC', label: 'Ascending' }, + { value: 'DESC', label: 'Descending' }, + ], + [] + ); + const areaChangeHandler = useCallback( (val: OptionType | OptionType[] | null) => { const arr = Array.isArray(val) ? val : val ? [val] : []; @@ -163,6 +171,16 @@ const PurchasesPerSupplierTab = () => { [updateFilter] ); + const sortByHandler = useCallback( + (val: OptionType | OptionType[] | null) => { + const newVal = val as OptionType; + const sortValue = (newVal?.value as 'ASC' | 'DESC') || 'ASC'; + updateFilter('sort_by', sortValue); + setIsSubmitted(false); + }, + [updateFilter] + ); + const startDateChangeHandler = useCallback< ChangeEventHandler >( @@ -843,19 +861,34 @@ const PurchasesPerSupplierTab = () => { isLoading={isLoadingProductCategories} isClearable /> - option.value === tableFilterState.filter_by - ) || null - } - onChange={dataTypeChangeHandler} - isLoading={false} - isClearable={false} - /> +
+ option.value === tableFilterState.filter_by + ) || null + } + onChange={dataTypeChangeHandler} + isLoading={false} + isClearable={false} + /> + option.value === tableFilterState.sort_by + ) || null + } + onChange={sortByHandler} + isLoading={false} + isClearable={false} + /> +