mirror of
https://github.com/vercel/commerce.git
synced 2025-05-11 04:07:50 +00:00
fix types
This commit is contained in:
parent
33a24a08af
commit
04a2c2b29e
@ -1,11 +1,8 @@
|
||||
import OpengraphImage from 'components/opengraph-image';
|
||||
import { getPage } from 'lib/shopify';
|
||||
|
||||
export const runtime = 'edge';
|
||||
|
||||
export default async function Image({ params }: { params: { page: string } }) {
|
||||
const page = await getPage(params.page);
|
||||
const title = page.seo?.title || page.title;
|
||||
|
||||
export default async function Image({}: { params: { page: string } }) {
|
||||
const title = process.env.SITE_NAME || 'Payload Store';
|
||||
return await OpengraphImage({ title });
|
||||
}
|
||||
|
@ -3,6 +3,5 @@ import OpengraphImage from 'components/opengraph-image';
|
||||
export const runtime = 'edge';
|
||||
|
||||
export default async function Image() {
|
||||
const title = process.env.SITE_NAME || 'Payload Store';
|
||||
return await OpengraphImage({ title });
|
||||
return await OpengraphImage();
|
||||
}
|
||||
|
@ -164,8 +164,8 @@ const reshapeImage = (media: PayloadMedia): Image => {
|
||||
return {
|
||||
url: media.url!,
|
||||
altText: media.alt,
|
||||
width: media.width,
|
||||
height: media.height
|
||||
width: media.width ?? 0,
|
||||
height: media.height ?? 0
|
||||
};
|
||||
};
|
||||
|
||||
@ -247,9 +247,7 @@ const reshapeProduct = (product: PayloadProduct): Product => {
|
||||
|
||||
export async function getCollectionProducts({
|
||||
collection,
|
||||
tag,
|
||||
reverse,
|
||||
sortKey
|
||||
tag
|
||||
}: {
|
||||
collection?: string;
|
||||
tag?: string;
|
||||
@ -327,6 +325,7 @@ export async function getMenu(handle: string): Promise<Menu[]> {
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
export async function getPage(handle: string): Promise<Page | undefined> {
|
||||
return undefined;
|
||||
}
|
||||
@ -340,14 +339,13 @@ export async function getProduct(handle: string): Promise<Product | undefined> {
|
||||
return reshapeProduct(product);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
export async function getProductRecommendations(productId: string): Promise<Product[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
export async function getProducts({
|
||||
query,
|
||||
reverse,
|
||||
sortKey
|
||||
query
|
||||
}: {
|
||||
query?: string;
|
||||
reverse?: boolean;
|
||||
|
@ -223,7 +223,3 @@ export interface PayloadMigration {
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
declare module 'payload' {
|
||||
export interface GeneratedTypes extends Config {}
|
||||
}
|
||||
|
@ -24,10 +24,11 @@ const OPERATORS = [
|
||||
|
||||
type Operator = (typeof OPERATORS)[number];
|
||||
type WhereField = {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
[key in Operator]?: unknown;
|
||||
};
|
||||
export type Where = {
|
||||
[key: string]: Where[] | WhereField;
|
||||
[key: string]: Where[] | WhereField | undefined;
|
||||
and?: Where[];
|
||||
or?: Where[];
|
||||
};
|
||||
@ -58,24 +59,24 @@ type FindParams = {
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
export const find = <T>(collection: string, params: FindParams) => {
|
||||
export const find = <T>(collection: Collection, params: FindParams) => {
|
||||
const query = qs.stringify(params, { addQueryPrefix: true });
|
||||
|
||||
const url = `${process.env.CMS_URL}/api/${collection}${query}`;
|
||||
return ajax<PaginatedDocs<T>>('GET', url);
|
||||
};
|
||||
|
||||
export const findByID = <T>(collection: string, id: string) => {
|
||||
export const findByID = <T>(collection: Collection, id: string) => {
|
||||
const url = `${process.env.CMS_URL}/api/${collection}/${id}`;
|
||||
return ajax<T>('GET', url);
|
||||
};
|
||||
|
||||
export const create = <T extends object>(collection: string, body: Partial<T>) => {
|
||||
export const create = <T extends object>(collection: Collection, body: Partial<T>) => {
|
||||
const url = `${process.env.CMS_URL}/api/${collection}`;
|
||||
return ajax<Doc<T>>('POST', url, body);
|
||||
};
|
||||
|
||||
export const update = <T extends object>(collection: string, id: string, body: Partial<T>) => {
|
||||
export const update = <T extends object>(collection: Collection, id: string, body: Partial<T>) => {
|
||||
const url = `${process.env.CMS_URL}/api/${collection}/${id}`;
|
||||
return ajax<Doc<T>>('PATCH', url, body);
|
||||
};
|
||||
|
@ -36,8 +36,8 @@ export type Collection = ShopifyCollection & {
|
||||
export type Image = {
|
||||
url: string;
|
||||
altText: string;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
export type Menu = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user