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 reshapeLineItem = (lineItem: MedusaLineItem): CartItem => {
|
||||||
const product = {
|
const product = {
|
||||||
|
title: lineItem.title,
|
||||||
priceRange: {
|
priceRange: {
|
||||||
maxVariantPrice: {
|
maxVariantPrice: {
|
||||||
amount: lineItem.variant?.prices?.[0]?.amount.toString() ?? '0',
|
amount: lineItem.variant?.prices?.[0]?.amount.toString() ?? '0',
|
||||||
@ -318,7 +319,7 @@ export async function getCollections(): Promise<ProductCollection[]> {
|
|||||||
return collections;
|
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 res = await medusaRequest('GET', `/products?handle=${handle}&limit=1`);
|
||||||
const product = res.body.products[0];
|
const product = res.body.products[0];
|
||||||
return reshapeProduct(product);
|
return reshapeProduct(product);
|
||||||
|
@ -53,6 +53,7 @@ export type MedusaProduct = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type Product = Partial<Omit<MedusaProduct, 'tags' | 'options' | 'variants'>> & {
|
export type Product = Partial<Omit<MedusaProduct, 'tags' | 'options' | 'variants'>> & {
|
||||||
|
title: string;
|
||||||
featuredImage: FeaturedImage;
|
featuredImage: FeaturedImage;
|
||||||
seo?: {
|
seo?: {
|
||||||
title?: string;
|
title?: string;
|
||||||
@ -66,7 +67,7 @@ export type Product = Partial<Omit<MedusaProduct, 'tags' | 'options' | 'variants
|
|||||||
tags: Array<string>;
|
tags: Array<string>;
|
||||||
availableForSale: boolean;
|
availableForSale: boolean;
|
||||||
options?: Array<ProductOption>;
|
options?: Array<ProductOption>;
|
||||||
variants: Array<ProductVariant | undefined>;
|
variants: Array<ProductVariant>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FeaturedImage = {
|
export type FeaturedImage = {
|
||||||
@ -380,7 +381,7 @@ export type MedusaLineItem = {
|
|||||||
has_shipping?: boolean | null;
|
has_shipping?: boolean | null;
|
||||||
unit_price: number;
|
unit_price: number;
|
||||||
variant_id?: string | null;
|
variant_id?: string | null;
|
||||||
variant?: MedusaProductVariant;
|
variant: MedusaProductVariant;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
fulfilled_quantity?: number | null;
|
fulfilled_quantity?: number | null;
|
||||||
returned_quantity?: number | null;
|
returned_quantity?: number | null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user