chore: clean code, add delete
This commit is contained in:
@@ -149,7 +149,7 @@ export default function Categories() {
|
||||
{
|
||||
field: 'actions',
|
||||
headerName: '',
|
||||
width: 130,
|
||||
width: 150,
|
||||
sortable: false,
|
||||
filterable: false,
|
||||
disableExport: true,
|
||||
|
||||
@@ -43,7 +43,7 @@ export default function ProductCollections() {
|
||||
const tagTypeApi = useMemo(() => new TagTypeApi(token), [token]);
|
||||
const categoriesApi = useMemo(() => new CategoriesApi(token), [token]);
|
||||
|
||||
const toast = useApiToast();
|
||||
const { handleError } = useApiToast();
|
||||
|
||||
const [rows, setRows] = useState([]);
|
||||
const [rawRows, setRawRows] = useState([]);
|
||||
@@ -153,7 +153,7 @@ export default function ProductCollections() {
|
||||
setRawRows(normalized);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
toast.error(err?.message || 'Error loading variants');
|
||||
handleError(err, 'Error loading product collections');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -177,12 +177,10 @@ export default function ProductCollections() {
|
||||
const confirmDelete = async () => {
|
||||
try {
|
||||
if (!editRow?.id) return;
|
||||
await api.changeStatusVariant({ mongoId: editRow.id, status: 'Inactive' });
|
||||
await api.changeStatusVariant({ mongoId: editRow._Id, status: 'Inactive' });
|
||||
await load();
|
||||
toast.success('Deleted successfully');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
toast.error(err?.message || 'Delete failed');
|
||||
} finally {
|
||||
setConfirmOpen(false);
|
||||
setEditRow(null);
|
||||
|
||||
Reference in New Issue
Block a user