chore: add color for category
This commit is contained in:
@@ -590,6 +590,7 @@ const V1_PUBLIC = "https://uber-stup.club/api/v1";
|
||||
export interface Category {
|
||||
id: number;
|
||||
name: string;
|
||||
color: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
@@ -604,11 +605,12 @@ export const getCategories = async (): Promise<Category[]> => {
|
||||
|
||||
export const createCategoryAdmin = async (
|
||||
name: string,
|
||||
color: string,
|
||||
): Promise<{ success: boolean; category?: Category; error?: string }> => {
|
||||
try {
|
||||
const { data } = await apiClient.post(
|
||||
`${V2}/admin/protected/categories`,
|
||||
{ name },
|
||||
{ name, color },
|
||||
);
|
||||
return { success: true, category: data.category };
|
||||
} catch (error: any) {
|
||||
@@ -622,11 +624,12 @@ export const createCategoryAdmin = async (
|
||||
export const updateCategoryAdmin = async (
|
||||
id: number,
|
||||
name: string,
|
||||
color: string,
|
||||
): Promise<{ success: boolean; category?: Category; error?: string }> => {
|
||||
try {
|
||||
const { data } = await apiClient.put(
|
||||
`${V2}/admin/protected/categories/${id}`,
|
||||
{ name },
|
||||
{ name, color },
|
||||
);
|
||||
return { success: true, category: data.category };
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user