feat: enhance SuccessModal and News context for improved modal management and subscription flow
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
// import { EyeIcon, EyeOffIcon } from 'lucide-react'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { type Dispatch, type SetStateAction } from 'react'
|
||||
import { FormProvider, useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { Button } from '~/components/ui/button'
|
||||
import { Input } from '~/components/ui/input'
|
||||
import type { NewsContextProperties } from '~/contexts/news'
|
||||
|
||||
const loginSchema = z.object({
|
||||
email: z.string().email('Email tidak valid'),
|
||||
@@ -15,10 +15,10 @@ const loginSchema = z.object({
|
||||
type TLoginSchema = z.infer<typeof loginSchema>
|
||||
|
||||
type TProperties = {
|
||||
setIsRegisterOpen: Dispatch<SetStateAction<boolean>>
|
||||
setIsLoginOpen: Dispatch<SetStateAction<boolean>>
|
||||
setIsForgetOpen: Dispatch<SetStateAction<boolean>>
|
||||
setIsSuccessModalOpen: Dispatch<SetStateAction<boolean>>
|
||||
setIsRegisterOpen: NewsContextProperties['setIsRegisterOpen']
|
||||
setIsLoginOpen: NewsContextProperties['setIsLoginOpen']
|
||||
setIsForgetOpen: NewsContextProperties['setForgetOpen']
|
||||
setIsInitSubscribeOpen: NewsContextProperties['setIsInitSubscribeOpen']
|
||||
}
|
||||
|
||||
export const FormLogin = (properties: TProperties) => {
|
||||
@@ -26,7 +26,7 @@ export const FormLogin = (properties: TProperties) => {
|
||||
setIsRegisterOpen,
|
||||
setIsLoginOpen,
|
||||
setIsForgetOpen,
|
||||
setIsSuccessModalOpen,
|
||||
setIsInitSubscribeOpen,
|
||||
} = properties
|
||||
|
||||
const formMethods = useForm<TLoginSchema>({
|
||||
@@ -37,7 +37,7 @@ export const FormLogin = (properties: TProperties) => {
|
||||
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
console.log('data', data) // eslint-disable-line no-console
|
||||
setIsSuccessModalOpen(true)
|
||||
setIsInitSubscribeOpen(true)
|
||||
setIsLoginOpen(false)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user