From 7ac29763272f56a002ebb6d46ef8c766b3296fb7 Mon Sep 17 00:00:00 2001 From: saim hashmi Date: Sun, 8 Dec 2024 00:06:51 -0500 Subject: [PATCH 1/6] feat(contact): created contact page skeleton --- libs/website/feature/contactpage/contact.tsx | 234 ++++++++++++++++++ .../contactpage/contactFormValidation.ts | 49 ++++ libs/website/pages/home.tsx | 3 + .../navbar/constants/navbar.constants.ts | 1 + 4 files changed, 287 insertions(+) create mode 100644 libs/website/feature/contactpage/contact.tsx create mode 100644 libs/website/feature/contactpage/contactFormValidation.ts diff --git a/libs/website/feature/contactpage/contact.tsx b/libs/website/feature/contactpage/contact.tsx new file mode 100644 index 000000000..74e22b342 --- /dev/null +++ b/libs/website/feature/contactpage/contact.tsx @@ -0,0 +1,234 @@ +import type { FormData, FormErrors } from './contactFormValidation' +import cuHackingLogo from '@cuhacking/shared/assets/logos/cuHacking/cuhacking-logo-1.svg' +import { GlassmorphicCard } from '@cuhacking/shared/ui/src/cuHacking/components/glassmorphic-card' +import { TerminalText } from '@cuhacking/shared/ui/src/cuHacking/components/terminal-text' +import React, { useState } from 'react' +import { validateForm } from './contactFormValidation' + +export default function ContactPage() { + const [formData, setFormData] = useState({ + name: '', + email: '', + subject: '', + message: '', + }) + + const [errors, setErrors] = useState({}) + const [isLoading, setIsLoading] = useState(false) + const [submitStatus, setSubmitStatus] = useState<'idle' | 'success' | 'error'>('idle') + + const handleChange = (e: React.ChangeEvent) => { + const { name, value } = e.target + setFormData(prev => ({ + ...prev, + [name]: value, + })) + if (errors[name as keyof FormErrors]) { + setErrors(prev => ({ + ...prev, + [name]: undefined, + })) + } + } + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault() + setIsLoading(true) + setSubmitStatus('idle') + + const validationErrors = validateForm(formData) + if (Object.keys(validationErrors).length > 0) { + setErrors(validationErrors) + setIsLoading(false) + return + } + + try { + await new Promise(resolve => setTimeout(resolve, 1500)) + setSubmitStatus('success') + setFormData({ + name: '', + email: '', + subject: '', + message: '', + }) + } + catch { + setSubmitStatus('error') + } + finally { + setIsLoading(false) + } + } + + return ( +
+
+ {/* GlassmorphicCard Wrapper */} + +
+

+ Contact Us +

+ +

+ Feel free to ask us anything! We're here to help. +

+
+
+ +
+ {/* Contact Form in a Separate Glass Card */} + +
+ {/* Status Messages */} + {submitStatus === 'success' && ( +
+ Message sent successfully! +
+ )} + {submitStatus === 'error' && ( +
+ Failed to send message. Please try again. +
+ )} + +
+ {/* Name Field */} +
+ + {errors.name && ( + {errors.name} + )} +
+ + {/* Email Field */} +
+ + {errors.email && ( + {errors.email} + )} +
+
+ + {/* Subject Field */} +
+ + {errors.subject && ( + + {errors.subject} + + )} +
+ + {/* Message Field */} +
+