feat: delete views from views dropdown (#1234)

Closes #1129

Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
Thaïs
2023-08-16 23:27:03 +02:00
committed by GitHub
parent 8863bb0035
commit a24e1e4dc9
17 changed files with 188 additions and 24 deletions

View File

@ -136,10 +136,12 @@ export const useViewSorts = <SortField>({
[currentViewId, deleteViewSortsMutation],
);
const updateSorts = useCallback(
const handleSortsChange = useCallback(
async (nextSorts: SelectedSortType<SortField>[]) => {
if (!currentViewId) return;
setSorts(nextSorts);
const sortsToCreate = nextSorts.filter(
(nextSort) => !sortsByKey[nextSort.key],
);
@ -162,10 +164,11 @@ export const useViewSorts = <SortField>({
createViewSorts,
currentViewId,
deleteViewSorts,
setSorts,
sortsByKey,
updateViewSorts,
],
);
return { updateSorts };
return { handleSortsChange };
};