feat(MED-100): update cart checkout flow and views

This commit is contained in:
2025-07-17 10:16:52 +03:00
parent ea3fb22f1d
commit 6426e2a79b
33 changed files with 1505 additions and 138 deletions

View File

@@ -154,6 +154,8 @@ export async function addToCart({
revalidateTag(fulfillmentCacheTag);
})
.catch(medusaError);
return cart;
}
export async function updateLineItem({
@@ -394,7 +396,7 @@ export async function placeOrder(cartId?: string) {
const id = cartId || (await getCartId());
if (!id) {
throw new Error("No existing cart found when placing an order");
return;
}
const headers = {
@@ -411,17 +413,14 @@ export async function placeOrder(cartId?: string) {
.catch(medusaError);
if (cartRes?.type === "order") {
const countryCode =
cartRes.order.shipping_address?.country_code?.toLowerCase();
const orderCacheTag = await getCacheTag("orders");
revalidateTag(orderCacheTag);
removeCartId();
redirect(`/${countryCode}/order/${cartRes?.order.id}/confirmed`);
redirect(`/home/order/${cartRes?.order.id}/confirmed`);
} else {
throw new Error("Cart is not an order");
}
return cartRes.cart;
}
/**

View File

@@ -14,7 +14,7 @@ export const listProducts = async ({
regionId,
}: {
pageParam?: number
queryParams?: HttpTypes.FindParams & HttpTypes.StoreProductParams
queryParams?: HttpTypes.FindParams & HttpTypes.StoreProductParams & { collection_id?: string }
countryCode?: string
regionId?: string
}): Promise<{

View File

@@ -57,7 +57,7 @@ export const getRegion = async (countryCode: string) => {
const region = countryCode
? regionMap.get(countryCode)
: regionMap.get("us")
: regionMap.get("et")
return region
} catch (e: any) {