mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 04:01:23 +00:00
🔨 refactor: collapse checkout
:%s
This commit is contained in:
@@ -2,29 +2,30 @@ 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 { CheckOutForm } from 'src/utils/types.utils'
|
||||
import s from './CustomerInfoForm.module.scss'
|
||||
interface CustomerInfoFormProps {
|
||||
onConfirm?: ()=>void
|
||||
onConfirm?: (id: number, formInfo: CheckOutForm) => void
|
||||
id: number
|
||||
}
|
||||
|
||||
const CustomerInfoForm = ({}: CustomerInfoFormProps) => {
|
||||
const nameRef = useRef<React.ElementRef<typeof InputCommon>>(null);
|
||||
const emailRef = useRef<React.ElementRef<typeof InputCommon>>(null);
|
||||
const CustomerInfoForm = ({ id, onConfirm }: CustomerInfoFormProps) => {
|
||||
const nameRef = useRef<React.ElementRef<typeof InputCommon>>(null)
|
||||
const emailRef = useRef<React.ElementRef<typeof InputCommon>>(null)
|
||||
|
||||
|
||||
|
||||
const handleConfirmClick = () => {
|
||||
return {
|
||||
name:nameRef?.current?.getValue(),
|
||||
email:emailRef.current?.getValue()
|
||||
}
|
||||
}
|
||||
const handleConfirmClick = () => {
|
||||
onConfirm &&
|
||||
onConfirm(id, {
|
||||
name: nameRef?.current?.getValue().toString(),
|
||||
email: emailRef.current?.getValue().toString(),
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={s.warpper}>
|
||||
<div className={s.body}>
|
||||
<Inputcommon type="text" placeholder="Full Name" ref={nameRef}/>
|
||||
<Inputcommon type="text" placeholder="Email Address" ref={emailRef}/>
|
||||
<Inputcommon type="text" placeholder="Full Name" ref={nameRef} />
|
||||
<Inputcommon type="text" placeholder="Email Address" ref={emailRef} />
|
||||
</div>
|
||||
<div className={s.bottom}>
|
||||
<div className={s.note}>
|
||||
@@ -42,7 +43,9 @@ const CustomerInfoForm = ({}: CustomerInfoFormProps) => {
|
||||
}
|
||||
.
|
||||
</div>
|
||||
<ButtonCommon onClick={handleConfirmClick}>Continue to Shipping</ButtonCommon>
|
||||
<ButtonCommon onClick={handleConfirmClick}>
|
||||
Continue to Shipping
|
||||
</ButtonCommon>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
Reference in New Issue
Block a user