Fix remove delete button after bulk delete in categories, collections and order draft lists (#3898)
This commit is contained in:
parent
2074915055
commit
2ab11bb407
4 changed files with 33 additions and 18 deletions
5
.changeset/odd-cycles-tell.md
Normal file
5
.changeset/odd-cycles-tell.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"saleor-dashboard": minor
|
||||
---
|
||||
|
||||
Fix clear row selection and show delete button after bulk deletion in categories, cllections and order drafts list
|
|
@ -114,7 +114,9 @@ export const CategoryList: React.FC<CategoryListProps> = ({ params }) => {
|
|||
);
|
||||
};
|
||||
|
||||
const handleCategoryBulkDelete = (data: CategoryBulkDeleteMutation) => {
|
||||
const handleCategoryBulkDeleteOnComplete = (
|
||||
data: CategoryBulkDeleteMutation,
|
||||
) => {
|
||||
if (data.categoryBulkDelete.errors.length === 0) {
|
||||
navigate(categoryListUrl(), { replace: true });
|
||||
refetch();
|
||||
|
@ -147,9 +149,18 @@ export const CategoryList: React.FC<CategoryListProps> = ({ params }) => {
|
|||
|
||||
const [categoryBulkDelete, categoryBulkDeleteOpts] =
|
||||
useCategoryBulkDeleteMutation({
|
||||
onCompleted: handleCategoryBulkDelete,
|
||||
onCompleted: handleCategoryBulkDeleteOnComplete,
|
||||
});
|
||||
|
||||
const handleCategoryBulkDelete = useCallback(async () => {
|
||||
await categoryBulkDelete({
|
||||
variables: {
|
||||
ids: selectedRowIds,
|
||||
},
|
||||
});
|
||||
clearRowSelection();
|
||||
}, [selectedRowIds]);
|
||||
|
||||
return (
|
||||
<PaginatorContext.Provider value={paginationValues}>
|
||||
<CategoryListPage
|
||||
|
@ -191,13 +202,7 @@ export const CategoryList: React.FC<CategoryListProps> = ({ params }) => {
|
|||
}),
|
||||
)
|
||||
}
|
||||
onConfirm={() =>
|
||||
categoryBulkDelete({
|
||||
variables: {
|
||||
ids: selectedRowIds,
|
||||
},
|
||||
})
|
||||
}
|
||||
onConfirm={handleCategoryBulkDelete}
|
||||
open={params.action === "delete"}
|
||||
title={intl.formatMessage({
|
||||
id: "sG0w22",
|
||||
|
|
|
@ -184,6 +184,15 @@ export const CollectionList: React.FC<CollectionListProps> = ({ params }) => {
|
|||
],
|
||||
);
|
||||
|
||||
const handleCollectionBulkDelete = useCallback(async () => {
|
||||
await collectionBulkDelete({
|
||||
variables: {
|
||||
ids: selectedRowIds,
|
||||
},
|
||||
});
|
||||
clearRowSelection();
|
||||
}, [selectedRowIds]);
|
||||
|
||||
return (
|
||||
<PaginatorContext.Provider value={paginationValues}>
|
||||
<CollectionListPage
|
||||
|
@ -226,13 +235,7 @@ export const CollectionList: React.FC<CollectionListProps> = ({ params }) => {
|
|||
}
|
||||
onClose={closeModal}
|
||||
confirmButtonState={collectionBulkDeleteOpts.status}
|
||||
onConfirm={() =>
|
||||
collectionBulkDelete({
|
||||
variables: {
|
||||
ids: selectedRowIds,
|
||||
},
|
||||
})
|
||||
}
|
||||
onConfirm={handleCollectionBulkDelete}
|
||||
variant="delete"
|
||||
title={intl.formatMessage({
|
||||
id: "Ykw8k5",
|
||||
|
|
|
@ -164,12 +164,14 @@ export const OrderDraftList: React.FC<OrderDraftListProps> = ({ params }) => {
|
|||
|
||||
const handleSort = createSortHandler(navigate, orderDraftListUrl, params);
|
||||
|
||||
const onOrderDraftBulkDelete = () =>
|
||||
orderDraftBulkDelete({
|
||||
const onOrderDraftBulkDelete = useCallback(async () => {
|
||||
await orderDraftBulkDelete({
|
||||
variables: {
|
||||
ids: selectedRowIds,
|
||||
},
|
||||
});
|
||||
clearRowSelection();
|
||||
}, []);
|
||||
|
||||
const handleSetSelectedOrderDraftIds = useCallback(
|
||||
(rows: number[], clearSelection: () => void) => {
|
||||
|
|
Loading…
Reference in a new issue