32 lines
963 B
TypeScript
32 lines
963 B
TypeScript
import "server-only";
|
|
import { winofyFetch, type PaginatedResponse } from "./winofy";
|
|
import type { StoreCategory, StoreDetail, StoreListItem } from "@/types/api";
|
|
|
|
export async function getStoreCategories(): Promise<StoreCategory[]> {
|
|
const res = await winofyFetch<PaginatedResponse<StoreCategory>>("/v1/store-categories/", {
|
|
auth: false,
|
|
params: { limit: 100 },
|
|
});
|
|
return res.results;
|
|
}
|
|
|
|
export interface GetStoresParams {
|
|
category?: string;
|
|
search?: string;
|
|
neighborhood?: string;
|
|
lat?: number;
|
|
lng?: number;
|
|
limit?: number;
|
|
}
|
|
|
|
export async function getStores(params: GetStoresParams = {}): Promise<StoreListItem[]> {
|
|
const res = await winofyFetch<PaginatedResponse<StoreListItem>>("/v1/stores/", {
|
|
auth: false,
|
|
params: { limit: 20, ...params },
|
|
});
|
|
return res.results;
|
|
}
|
|
|
|
export async function getStore(uuid: string): Promise<StoreDetail> {
|
|
return winofyFetch<StoreDetail>(`/v1/stores/${uuid}/`, { auth: false });
|
|
}
|