base commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { apiClient } from '@/shared/api/client'
|
||||
|
||||
export type InfoPageBlock = {
|
||||
id: string
|
||||
key: string
|
||||
title: string
|
||||
body: string
|
||||
sort: number
|
||||
published: boolean
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export async function fetchPublicInfoBlocks(): Promise<{ items: InfoPageBlock[] }> {
|
||||
const { data } = await apiClient.get<{ items: InfoPageBlock[] }>('info-page/blocks')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchAdminInfoBlocks(): Promise<{ items: InfoPageBlock[] }> {
|
||||
const { data } = await apiClient.get<{ items: InfoPageBlock[] }>('admin/info-page/blocks')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function createInfoBlock(
|
||||
body: Pick<InfoPageBlock, 'key' | 'title' | 'body' | 'sort' | 'published'>,
|
||||
): Promise<{ item: InfoPageBlock }> {
|
||||
const { data } = await apiClient.post<{ item: InfoPageBlock }>('admin/info-page/blocks', body)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateInfoBlock(
|
||||
id: string,
|
||||
body: Partial<Pick<InfoPageBlock, 'key' | 'title' | 'body' | 'sort' | 'published'>>,
|
||||
): Promise<{ item: InfoPageBlock }> {
|
||||
const { data } = await apiClient.patch<{ item: InfoPageBlock }>(`admin/info-page/blocks/${id}`, body)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deleteInfoBlock(id: string): Promise<void> {
|
||||
await apiClient.delete(`admin/info-page/blocks/${id}`)
|
||||
}
|
||||
@@ -49,47 +49,31 @@ export type AdminOrderDetailResponse = {
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchAdminOrdersSummary(token: string): Promise<{ attentionCount: number }> {
|
||||
const { data } = await apiClient.get<{ attentionCount: number }>('admin/orders/summary', {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function fetchAdminOrdersSummary(): Promise<{ attentionCount: number }> {
|
||||
const { data } = await apiClient.get<{ attentionCount: number }>('admin/orders/summary')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchAdminOrders(
|
||||
token: string,
|
||||
params?: { status?: string; deliveryType?: 'delivery' | 'pickup'; q?: string; page?: number; pageSize?: number },
|
||||
): Promise<AdminOrdersListResponse> {
|
||||
const { data } = await apiClient.get<AdminOrdersListResponse>('admin/orders', {
|
||||
params,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function fetchAdminOrders(params?: {
|
||||
status?: string
|
||||
deliveryType?: 'delivery' | 'pickup'
|
||||
q?: string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}): Promise<AdminOrdersListResponse> {
|
||||
const { data } = await apiClient.get<AdminOrdersListResponse>('admin/orders', { params })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchAdminOrder(token: string, id: string): Promise<AdminOrderDetailResponse> {
|
||||
const { data } = await apiClient.get<AdminOrderDetailResponse>(`admin/orders/${id}`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function fetchAdminOrder(id: string): Promise<AdminOrderDetailResponse> {
|
||||
const { data } = await apiClient.get<AdminOrderDetailResponse>(`admin/orders/${id}`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function setAdminOrderStatus(token: string, id: string, status: string): Promise<void> {
|
||||
await apiClient.patch(
|
||||
`admin/orders/${id}/status`,
|
||||
{ status },
|
||||
{
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
},
|
||||
)
|
||||
export async function setAdminOrderStatus(id: string, status: string): Promise<void> {
|
||||
await apiClient.patch(`admin/orders/${id}/status`, { status })
|
||||
}
|
||||
|
||||
export async function postAdminOrderMessage(token: string, id: string, text: string): Promise<void> {
|
||||
await apiClient.post(
|
||||
`admin/orders/${id}/messages`,
|
||||
{ text },
|
||||
{
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
},
|
||||
)
|
||||
export async function postAdminOrderMessage(id: string, text: string): Promise<void> {
|
||||
await apiClient.post(`admin/orders/${id}/messages`, { text })
|
||||
}
|
||||
|
||||
@@ -43,39 +43,31 @@ export async function fetchCategories(): Promise<Category[]> {
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchAdminProducts(token: string): Promise<Product[]> {
|
||||
const { data } = await apiClient.get<Product[]>('admin/products', {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function fetchAdminProducts(): Promise<Product[]> {
|
||||
const { data } = await apiClient.get<Product[]>('admin/products')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function createProduct(
|
||||
token: string,
|
||||
body: {
|
||||
title: string
|
||||
slug?: string
|
||||
shortDescription?: string | null
|
||||
description?: string | null
|
||||
quantity?: number | null
|
||||
materials?: string[]
|
||||
priceCents: number
|
||||
imageUrl?: string | null
|
||||
imageUrls?: string[]
|
||||
published: boolean
|
||||
inStock?: boolean
|
||||
leadTimeDays?: number | null
|
||||
categoryId: string
|
||||
},
|
||||
): Promise<Product> {
|
||||
const { data } = await apiClient.post<Product>('admin/products', body, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function createProduct(body: {
|
||||
title: string
|
||||
slug?: string
|
||||
shortDescription?: string | null
|
||||
description?: string | null
|
||||
quantity?: number | null
|
||||
materials?: string[]
|
||||
priceCents: number
|
||||
imageUrl?: string | null
|
||||
imageUrls?: string[]
|
||||
published: boolean
|
||||
inStock?: boolean
|
||||
leadTimeDays?: number | null
|
||||
categoryId: string
|
||||
}): Promise<Product> {
|
||||
const { data } = await apiClient.post<Product>('admin/products', body)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateProduct(
|
||||
token: string,
|
||||
id: string,
|
||||
body: Partial<{
|
||||
title: string
|
||||
@@ -93,24 +85,15 @@ export async function updateProduct(
|
||||
categoryId: string
|
||||
}>,
|
||||
): Promise<Product> {
|
||||
const { data } = await apiClient.patch<Product>(`admin/products/${id}`, body, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
const { data } = await apiClient.patch<Product>(`admin/products/${id}`, body)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deleteProduct(token: string, id: string): Promise<void> {
|
||||
await apiClient.delete(`admin/products/${id}`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function deleteProduct(id: string): Promise<void> {
|
||||
await apiClient.delete(`admin/products/${id}`)
|
||||
}
|
||||
|
||||
export async function createCategory(
|
||||
token: string,
|
||||
body: { name: string; slug?: string; sort?: number },
|
||||
): Promise<Category> {
|
||||
const { data } = await apiClient.post<Category>('admin/categories', body, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function createCategory(body: { name: string; slug?: string; sort?: number }): Promise<Category> {
|
||||
const { data } = await apiClient.post<Category>('admin/categories', body)
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -2,15 +2,25 @@ import { apiClient } from '@/shared/api/client'
|
||||
|
||||
export async function postProductReview(
|
||||
productId: string,
|
||||
body: { rating: number; text?: string | null },
|
||||
body: { rating: number; text?: string | null; imageUrl?: string | null },
|
||||
): Promise<void> {
|
||||
await apiClient.post(`products/${productId}/reviews`, body)
|
||||
}
|
||||
|
||||
export async function uploadReviewImage(file: File): Promise<{ url: string }> {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
const { data } = await apiClient.post<{ url: string }>('reviews/upload-image', fd, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
export type PublicReviewFeedItem = {
|
||||
id: string
|
||||
rating: number
|
||||
text: string | null
|
||||
imageUrl: string | null
|
||||
createdAt: string
|
||||
authorDisplay: string
|
||||
productId: string
|
||||
@@ -32,6 +42,7 @@ export type PublicProductReviewItem = {
|
||||
id: string
|
||||
rating: number
|
||||
text: string | null
|
||||
imageUrl: string | null
|
||||
createdAt: string
|
||||
authorDisplay: string
|
||||
}
|
||||
|
||||
@@ -18,23 +18,15 @@ export type AdminReviewsListResponse = {
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export async function fetchAdminReviews(
|
||||
token: string,
|
||||
params?: { status?: string; page?: number; pageSize?: number },
|
||||
): Promise<AdminReviewsListResponse> {
|
||||
const { data } = await apiClient.get<AdminReviewsListResponse>('admin/reviews', {
|
||||
params,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function fetchAdminReviews(params?: {
|
||||
status?: string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}): Promise<AdminReviewsListResponse> {
|
||||
const { data } = await apiClient.get<AdminReviewsListResponse>('admin/reviews', { params })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function moderateReview(token: string, id: string, action: 'approve' | 'reject'): Promise<void> {
|
||||
await apiClient.patch(
|
||||
`admin/reviews/${id}`,
|
||||
{ action },
|
||||
{
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
},
|
||||
)
|
||||
export async function moderateReview(id: string, action: 'approve' | 'reject'): Promise<void> {
|
||||
await apiClient.patch(`admin/reviews/${id}`, { action })
|
||||
}
|
||||
|
||||
@@ -8,40 +8,28 @@ export type AdminUsersListResponse = {
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export async function fetchAdminUsers(
|
||||
token: string,
|
||||
params?: { q?: string; page?: number; pageSize?: number },
|
||||
): Promise<AdminUsersListResponse> {
|
||||
const { data } = await apiClient.get<AdminUsersListResponse>('admin/users', {
|
||||
params,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function fetchAdminUsers(params?: {
|
||||
q?: string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}): Promise<AdminUsersListResponse> {
|
||||
const { data } = await apiClient.get<AdminUsersListResponse>('admin/users', { params })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function createAdminUser(
|
||||
token: string,
|
||||
body: { email: string; name?: string | null; password?: string },
|
||||
): Promise<AdminUser> {
|
||||
const { data } = await apiClient.post<AdminUser>('admin/users', body, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function createAdminUser(body: { email: string; name?: string | null }): Promise<AdminUser> {
|
||||
const { data } = await apiClient.post<AdminUser>('admin/users', body)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateAdminUser(
|
||||
token: string,
|
||||
id: string,
|
||||
body: Partial<{ email: string; name: string | null; password: string }>,
|
||||
body: Partial<{ email: string; name: string | null }>,
|
||||
): Promise<AdminUser> {
|
||||
const { data } = await apiClient.patch<AdminUser>(`admin/users/${id}`, body, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
const { data } = await apiClient.patch<AdminUser>(`admin/users/${id}`, body)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deleteAdminUser(token: string, id: string): Promise<void> {
|
||||
await apiClient.delete(`admin/users/${id}`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
export async function deleteAdminUser(id: string): Promise<void> {
|
||||
await apiClient.delete(`admin/users/${id}`)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ export type AdminUser = {
|
||||
id: string
|
||||
email: string
|
||||
name: string | null
|
||||
hasPassword: boolean
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user