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