Fix remove delete button after bulk delete in categories, collections and order draft lists (#3898)

This commit is contained in:
Paweł Chyła 2023-07-12 10:30:24 +02:00 committed by GitHub
parent 2074915055
commit 2ab11bb407
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 18 deletions

View 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

View file

@ -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",

View file

@ -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",

View file

@ -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) => {