Skip to content

Commit

Permalink
chore(web): email validation (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
bansal-harsh-2504 authored Oct 14, 2024
1 parent f4af874 commit e8e737a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 305 deletions.
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"react-dom": "^18.2.0",
"sharp": "^0.33.3",
"sonner": "^1.4.41",
"tailwind-merge": "^2.2.1"
"tailwind-merge": "^2.2.1",
"zod": "^3.23.8"
},
"devDependencies": {
"@next/eslint-plugin-next": "^13.4.19",
Expand Down
9 changes: 7 additions & 2 deletions apps/web/src/components/hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ import Image from 'next/image'
import { useState } from 'react'
import { Toaster, toast } from 'sonner'
import { ColorBGSVG, HeroImage } from '@public/hero'
import { z } from 'zod'
import EncryptButton from '../ui/encrypt-btn'
import { InputBorderSpotlight } from '../ui/input-spotlight'

const emailSchema = z.string().email()

function Hero(): React.JSX.Element {
const [email, setEmail] = useState<string>('')

const onSubmit = (e: React.FormEvent): void => {
e.preventDefault()

if (email === '') {
const result = emailSchema.safeParse(email)

if (!result.success) {
toast.custom(() => (
<div className="text-brandBlue border-brandBlue/20 w-[90vw] rounded-lg border bg-[#852b2c] p-2 shadow-2xl backdrop-blur-3xl md:w-[20vw]">
<p className="text-sm">Please enter an email address </p>
<p className="text-sm">Please enter a valid email address </p>
</div>
))
return
Expand Down
Loading

0 comments on commit e8e737a

Please sign in to comment.