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

feat: Configured extra check for waitlisted users already in the list and created toast message for them #492

28 changes: 26 additions & 2 deletions apps/web/src/components/hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const emailSchema = z.string().email()

function Hero(): React.JSX.Element {
const [email, setEmail] = useState<string>('')
//@typescript-eslint/no-unused-vars
const [_waitListData, setWaitListData] = useState<string[]>([])

const onSubmit = (e: React.FormEvent): void => {
e.preventDefault()
Expand All @@ -27,6 +29,22 @@ function Hero(): React.JSX.Element {
return
}

const dataInStorage: string | null = localStorage.getItem('waitListData')
const waitListedEmails: string[] = dataInStorage ? (JSON.parse(dataInStorage) as string[]) : []
poswalsameer marked this conversation as resolved.
Show resolved Hide resolved

// actual logic where we are checking if this email is already in waitlisted users or not
if (waitListedEmails.includes(email)) {
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]">
kriptonian1 marked this conversation as resolved.
Show resolved Hide resolved
<p className="text-sm">
You have been already added to the waitlist. We will notify you once
we launch.{' '}
poswalsameer marked this conversation as resolved.
Show resolved Hide resolved
</p>
</div>
))
return
}

const url =
'https://xyz.us18.list-manage.com/subscribe/post?u=2e44b940cafe6e54d8b9e0790&amp;id=bd382dd7c5&amp;f_id=00e5c2e1f0'

Expand All @@ -44,8 +62,14 @@ function Hero(): React.JSX.Element {
launch
</p>
</div>
))
setEmail('');
))

setWaitListData((prevData) => {
const updatedData: string[] = [...prevData, email]
localStorage.setItem('waitListData', JSON.stringify(updatedData))
return updatedData
})
kriptonian1 marked this conversation as resolved.
Show resolved Hide resolved
setEmail('')

} catch (error) {
// eslint-disable-next-line no-console -- chill
Expand Down