mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 19:51:23 +00:00
✨ feat: setCustomerForOrder
:%s
This commit is contained in:
@@ -2,6 +2,8 @@ import Link from 'next/link'
|
||||
import React, { useRef } from 'react'
|
||||
import { ButtonCommon, Inputcommon } from 'src/components/common'
|
||||
import InputCommon from 'src/components/common/InputCommon/InputCommon'
|
||||
import { useMessage } from 'src/components/contexts'
|
||||
import { useSetCustomerForOrder } from 'src/components/hooks/order'
|
||||
import { ROUTE } from 'src/utils/constanst.utils'
|
||||
import { CheckOutForm } from 'src/utils/types.utils'
|
||||
import s from './CustomerInfoForm.module.scss'
|
||||
@@ -13,13 +15,26 @@ interface CustomerInfoFormProps {
|
||||
const CustomerInfoForm = ({ id, onConfirm }: CustomerInfoFormProps) => {
|
||||
const nameRef = useRef<React.ElementRef<typeof InputCommon>>(null)
|
||||
const emailRef = useRef<React.ElementRef<typeof InputCommon>>(null)
|
||||
const { setCustomerForOrder, loading } = useSetCustomerForOrder()
|
||||
const { showMessageError } = useMessage()
|
||||
|
||||
const handleConfirmClick = () => {
|
||||
onConfirm &&
|
||||
onConfirm(id, {
|
||||
name: nameRef?.current?.getValue().toString(),
|
||||
email: emailRef.current?.getValue().toString(),
|
||||
})
|
||||
setCustomerForOrder({ firstName: 'Ly', lastName: 'Tran', emailAddress: 'test7@gmail.com' }, onSubmitCalBack)
|
||||
// onConfirm &&
|
||||
// onConfirm(id, {
|
||||
// name: nameRef?.current?.getValue().toString(),
|
||||
// email: emailRef.current?.getValue().toString(),
|
||||
// })
|
||||
}
|
||||
const onSubmitCalBack = (isSuccess: boolean, msg?: string) => {
|
||||
// TODO:
|
||||
if (isSuccess) {
|
||||
|
||||
} else {
|
||||
console.log("error here")
|
||||
showMessageError(msg)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
|
@@ -1,5 +1,7 @@
|
||||
import classNames from 'classnames'
|
||||
import React, { useState } from 'react'
|
||||
import { MessageCommon } from 'src/components/common'
|
||||
import { useMessage } from 'src/components/contexts'
|
||||
import IconHide from 'src/components/icons/IconHide'
|
||||
import { CHECKOUT_BILL_DATA } from 'src/utils/demo-data'
|
||||
import { CheckoutBill, CheckoutInfo } from '..'
|
||||
@@ -8,7 +10,9 @@ interface CheckoutPageProps {
|
||||
}
|
||||
|
||||
const CheckoutPage = ({}: CheckoutPageProps) => {
|
||||
const { messages, removeMessage } = useMessage()
|
||||
const [isShow, setIsShow] = useState(false)
|
||||
|
||||
const onClose = () => {
|
||||
setIsShow(false)
|
||||
}
|
||||
@@ -17,6 +21,7 @@ const CheckoutPage = ({}: CheckoutPageProps) => {
|
||||
}
|
||||
return (
|
||||
<div className={s.warrper}>
|
||||
<MessageCommon messages={messages} onRemove={removeMessage} />
|
||||
<div className={s.left}><CheckoutInfo onViewCart = {onViewCart}/></div>
|
||||
<div className={s.right}><CheckoutBill data={CHECKOUT_BILL_DATA}/></div>
|
||||
<div className={classNames({ [s.mobile] :true,[s.isShow]: isShow})}>
|
||||
|
Reference in New Issue
Block a user