Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Email validation #487

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading