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', field: 'actions',
headerName: '', headerName: '',
width: 130, width: 150,
sortable: false, sortable: false,
filterable: false, filterable: false,
disableExport: true, disableExport: true,

View File

@@ -43,7 +43,7 @@ export default function ProductCollections() {
const tagTypeApi = useMemo(() => new TagTypeApi(token), [token]); const tagTypeApi = useMemo(() => new TagTypeApi(token), [token]);
const categoriesApi = useMemo(() => new CategoriesApi(token), [token]); const categoriesApi = useMemo(() => new CategoriesApi(token), [token]);
const toast = useApiToast(); const { handleError } = useApiToast();
const [rows, setRows] = useState([]); const [rows, setRows] = useState([]);
const [rawRows, setRawRows] = useState([]); const [rawRows, setRawRows] = useState([]);
@@ -153,7 +153,7 @@ export default function ProductCollections() {
setRawRows(normalized); setRawRows(normalized);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
toast.error(err?.message || 'Error loading variants'); handleError(err, 'Error loading product collections');
} finally { } finally {
setLoading(false); setLoading(false);
} }
@@ -177,12 +177,10 @@ export default function ProductCollections() {
const confirmDelete = async () => { const confirmDelete = async () => {
try { try {
if (!editRow?.id) return; if (!editRow?.id) return;
await api.changeStatusVariant({ mongoId: editRow.id, status: 'Inactive' }); await api.changeStatusVariant({ mongoId: editRow._Id, status: 'Inactive' });
await load(); await load();
toast.success('Deleted successfully');
} catch (err) { } catch (err) {
console.error(err); console.error(err);
toast.error(err?.message || 'Delete failed');
} finally { } finally {
setConfirmOpen(false); setConfirmOpen(false);
setEditRow(null); setEditRow(null);