mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 22:16:58 +00:00
fix: some TS issues
This commit is contained in:
parent
e453e401fb
commit
f4a71fa67d
@ -97,6 +97,7 @@ const reshapeCart = (cart: MedusaCart): Cart => {
|
||||
|
||||
const reshapeLineItem = (lineItem: MedusaLineItem): CartItem => {
|
||||
const product = {
|
||||
title: lineItem.title,
|
||||
priceRange: {
|
||||
maxVariantPrice: {
|
||||
amount: lineItem.variant?.prices?.[0]?.amount.toString() ?? '0',
|
||||
@ -318,7 +319,7 @@ export async function getCollections(): Promise<ProductCollection[]> {
|
||||
return collections;
|
||||
}
|
||||
|
||||
export async function getProduct(handle: string): Promise<Product | undefined> {
|
||||
export async function getProduct(handle: string): Promise<Product> {
|
||||
const res = await medusaRequest('GET', `/products?handle=${handle}&limit=1`);
|
||||
const product = res.body.products[0];
|
||||
return reshapeProduct(product);
|
||||
|
@ -53,6 +53,7 @@ export type MedusaProduct = {
|
||||
};
|
||||
|
||||
export type Product = Partial<Omit<MedusaProduct, 'tags' | 'options' | 'variants'>> & {
|
||||
title: string;
|
||||
featuredImage: FeaturedImage;
|
||||
seo?: {
|
||||
title?: string;
|
||||
@ -66,7 +67,7 @@ export type Product = Partial<Omit<MedusaProduct, 'tags' | 'options' | 'variants
|
||||
tags: Array<string>;
|
||||
availableForSale: boolean;
|
||||
options?: Array<ProductOption>;
|
||||
variants: Array<ProductVariant | undefined>;
|
||||
variants: Array<ProductVariant>;
|
||||
};
|
||||
|
||||
export type FeaturedImage = {
|
||||
@ -380,7 +381,7 @@ export type MedusaLineItem = {
|
||||
has_shipping?: boolean | null;
|
||||
unit_price: number;
|
||||
variant_id?: string | null;
|
||||
variant?: MedusaProductVariant;
|
||||
variant: MedusaProductVariant;
|
||||
quantity: number;
|
||||
fulfilled_quantity?: number | null;
|
||||
returned_quantity?: number | null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user