|
@@ -1,14 +1,14 @@
|
|
|
"use client";
|
|
"use client";
|
|
|
|
|
|
|
|
-import {use, useEffect} from "react";
|
|
|
|
|
|
|
+import {use} from "react";
|
|
|
import Link from "next/link";
|
|
import Link from "next/link";
|
|
|
import Image from "next/image";
|
|
import Image from "next/image";
|
|
|
import {GraphqlRequestResult} from "@/types/graphqlFetch/type";
|
|
import {GraphqlRequestResult} from "@/types/graphqlFetch/type";
|
|
|
import { OrderDetailsData,ProductItemAdditional } from "@/types/customer/type";
|
|
import { OrderDetailsData,ProductItemAdditional } from "@/types/customer/type";
|
|
|
import { useCurrencyList } from "@utils/hooks/useCurrencyList";
|
|
import { useCurrencyList } from "@utils/hooks/useCurrencyList";
|
|
|
import Faqs from "./Faqs";
|
|
import Faqs from "./Faqs";
|
|
|
-import { useAppDispatch } from "@/store/hooks";
|
|
|
|
|
-import { clearCart, fetchCartDetail } from "@/store/slices/cart-slice";
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
function getProductAdditionalInfo(productItem: ProductItemAdditional) {
|
|
function getProductAdditionalInfo(productItem: ProductItemAdditional) {
|
|
|
const attributeKeys = Object.keys(productItem.attributes);
|
|
const attributeKeys = Object.keys(productItem.attributes);
|
|
@@ -31,19 +31,17 @@ function getProductAdditionalInfo(productItem: ProductItemAdditional) {
|
|
|
|
|
|
|
|
export default function OrderDetailWrapper({
|
|
export default function OrderDetailWrapper({
|
|
|
orderDetailPromise,
|
|
orderDetailPromise,
|
|
|
- isGuest
|
|
|
|
|
}: {
|
|
}: {
|
|
|
orderDetailPromise: Promise<GraphqlRequestResult<OrderDetailsData>>,
|
|
orderDetailPromise: Promise<GraphqlRequestResult<OrderDetailsData>>,
|
|
|
- isGuest: boolean
|
|
|
|
|
}) {
|
|
}) {
|
|
|
- const dispatch = useAppDispatch();
|
|
|
|
|
|
|
+
|
|
|
const {currencies} = useCurrencyList();
|
|
const {currencies} = useCurrencyList();
|
|
|
const promiseRes = use(orderDetailPromise);
|
|
const promiseRes = use(orderDetailPromise);
|
|
|
const orderDetailRes = promiseRes.data?.customerOrder ?? null;
|
|
const orderDetailRes = promiseRes.data?.customerOrder ?? null;
|
|
|
const shippingAddress = orderDetailRes?.addresses?.edges.find(item => item.node.addressType === "order_shipping");
|
|
const shippingAddress = orderDetailRes?.addresses?.edges.find(item => item.node.addressType === "order_shipping");
|
|
|
let orderCreatedAt = 'Can\'t get order date';
|
|
let orderCreatedAt = 'Can\'t get order date';
|
|
|
if(orderDetailRes?.createdAt) {
|
|
if(orderDetailRes?.createdAt) {
|
|
|
- let localDate = new Date(orderDetailRes.createdAt);
|
|
|
|
|
|
|
+ const localDate = new Date(orderDetailRes.createdAt);
|
|
|
orderCreatedAt = localDate.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
|
|
orderCreatedAt = localDate.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
|
|
|
}
|
|
}
|
|
|
const productItems = orderDetailRes?.items?.edges.map(item => {
|
|
const productItems = orderDetailRes?.items?.edges.map(item => {
|
|
@@ -51,13 +49,6 @@ export default function OrderDetailWrapper({
|
|
|
}) || [];
|
|
}) || [];
|
|
|
const currency = currencies?.find(item => item.code === orderDetailRes?.orderCurrencyCode) || null;
|
|
const currency = currencies?.find(item => item.code === orderDetailRes?.orderCurrencyCode) || null;
|
|
|
|
|
|
|
|
- // useEffect(() => {
|
|
|
|
|
- // // const isGuest = getCookie(IS_GUEST);
|
|
|
|
|
- // if(isGuest) {
|
|
|
|
|
- // deleteCookie(GUEST_CART_TOKEN);
|
|
|
|
|
- // deleteCookie(GUEST_CART_ID);
|
|
|
|
|
- // }
|
|
|
|
|
- // }, []);
|
|
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|