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) {
|
if (data.categoryBulkDelete.errors.length === 0) {
|
||||||
navigate(categoryListUrl(), { replace: true });
|
navigate(categoryListUrl(), { replace: true });
|
||||||
refetch();
|
refetch();
|
||||||
|
@ -147,9 +149,18 @@ export const CategoryList: React.FC<CategoryListProps> = ({ params }) => {
|
||||||
|
|
||||||
const [categoryBulkDelete, categoryBulkDeleteOpts] =
|
const [categoryBulkDelete, categoryBulkDeleteOpts] =
|
||||||
useCategoryBulkDeleteMutation({
|
useCategoryBulkDeleteMutation({
|
||||||
onCompleted: handleCategoryBulkDelete,
|
onCompleted: handleCategoryBulkDeleteOnComplete,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleCategoryBulkDelete = useCallback(async () => {
|
||||||
|
await categoryBulkDelete({
|
||||||
|
variables: {
|
||||||
|
ids: selectedRowIds,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
clearRowSelection();
|
||||||
|
}, [selectedRowIds]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PaginatorContext.Provider value={paginationValues}>
|
<PaginatorContext.Provider value={paginationValues}>
|
||||||
<CategoryListPage
|
<CategoryListPage
|
||||||
|
@ -191,13 +202,7 @@ export const CategoryList: React.FC<CategoryListProps> = ({ params }) => {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
onConfirm={() =>
|
onConfirm={handleCategoryBulkDelete}
|
||||||
categoryBulkDelete({
|
|
||||||
variables: {
|
|
||||||
ids: selectedRowIds,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
open={params.action === "delete"}
|
open={params.action === "delete"}
|
||||||
title={intl.formatMessage({
|
title={intl.formatMessage({
|
||||||
id: "sG0w22",
|
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 (
|
return (
|
||||||
<PaginatorContext.Provider value={paginationValues}>
|
<PaginatorContext.Provider value={paginationValues}>
|
||||||
<CollectionListPage
|
<CollectionListPage
|
||||||
|
@ -226,13 +235,7 @@ export const CollectionList: React.FC<CollectionListProps> = ({ params }) => {
|
||||||
}
|
}
|
||||||
onClose={closeModal}
|
onClose={closeModal}
|
||||||
confirmButtonState={collectionBulkDeleteOpts.status}
|
confirmButtonState={collectionBulkDeleteOpts.status}
|
||||||
onConfirm={() =>
|
onConfirm={handleCollectionBulkDelete}
|
||||||
collectionBulkDelete({
|
|
||||||
variables: {
|
|
||||||
ids: selectedRowIds,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
variant="delete"
|
variant="delete"
|
||||||
title={intl.formatMessage({
|
title={intl.formatMessage({
|
||||||
id: "Ykw8k5",
|
id: "Ykw8k5",
|
||||||
|
|
|
@ -164,12 +164,14 @@ export const OrderDraftList: React.FC<OrderDraftListProps> = ({ params }) => {
|
||||||
|
|
||||||
const handleSort = createSortHandler(navigate, orderDraftListUrl, params);
|
const handleSort = createSortHandler(navigate, orderDraftListUrl, params);
|
||||||
|
|
||||||
const onOrderDraftBulkDelete = () =>
|
const onOrderDraftBulkDelete = useCallback(async () => {
|
||||||
orderDraftBulkDelete({
|
await orderDraftBulkDelete({
|
||||||
variables: {
|
variables: {
|
||||||
ids: selectedRowIds,
|
ids: selectedRowIds,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
clearRowSelection();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleSetSelectedOrderDraftIds = useCallback(
|
const handleSetSelectedOrderDraftIds = useCallback(
|
||||||
(rows: number[], clearSelection: () => void) => {
|
(rows: number[], clearSelection: () => void) => {
|
||||||
|
|
Loading…
Reference in a new issue