Add category edit action

This commit is contained in:
Cauê Faleiros
2026-08-10 11:15:15 -03:00
parent 4556659fcf
commit e85dbe6f10
4 changed files with 94 additions and 11 deletions

View File

@@ -291,6 +291,21 @@ export const saveCatalogCategory = async (payload: CatalogCategoryPayload): Prom
return data as CatalogCategory;
};
export const updateCatalogCategory = async (id: number, payload: CatalogCategoryPayload): Promise<CatalogCategory> => {
const response = await authFetch(`/catalog/categories/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
const data = await response.json().catch(() => null);
if (!response.ok) {
throw new Error(data?.error || 'Não foi possível atualizar a categoria.');
}
return data as CatalogCategory;
};
export const deleteCatalogCategory = async (id: number): Promise<void> => {
const response = await authFetch(`/catalog/categories/${id}`, { method: 'DELETE' });
if (!response.ok) {