Add category edit action
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user