chore: clean code, add delete

This commit is contained in:
Rodolfo Ruiz
2025-09-06 20:45:56 -06:00
parent b3209a4019
commit f7adaf1b18
5 changed files with 24 additions and 26 deletions

View File

@@ -149,7 +149,7 @@ export default function Categories() {
{
field: 'actions',
headerName: '',
width: 130,
width: 150,
sortable: false,
filterable: false,
disableExport: true,

View File

@@ -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);