@@ -4,8 +4,11 @@ import { CartSkeleton } from "../product-cart-skeleton";
44import Stepper from "../stepper" ;
55import { useCartDetail } from "@/components/hooks/use-cart-detail" ;
66import { useAppSelector } from "@/store/hooks" ;
7- import { CountryArrayDataType } from "@/lib/bagisto/types" ;
7+ import { BagistoCart , CountryArrayDataType } from "@/lib/bagisto/types" ;
88import CheckoutSkeleton from "../place-holder" ;
9+ import { useEffect } from "react" ;
10+ import { isObject } from "@/lib/type-guards" ;
11+ import { useRouter } from "next/navigation" ;
912interface CheckOutProps {
1013 countries : CountryArrayDataType [ ] ;
1114 step : string ;
@@ -15,22 +18,7 @@ const CheckOut = ({ countries, step }: CheckOutProps) => {
1518 const { isLoading } = useCartDetail ( ) ;
1619 const cartDetail = useAppSelector ( ( state ) => state . cartDetail ) ;
1720
18- if ( isLoading ) {
19- return (
20- < section className = "flex flex-col-reverse items-start justify-between lg:flex-row lg:justify-between" >
21- < div className = "w-full px-0 py-2 sm:px-4 sm:py-4 lg:w-1/2 xl:px-16" >
22- < CheckoutSkeleton />
23- </ div >
24-
25- < div className = "h-full w-full justify-self-start border-0 border-l border-none border-black/[10%] dark:border-neutral-700 lg:w-1/2 lg:border-solid" >
26- < CartSkeleton className = "w-full" />
27- </ div >
28- </ section >
29- ) ;
30- }
31-
3221 const cartItems = cartDetail ?. cart ;
33-
3422 const billingAddress = cartItems ?. billingAddress ;
3523 const shippingAddress = cartItems ?. shippingAddress ;
3624 const userEmail = cartItems ?. customerEmail ;
@@ -43,22 +31,30 @@ const CheckOut = ({ countries, step }: CheckOutProps) => {
4331 < >
4432 < section className = "flex flex-col-reverse items-start justify-between lg:flex-row lg:justify-between" >
4533 < div className = "w-full px-0 py-2 sm:px-4 sm:py-4 lg:w-1/2 xl:px-16" >
46- < Stepper
47- billingAddress = { billingAddress }
48- countries = { countries }
49- currentStep = { step }
50- isGuest = { isGuest }
51- selectedPayment = { selectedPayment }
52- selectedShippingRate = { selectedShippingRate }
53- shippingAddress = { shippingAddress }
54- userEmail = { userEmail }
55- />
34+ { isLoading ? (
35+ < CheckoutSkeleton />
36+ ) : (
37+ < Stepper
38+ billingAddress = { billingAddress }
39+ countries = { countries }
40+ currentStep = { step }
41+ isGuest = { isGuest }
42+ selectedPayment = { selectedPayment }
43+ selectedShippingRate = { selectedShippingRate }
44+ shippingAddress = { shippingAddress }
45+ userEmail = { userEmail }
46+ />
47+ ) }
5648 </ div >
5749
5850 < div className = "h-full w-full justify-self-start border-0 border-l border-none border-black/[10%] dark:border-neutral-700 lg:w-1/2 lg:border-solid" >
59- < div className = "max-h-auto w-full flex-initial flex-shrink-0 flex-grow-0 lg:sticky lg:top-0" >
60- < Cart cart = { cartItems } />
61- </ div >
51+ { isLoading ? (
52+ < CartSkeleton className = "w-full" />
53+ ) : (
54+ < div className = "max-h-auto w-full flex-initial flex-shrink-0 flex-grow-0 lg:sticky lg:top-0" >
55+ < Cart cart = { cartItems as BagistoCart } />
56+ </ div >
57+ ) }
6258 </ div >
6359 </ section >
6460 </ >
0 commit comments