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

Contact page notification #494

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
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: 3 additions & 0 deletions src/components/GoToTop/GoToTop.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@
right: 15vw;
bottom: 4px;
}
<<<<<<< HEAD
=======

>>>>>>> af8dd9d11e4d459ff9d66de24f659e31373f46c3
}
29 changes: 29 additions & 0 deletions src/components/faq/FAQ.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@

.container {
margin: 20px;
<<<<<<< HEAD
padding: 20px;
=======

padding: 10px 20px;

padding: 20px;

>>>>>>> af8dd9d11e4d459ff9d66de24f659e31373f46c3
display: inline;
}

.heading {
<<<<<<< HEAD
margin: 20px;
=======

margin: 10px;}

Expand All @@ -26,26 +33,42 @@

margin: 20px;

>>>>>>> af8dd9d11e4d459ff9d66de24f659e31373f46c3
text-align: center;
}

.faq-item {
<<<<<<< HEAD
margin-left: 30px;
margin-right: 30px;
margin-bottom: 10px;
=======
margin-bottom: 10px;
width: 100%;
max-width: 800px;
>>>>>>> af8dd9d11e4d459ff9d66de24f659e31373f46c3
}

.faq-question {
background-color: #78ecb4;
<<<<<<< HEAD
=======
color : rgb(3, 66, 3);
>>>>>>> af8dd9d11e4d459ff9d66de24f659e31373f46c3
font-weight: 600;
border: none;
border-radius: 5px;
outline: none;
<<<<<<< HEAD
padding: 10px;
width: 100%;
text-align: left;
=======
padding: 15px;
width: 100%;
text-align: left;
font-size: 1.05em;
>>>>>>> af8dd9d11e4d459ff9d66de24f659e31373f46c3
cursor: pointer;
display: flex;
justify-content: space-between;
Expand All @@ -57,6 +80,11 @@ svg {
}

.faq-question:hover {
<<<<<<< HEAD
background-color: #40b47c;
color: white;
}
=======
background-color:rgb(3, 66, 3);
color: white;
}
Expand All @@ -70,3 +98,4 @@ svg {
max-width: 800px;
font-size: 1em;
}
>>>>>>> af8dd9d11e4d459ff9d66de24f659e31373f46c3
177 changes: 72 additions & 105 deletions src/pages/Contactus/Contactus.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Button, TextareaAutosize, TextField, Typography } from '@mui/material';
import React, { useRef, useState } from 'react';
import { Slide, toast, ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import './contactus.css';
import emailjs from '@emailjs/browser';
import { Button, Snackbar, TextareaAutosize, Typography } from '@mui/material';
import TextField from '@mui/material/TextField';

export default function Contactus() {
let form = useRef();
const form = useRef();
const [formFields, setFormFields] = useState({
user_email: '',
user_name: '',
Expand All @@ -16,74 +16,77 @@ export default function Contactus() {
user_name: '',
message: ''
});
const serviceId = '';
const templateId = '';
const publicKey = '';

const validateEmail = (email) => {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
};

const onChangeField = (e) => {
const name = e.target.name;
const value = e.target.value;

let errors = { ...inputErrors };

// Validate email
if (name === 'user_email') {
errors.user_email = !validateEmail(value) ? 'Invalid email address' : '';
}

if (name == 'user_name' && value.length > 0) {
if (name === 'user_name' && value.length > 0) {
errors.user_name = '';
}
if (name == 'message' && value.length > 0) {
if (name === 'message' && value.length > 0) {
errors.message = '';
}

setInputErrors(errors);
setFormFields((prevFormFields) => ({
...prevFormFields,
[name]: value
}));
};
const handleClick = (e) => {
e.preventDefault();

const handleSubmit = (event) => {
event.preventDefault();

let errors = { ...inputErrors };

if (formFields.user_name.length == 0) {
if (formFields.user_name.length === 0) {
errors.user_name = 'Please Enter Name';
setInputErrors(errors);
return;
} else if (formFields.message.length == 0) {
errors.message = 'please Enter message';
setInputErrors(errors);
return;
} else if (formFields.user_email.length == 0) {
errors.user_email = 'please Enter Email';
setInputErrors(errors);
return;
}
if (
inputErrors.user_email ||
inputErrors.message ||
inputErrors.user_name
) {
if (formFields.message.length === 0) {
errors.message = 'Please Enter Message';
}
if (formFields.user_email.length === 0) {
errors.user_email = 'Please Enter Email';
}

setInputErrors(errors);

if (errors.user_email || errors.message || errors.user_name) {
return;
}
console.log(formFields);
emailjs
.sendForm(serviceId, templateId, form.current, {
publicKey: publicKey
})
.then(
() => {
console.log('SUCCESS!');
},
(error) => {
console.log('FAILED...', error);
}
);

setFormFields({
user_email: '',
user_name: '',
message: ''
});

toast.success('Sent Successfully!', {
position: 'top-center',
autoClose: 5000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: false,
draggable: true,
progress: undefined,
theme: 'light',
transition: Slide,
closeButton: true,
style: { fontSize: '16px' }
});
};

return (
<div className="contact-section-light">
<div className="contact-parent">
Expand All @@ -93,116 +96,80 @@ export default function Contactus() {
Get In Touch
</h1>
<div className="inside-contact">
<form ref={form} className='contact-form'>
{/* <div className="contact-input contact-input-light">
<form ref={form} onSubmit={handleSubmit}>
<div className="contact-input contact-input-light">
<TextField
id="user_name"
type="text"
name="user_name"
autoFocus="on"
autoFocus
autoComplete="off"
placeholder="Your Name"

style={{ width: '100%' }}
onChange={onChangeField}
value={formFields.user_name}
error={inputErrors.user_name}
error={!!inputErrors.user_name}
helperText={inputErrors.user_name}
/>
{inputErrors.user_name && (
<Typography
variant="caption"
style={{ fontSize: '1.4rem' }}
sx={{ color: 'red', padding: '5px' }}
>
{inputErrors.user_name}
</Typography>
)}
</div>
<br />
<div className="contact-input contact-input-light">
<TextField
id="user_email"
type="email"
name="user_email"
placeholder="Your Email"

onChange={onChangeField}
value={formFields.user_email}
autoComplete="email"
error={inputErrors.user_email}
style={{ width: '100%' }}
error={!!inputErrors.user_email}
helperText={inputErrors.user_email}
InputProps={{
style: { fontSize: '1.2rem', padding: '10px' }
}}
/>
{inputErrors.user_email && (
<Typography
variant="caption"
style={{ fontSize: '1.4rem' }}
sx={{ color: 'red', padding: '5px' }}
>
{inputErrors.user_email}
</Typography>
)}
</div>

<br />
<div className="contact-input contact-input-light">
<TextareaAutosize
id="message"
type="text"
autoComplete="off"
name="message"
placeholder="Your Message"

onChange={onChangeField}
value={formFields.message}
error={inputErrors.message}
style={{
width: '100%',
height: '100px',
padding: '10px',
fontSize: '1.2rem'
}}
className={inputErrors.message ? 'error' : ''}
/>
{inputErrors.message && (
<Typography
variant="caption"
style={{ fontSize: '1.4rem' }}
style={{ fontSize: '1rem' }}
sx={{ color: 'red', padding: '5px' }}
>
{inputErrors.message}
</Typography>
)}

</div> */}
<input
id="user_name"
name="user_name"
autoFocus="on"
autoComplete="off"
onChange={onChangeField}
value={formFields.user_name}
error={inputErrors.user_name}
type="text"
placeholder="Your Name"
/>
<input
id="user_email"
type="email"
name="user_email"
placeholder="Your Email"
onChange={onChangeField}
value={formFields.user_email}
autoComplete="email"
error={inputErrors.user_email}
/>
<input
id="message"
type="text"
autoComplete="off"
name="message"
placeholder="Your Message"
onChange={onChangeField}
value={formFields.message}
error={inputErrors.message}
/>
</div>
<br />
<div className="submit-btn">
<Button
type="submit"
className="btn btn-g btn-lg w-100"
onClick={handleClick}
style={{ fontSize: '1.2rem' }}
>
Sign In
Submit
</Button>
</div>
</form>
<ToastContainer />
</div>
</div>
</React.Fragment>
Expand Down
Loading