fix update Section Block
This commit is contained in:
1 parent
996dfdabd0
commit
6f67ee6077
47 files changed
+1792
-197
No files matched your search
@@ -61,19 +61,19 @@ export async function fetchJsonResult<T>(path: string, init?: RequestInit & { ne
|
||||
}
|
||||
}
|
||||
|
||||
export async function getCategories(lang = 'th'): Promise<Category[]> {
|
||||
export async function getCategories(lang = 'all'): Promise<Category[]> {
|
||||
return await fetchJson<Category[]>(`/categories?lang=${lang}`, { next: { revalidate: 3600 } }) ?? []
|
||||
}
|
||||
|
||||
export async function getCategoriesResult(lang = 'th'): Promise<ApiResult<Category[]>> {
|
||||
export async function getCategoriesResult(lang = 'all'): Promise<ApiResult<Category[]>> {
|
||||
return await fetchJsonResult<Category[]>(`/categories?lang=${lang}`, { next: { revalidate: 3600 } })
|
||||
}
|
||||
|
||||
export async function getCmsPage(slug: string, lang = 'th'): Promise<Page | null> {
|
||||
export async function getCmsPage(slug: string, lang = 'all'): Promise<Page | null> {
|
||||
return await fetchJson<Page>(`/pages/${slug}?lang=${lang}`, { next: { revalidate: defaultRevalidate } })
|
||||
}
|
||||
|
||||
export async function getCmsPageResult(slug: string, lang = 'th'): Promise<ApiResult<Page>> {
|
||||
export async function getCmsPageResult(slug: string, lang = 'all'): Promise<ApiResult<Page>> {
|
||||
return await fetchJsonResult<Page>(`/pages/${slug}?lang=${lang}`, { next: { revalidate: defaultRevalidate } })
|
||||
}
|
||||
|
||||
@@ -95,15 +95,15 @@ export async function getOrderResult(id: string | number): Promise<ApiResult<Ord
|
||||
return await fetchJsonResult<Order>(`/orders/${id}`, { next: { revalidate: defaultRevalidate } })
|
||||
}
|
||||
|
||||
export async function getProduct(id: string | number, lang = 'th'): Promise<Product | null> {
|
||||
export async function getProduct(id: string | number, lang = 'all'): Promise<Product | null> {
|
||||
return await fetchJson<Product>(`/products/${id}?lang=${lang}`, { next: { revalidate: defaultRevalidate } })
|
||||
}
|
||||
|
||||
export async function getProductResult(id: string | number, lang = 'th'): Promise<ApiResult<Product>> {
|
||||
export async function getProductResult(id: string | number, lang = 'all'): Promise<ApiResult<Product>> {
|
||||
return await fetchJsonResult<Product>(`/products/${id}?lang=${lang}`, { next: { revalidate: defaultRevalidate } })
|
||||
}
|
||||
|
||||
export async function getProducts(query = '', lang = 'th'): Promise<Product[]> {
|
||||
export async function getProducts(query = '', lang = 'all'): Promise<Product[]> {
|
||||
const separator = query ? '&' : ''
|
||||
const response = await fetchJson<ProductListResponse>(`/products?${query}${separator}lang=${lang}`, {
|
||||
next: { revalidate: defaultRevalidate },
|
||||
@@ -112,7 +112,7 @@ export async function getProducts(query = '', lang = 'th'): Promise<Product[]> {
|
||||
return response?.data ?? []
|
||||
}
|
||||
|
||||
export async function getProductsResult(query = '', lang = 'th'): Promise<ApiResult<Product[]>> {
|
||||
export async function getProductsResult(query = '', lang = 'all'): Promise<ApiResult<Product[]>> {
|
||||
const separator = query ? '&' : ''
|
||||
const response = await fetchJsonResult<ProductListResponse>(`/products?${query}${separator}lang=${lang}`, {
|
||||
next: { revalidate: defaultRevalidate },
|
||||
|
||||
Reference in new issue
Block a user