-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing help form within help page
- Loading branch information
Showing
2 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
'use client'; | ||
|
||
import React, { useState } from 'react'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
interface HelpFormValues { | ||
name: string; | ||
email: string; | ||
message: string; | ||
} | ||
|
||
const HelpForm: React.FC = () => { | ||
const [formValues, setFormValues] = useState<HelpFormValues>({ | ||
name: '', | ||
email: '', | ||
message: '', | ||
}); | ||
|
||
const [submitted, setSubmitted] = useState(false); | ||
const router = useRouter(); | ||
|
||
const handleChange = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => { | ||
const { name, value } = event.target; | ||
setFormValues({ | ||
...formValues, | ||
[name]: value, | ||
}); | ||
}; | ||
|
||
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
console.log('Form submitted:', formValues); | ||
setSubmitted(true); | ||
router.push('/help'); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h1>Help Form</h1> | ||
{!submitted ? ( | ||
<form onSubmit={handleSubmit}> | ||
<div> | ||
<label htmlFor="name">Name:</label> | ||
<input | ||
type="text" | ||
id="name" | ||
name="name" | ||
value={formValues.name} | ||
onChange={handleChange} | ||
required | ||
/> | ||
</div> | ||
<div> | ||
<label htmlFor="email">Email:</label> | ||
<input | ||
type="email" | ||
id="email" | ||
name="email" | ||
value={formValues.email} | ||
onChange={handleChange} | ||
required | ||
/> | ||
</div> | ||
<div> | ||
<label htmlFor="message">Message:</label> | ||
<textarea | ||
id="message" | ||
name="message" | ||
value={formValues.message} | ||
onChange={handleChange} | ||
required | ||
/> | ||
</div> | ||
<button type="submit">Submit</button> | ||
</form> | ||
) : ( | ||
<p>Thanks for reaching out! We will get back to you soon.</p> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default HelpForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters