mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
🎨 styles: checkout page
:%s
This commit is contained in:
@@ -4,8 +4,11 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
> main {
|
> main {
|
||||||
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
max-width: min(100%, 1536px);
|
||||||
|
margin: auto;
|
||||||
}
|
}
|
||||||
.footer {
|
.footer {
|
||||||
@apply spacing-horizontal;
|
@apply spacing-horizontal;
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
.warpper {
|
.warpper {
|
||||||
padding: 3.2rem;
|
padding: 3.2rem;
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
@screen lg {
|
@screen lg {
|
||||||
max-width: 56.3rem;
|
max-width: 56.3rem;
|
||||||
@apply flex justify-between flex-col;
|
@apply flex justify-between flex-col;
|
||||||
@@ -14,10 +15,14 @@
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.empty {
|
||||||
|
@apply flex flex-col justify-center items-center;
|
||||||
|
}
|
||||||
.list {
|
.list {
|
||||||
min-height: 52.8rem;
|
// min-height: 52.8rem;
|
||||||
}
|
}
|
||||||
.bot {
|
.bot {
|
||||||
|
margin-top: auto;
|
||||||
.price {
|
.price {
|
||||||
margin-top: 3.2rem;
|
margin-top: 3.2rem;
|
||||||
.line {
|
.line {
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
import { Cart } from '@commerce/types/cart'
|
import { Cart } from '@commerce/types/cart'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CardItemCheckout } from '../../../common'
|
import { ROUTE } from 'src/utils/constanst.utils'
|
||||||
|
import { LANGUAGE } from 'src/utils/language.utils'
|
||||||
|
import { ButtonCommon, CardItemCheckout, EmptyCommon } from '../../../common'
|
||||||
import s from './CheckoutBill.module.scss'
|
import s from './CheckoutBill.module.scss'
|
||||||
import FormPromotionCode from './FormPromotionCode/FormPromotionCode'
|
import FormPromotionCode from './FormPromotionCode/FormPromotionCode'
|
||||||
|
import Link from 'next/link'
|
||||||
|
|
||||||
interface CheckoutBillProps {
|
interface CheckoutBillProps {
|
||||||
// data: CardItemCheckoutProps[]
|
// data: CardItemCheckoutProps[]
|
||||||
@@ -14,8 +17,18 @@ const CheckoutBill = ({ data }: CheckoutBillProps) => {
|
|||||||
return (
|
return (
|
||||||
<div className={s.warpper}>
|
<div className={s.warpper}>
|
||||||
<div className={s.title}>
|
<div className={s.title}>
|
||||||
Your cart ({data?.totalQuantity})
|
Your cart ({data?.totalQuantity || 0})
|
||||||
</div>
|
</div>
|
||||||
|
{
|
||||||
|
!data?.totalQuantity && <div className={s.empty}>
|
||||||
|
<EmptyCommon description="Your cart is empty" />
|
||||||
|
<Link href={ROUTE.HOME}>
|
||||||
|
<a>
|
||||||
|
<ButtonCommon>{LANGUAGE.BUTTON_LABEL.SHOP_NOW}</ButtonCommon>
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
<div className={s.list}>
|
<div className={s.list}>
|
||||||
{data?.lineItems?.map((item) => {
|
{data?.lineItems?.map((item) => {
|
||||||
return <CardItemCheckout {...item} key={item.slug} currency={data?.currency} />
|
return <CardItemCheckout {...item} key={item.slug} currency={data?.currency} />
|
||||||
@@ -26,11 +39,15 @@ const CheckoutBill = ({ data }: CheckoutBillProps) => {
|
|||||||
<div className={s.price}>
|
<div className={s.price}>
|
||||||
<div className={s.line}>
|
<div className={s.line}>
|
||||||
Discount {(data?.discounts?.length || 0) > 0 && `(${data?.discounts?.map(item => item.description).join(",")})`}
|
Discount {(data?.discounts?.length || 0) > 0 && `(${data?.discounts?.map(item => item.description).join(",")})`}
|
||||||
<div className={s.shipping}>{data?.totalDiscount} {data?.currency?.code}</div>
|
<div className={s.shipping}>
|
||||||
|
{data?.totalDiscount ? `${data?.totalDiscount} ${data?.currency?.code}` : "0"}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={s.line}>
|
<div className={s.line}>
|
||||||
Subtotal
|
Subtotal
|
||||||
<div className={s.subTotal}>{data?.subtotalPrice} {data?.currency?.code}</div>
|
<div className={s.subTotal}>
|
||||||
|
{data?.subtotalPrice ? `${data?.subtotalPrice} ${data?.currency?.code}` : "0"}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={s.line}>
|
<div className={s.line}>
|
||||||
Shipping
|
Shipping
|
||||||
@@ -38,7 +55,7 @@ const CheckoutBill = ({ data }: CheckoutBillProps) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className={s.line}>
|
<div className={s.line}>
|
||||||
Estimated Total
|
Estimated Total
|
||||||
<div className={s.total}>{data?.totalPrice} {data?.currency?.code}</div>
|
<div className={s.total}>{data?.totalPrice ? `${data?.totalPrice} ${data?.currency?.code}` : "0"}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -116,22 +116,19 @@ const CheckoutInfo = ({ onViewCart }: CheckoutInfoProps) => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// TODO: remove
|
// TODO: remove
|
||||||
const { addProduct } = useAddProductToCart()
|
// const { addProduct } = useAddProductToCart()
|
||||||
|
|
||||||
const createOrder = () => {
|
|
||||||
addProduct({ variantId: "92", quantity: 2 }, handleAddToCartCallback)
|
|
||||||
}
|
|
||||||
const handleAddToCartCallback = (isSuccess: boolean, message?: string) => {
|
|
||||||
// console.log("after create order: ", isSuccess, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// const createOrder = () => {
|
||||||
|
// addProduct({ variantId: "92", quantity: 2 }, handleAddToCartCallback)
|
||||||
|
// }
|
||||||
|
// const handleAddToCartCallback = (isSuccess: boolean, message?: string) => {
|
||||||
|
// // console.log("after create order: ", isSuccess, message)
|
||||||
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={s.warpper}>
|
<div className={s.warpper}>
|
||||||
{/* TODO: remove */}
|
{/* TODO: remove */}
|
||||||
<ButtonCommon onClick={createOrder}>test create order</ButtonCommon>
|
{/* <ButtonCommon onClick={createOrder}>test create order</ButtonCommon> */}
|
||||||
<ButtonCommon onClick={createOrder}>test get activeStep order</ButtonCommon>
|
|
||||||
TOTAL: {order?.totalPrice}
|
|
||||||
|
|
||||||
<div className={s.title}>
|
<div className={s.title}>
|
||||||
<Logo />
|
<Logo />
|
||||||
|
@@ -54,6 +54,8 @@ const CustomerInfoForm = ({ id, onConfirm, activeStep }: Props) => {
|
|||||||
if (error?.errorCode === ErrorCode.EmailAddressConflictError) {
|
if (error?.errorCode === ErrorCode.EmailAddressConflictError) {
|
||||||
// show modal common
|
// show modal common
|
||||||
openModalConfirmLogin()
|
openModalConfirmLogin()
|
||||||
|
} else if (error?.errorCode === ErrorCode.NoActiveOrderError) {
|
||||||
|
showMessageError("Your cart is empty! Please add items to the cart!")
|
||||||
} else {
|
} else {
|
||||||
showMessageError(error?.message)
|
showMessageError(error?.message)
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
@import "../../../../styles/utilities";
|
@import "../../../../styles/utilities";
|
||||||
.warrper{
|
.warrper{
|
||||||
@apply flex w-full;
|
@apply flex w-full;
|
||||||
|
min-height: 100%;
|
||||||
.right {
|
.right {
|
||||||
display: none;
|
display: none;
|
||||||
@screen lg {
|
@screen lg {
|
||||||
|
Reference in New Issue
Block a user