feat(categories): add create, update, and delete methods to category service
- Introduced `create`, `update`, and `remove` methods for managing categories via the service. - Enables API integration for category CRUD functionality.
This commit is contained in:
@@ -11,4 +11,18 @@ export const CategoryService = {
|
|||||||
const { data } = await api.get<Category>(`/categories/${id}`);
|
const { data } = await api.get<Category>(`/categories/${id}`);
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async create(category: Partial<Category>): Promise<Category> {
|
||||||
|
const { data } = await api.post<Category>("/categories", category);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
|
||||||
|
async update(id: string, category: Partial<Category>): Promise<Category> {
|
||||||
|
const { data } = await api.patch<Category>(`/categories/${id}`, category);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
|
||||||
|
async remove(id: string): Promise<void> {
|
||||||
|
await api.delete(`/categories/${id}`);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user