store 3
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import useAxios from '@core/utils/useAxios'
|
||||
import type { Category, CategoryInput } from '@/model/category'
|
||||
|
||||
export type CategoryListParams = {
|
||||
active?: number
|
||||
select_only?: boolean
|
||||
search?: string
|
||||
}
|
||||
|
||||
export const getCategories = async (params?: CategoryListParams) =>
|
||||
await useAxios.get<Category[]>('/admin/categories', { params })
|
||||
|
||||
export const updateCategory = async (id: number, payload: Partial<CategoryInput>) =>
|
||||
await useAxios.put<Category>(`/admin/categories/${id}`, payload)
|
||||
|
||||
export const syncCategoriesFromProducts = async () =>
|
||||
await useAxios.post<{ message: string; created: number; items: Category[] }>(
|
||||
'/admin/categories/sync-from-products'
|
||||
)
|
||||
|
||||
export const changeCategoryActive = async (id: number, active: 0 | 1) =>
|
||||
await useAxios.get(`/admin/categories/${id}/active/${active}`)
|
||||
Reference in New Issue
Block a user