feat: setCustomerForOrder

:%s
This commit is contained in:
lytrankieio123
2021-10-18 17:38:08 +07:00
parent d846574b94
commit 8a2e06a0fa
14 changed files with 384 additions and 242 deletions

View File

@@ -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 (

View File

@@ -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})}>