mirror of
https://github.com/vercel/commerce.git
synced 2025-07-12 15:31:25 +00:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import React, { useRef } from 'react'
|
|
import { ButtonCommon, Inputcommon } from 'src/components/common'
|
|
import { CustomInputCommon } from 'src/utils/type.utils';
|
|
import s from './FormSubscribe.module.scss'
|
|
|
|
|
|
const FormSubscribe = () => {
|
|
const inputElementRef = useRef<CustomInputCommon>(null);
|
|
|
|
const handleSubmit = (e?: any) => {
|
|
// todo
|
|
let value: string
|
|
if (typeof (e) === 'string') {
|
|
value = e
|
|
} else {
|
|
e.preventDefault && e.preventDefault()
|
|
value = inputElementRef.current?.getValue()?.toString() || ''
|
|
}
|
|
console.log("email here: ", value)
|
|
}
|
|
|
|
return (
|
|
<section className={s.formSubscribe}>
|
|
<Inputcommon
|
|
type='email'
|
|
styleType='custom'
|
|
placeholder="Enter your email"
|
|
ref={inputElementRef}
|
|
onEnter={handleSubmit}
|
|
backgroundTransparent={true}
|
|
/>
|
|
<ButtonCommon onClick={handleSubmit} type='lightBorderNone'>Subsribe</ButtonCommon>
|
|
</section>
|
|
)
|
|
}
|
|
|
|
export default FormSubscribe
|