diff --git a/components/ChapterDirectory/ChapterDirectory.component.jsx b/components/ChapterDirectory/ChapterDirectory.component.jsx index 1afdec2f..16bb8c77 100644 --- a/components/ChapterDirectory/ChapterDirectory.component.jsx +++ b/components/ChapterDirectory/ChapterDirectory.component.jsx @@ -42,13 +42,12 @@ const ChapterDirectory = ({ ); setStartedAChapter(result); }, [locationDetails]); - return (
{startedAChapter ? ( ) : ( - + )}
diff --git a/components/ChapterDirectory/ChapterDirectory.module.css b/components/ChapterDirectory/ChapterDirectory.module.css index 1d1bc312..63e17d75 100644 --- a/components/ChapterDirectory/ChapterDirectory.module.css +++ b/components/ChapterDirectory/ChapterDirectory.module.css @@ -4,8 +4,8 @@ align-items: center; justify-content: center; flex-direction: column; - padding: 4em 0.5em 3em 0.5em; - background: linear-gradient(90deg, #ff00b8 0%, #ff655b 50.8%, #ffc700 100%); + padding: 10em 0.5em 3em 0.5em; + font-family: 'Poppins', sans-serif; } .joinWrapper { @@ -18,13 +18,12 @@ .joinOuterContainer { width: 100%; - border: 2px solid rgb(255, 255, 255, 0.5); - padding: 1em; } .joinContainer { width: 100%; - background: rgba(255, 255, 255, 0.7); + border-radius: 16px; + background-color: #1C1D37; display: flex; align-items: center; justify-content: center; @@ -42,23 +41,24 @@ margin-bottom: 1em; font-size: 1.2rem; font-weight: 500; - color: black; + color: rgb(255, 255, 255); } .joinButton { - background: #151371; - padding: 8px 24px; - border-radius: 8px; - cursor: pointer; - color: white; + color: #ffffff; + padding: 0.3em 0.8em; text-transform: capitalize; - transition: all 350ms cubic-bezier(0.165, 0.84, 0.44, 1); + background: #6938EF; + border-radius: 100px; + font-size: 18px; + font-weight: 500; + padding: 12px 30px; } .joinButton:hover { - background: white; - border: 2px solid #151371; - color: #151371; + /* background: white; + border: 2px solid #151371; */ + color: #fff; } @media screen and (max-width: 1024px) { diff --git a/components/ChapterMenu/ChapterMenu.component.jsx b/components/ChapterMenu/ChapterMenu.component.jsx index 5d0d7cfd..80b62a9b 100644 --- a/components/ChapterMenu/ChapterMenu.component.jsx +++ b/components/ChapterMenu/ChapterMenu.component.jsx @@ -17,7 +17,9 @@ const ChapterMenu = () => ( />
Find Advisor
- +
+
+
@@ -30,7 +32,9 @@ const ChapterMenu = () => ( />
Hold An Interest Meeting
- +
+
+
@@ -42,7 +46,9 @@ const ChapterMenu = () => ( />
Sign Chapter Agreement Form
- +
+
+
@@ -54,7 +60,9 @@ const ChapterMenu = () => ( />
Find Your Team
- +
+
+
@@ -66,7 +74,9 @@ const ChapterMenu = () => ( />
Get On Technologes
- +
+
+
@@ -78,7 +88,9 @@ const ChapterMenu = () => ( />
Develop Socially Impactful Project
- +
+
+
@@ -92,7 +104,9 @@ const ChapterMenu = () => ( Host Meetings Workshops Carreer Development
- +
+
+
diff --git a/components/ChapterMenu/ChapterMenu.module.css b/components/ChapterMenu/ChapterMenu.module.css index 909f58df..6ddb6ff8 100644 --- a/components/ChapterMenu/ChapterMenu.module.css +++ b/components/ChapterMenu/ChapterMenu.module.css @@ -8,8 +8,16 @@ .meter { width: 100%; + height: 8px; + background: rgba(82, 85, 141, 0.61); + border-radius: 17px; + display: flex; +} +.meter div{ + border-radius: 17px; + height: 100%; + background: linear-gradient(270deg, #FD05B3 1.84%, rgba(253, 5, 179, 0.15) 100%); } - .menuContainer { width: 100%; max-width: 64em; @@ -26,11 +34,11 @@ flex-direction: column; text-align: center; border-radius: 0.5em; - background: #282828; + background: #1C1D37; } .menuContainer > section:first-child { - background: #ffc700; + background: #6938EF; } .iconAndTextContainer { @@ -52,8 +60,9 @@ .item1 { padding: 1em 0; text-transform: uppercase; + font-size: 18px; font-weight: 500; - color: #151371; + color: #fff; } .item4, @@ -106,10 +115,6 @@ grid-row: 5/8; } -.meter::-webkit-meter-optimum-value { - background: #ff655b; - height: 50px; -} @media screen and (max-width: 1024px) { .menuContainer { diff --git a/components/InterestForm/FormValidations.js b/components/InterestForm/FormValidations.js index f1923a5c..d2b3c20e 100644 --- a/components/InterestForm/FormValidations.js +++ b/components/InterestForm/FormValidations.js @@ -1,32 +1,38 @@ const validateSection_1 = (values) => { if (values.profession !== 'student' && values.profession.length !== 0) return {}; if (values.profession.length === 0 && values.profession !== 'student') return { profession: 'Please select a profession' }; - if (values.level.length === 0) return { level: 'Please select your level of education' }; - if (values.school.length === 0) return { school: 'Please tell us the name of your school' }; return {}; }; const validateSection_2 = (values) => { - if (values.interest.length === 0) return { interest: 'Please pick atleast one of your interests' }; + if (values.level.length === 0) return { level: 'Please select your level of education' }; return {}; }; const validateSection_3 = (values) => { - if (values.passion.length === 0) return { passion: 'Please pick atleast one of your passions' }; + if (values.location.length === 0 || values.country.length === 0 || values.city.length === 0) return { school: 'Please fill in the missing fields' }; return {}; }; const validateSection_4 = (values) => { - if (values.reasons.length === 0) return { reasons: 'Please tell us your reasons' }; + if (values.interest.length === 0) return { interest: 'Please pick atleast one of your interests' }; return {}; }; - const validateSection_5 = (values) => { - if (values.support.length === 0) return { support: 'Please tells us how we may support you' }; + if (values.passion.length === 0) return { passion: 'Please pick atleast one of your passions' }; + return {}; +}; +const validateSection_6 = (values) => { + if (values.description.length === 0) return { reasons: 'Please fill in the missing fields' }; return {}; }; const validateSection_7 = (values) => { + if (values.mission.length === 0) return { support: 'Please fill in the missing fields' }; + return {}; +}; + +const validateSection_9 = (values) => { if (values.contact.length === 0) return { contact: 'Please select how we may contact you' }; if (values.email) { if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(values.email)) { @@ -37,7 +43,7 @@ const validateSection_7 = (values) => { }; export const validateField = ({ - section_1, section_2, section_3, section_4, section_5, section_7, + section_1, section_2, section_3, section_4, section_5, section_7, section_6, }, values) => { if (section_1) { return validateSection_1(values); @@ -49,9 +55,16 @@ export const validateField = ({ return validateSection_4(values); } if (section_5) { return validateSection_5(values); - } if (section_7) { + } + if (section_6) { + return validateSection_6(values); + } + if (section_7) { return validateSection_7(values); } + // if (section_8) { + // return validateSection_8(values); + // } return {}; }; @@ -69,7 +82,11 @@ export const validateStepper = (sections, values, nextStep) => { return { reasons: 'Field 4 is required' }; } if (sectionsToArray[i] === 'section_5' && Object.keys(validateSection_5(values)).length !== 0) { return { support: 'Field 5 is required' }; - } if (sectionsToArray[i] === 'section_7' && Object.keys(validateSection_7(values)).length !== 0) { + } + if (sectionsToArray[i] === 'section_7' && Object.keys(validateSection_7(values)).length !== 0) { + return { contact: 'Field 7 is required' }; + } + if (sectionsToArray[i] === 'section_9' && Object.keys(validateSection_9(values)).length !== 0) { return { contact: 'Field 7 is required' }; } } @@ -78,10 +95,11 @@ export const validateStepper = (sections, values, nextStep) => { export const validateForm = (values) => { if (Object.entries(validateSection_1(values)).length !== 0) return validateSection_1(values); - if (Object.entries(validateSection_2(values)).length !== 0) return validateSection_2(values); if (Object.entries(validateSection_3(values)).length !== 0) return validateSection_3(values); if (Object.entries(validateSection_4(values)).length !== 0) return validateSection_4(values); if (Object.entries(validateSection_5(values)).length !== 0) return validateSection_5(values); + if (Object.entries(validateSection_6(values)).length !== 0) return validateSection_6(values); if (Object.entries(validateSection_7(values)).length !== 0) return validateSection_7(values); + if (Object.entries(validateSection_9(values)).length !== 0) return validateSection_9(values); return {}; }; diff --git a/components/InterestForm/InterestForm.component.jsx b/components/InterestForm/InterestForm.component.jsx index a917ac6d..eb944bb4 100644 --- a/components/InterestForm/InterestForm.component.jsx +++ b/components/InterestForm/InterestForm.component.jsx @@ -1,58 +1,110 @@ import axios from 'axios'; import React, { useState } from 'react'; import Select from 'react-select'; +import Geocode from 'react-geocode'; import { errorToast, successToast } from '../../contexts/utils/toasts'; -import { validateField, validateForm, validateStepper } from './FormValidations'; +import { validateField, validateForm } from './FormValidations'; import styles from './InterestForm.module.css'; +import DropdownIndicator from '../settings/DropdownIndicator'; +import { + countries, passionOptions, interestOptions, countriesLoaction, +} from './Options'; -const interestOptions = [ - { label: 'Development', value: 'development' }, - { label: 'Design', value: 'design' }, - { label: 'Frontend', value: 'frontend' }, - { label: 'Backend', value: 'backend' }, - { label: 'Research', value: 'research' }, - { label: 'Marketing', value: 'marketing' }, - { label: 'Intructing', value: 'intructing' }, - { label: 'Project Management', value: 'Project management' }, -]; +const customStyles = { + option: (provided, state) => ({ + ...provided, + color: 'white', + border: state.isSelected ? '2px solid #6938EF' : state.isFocused ? '2px solid #6938EF' : '2px solid transparent', + background: '#1C1D37', + borderRadius: '8px', + padding: 20, + marginTop: 8, + width: '100%', + cursor: 'pointer', + fontWeight: 'bold', + ':active': { + // ...styles[':active'], + background: '#1C1D37', + }, + }), + control: () => ({ + // none of react-select's styles are passed to + // width: , + display: 'flex', + height: '100%', + }), + menu: (provided) => ({ + ...provided, + // borderBottom: '1px dotted pink', + background: '#1C1D37', + padding: 5, + border: '1px solid #6938EF', + width: '100%', + textAlign: 'center', + // marginLeft: '-70px', + }), + container: (provided) => ({ + ...provided, + height: '60px', + margin: '0 !important', + cursor: 'pointer', + paddingLeft: '8px', + border: '1px solid #6938EF', + borderRadius: '16px', + }), + multiValueLabel: (provided) => ({ + ...provided, + color: 'white', + }), + multiValue: (provided) => ({ + ...provided, + border: '1px solid #6938EF', + borderRadius: '100px', + background: 'transparent', + padding: '5px', + }), + multiValueRemove: (provided) => ({ + ...provided, + color: 'white', + }), + indicatorSeparator: (provided) => ({ + ...provided, + display: 'none', + }), + singleValue: (provided) => { + const opacity = 1; + const color = '#fff'; + const transition = 'opacity 300ms'; -const passionOptions = [ - { label: 'Technology', value: 'technology' }, - { label: 'Nature', value: 'nature' }, - { label: 'Music', value: 'music' }, - { label: 'Sports', value: 'sports' }, - { label: 'Entreprenuership', value: 'entreprenuership' }, - { label: 'Reading', value: 'reading' }, - { label: 'Volunteering', value: 'volunteering' }, - { label: 'Arts', value: 'arts' }, - { label: 'Dancing', value: 'dancing' }, - { label: 'Comedy', value: 'comedy' }, - { label: 'Gaming', value: 'gaming' }, - { label: 'Cooking', value: 'cooking' }, - { label: 'Animals', value: 'animals' }, - { label: 'Travel', value: 'travel' }, -]; + return { + ...provided, opacity, transition, color, + }; + }, +}; -const InterestForm = function ({ token }) { +const InterestForm = ({ token, userData }) => { const [values, setValues] = useState({ status: 'pending', interest: [], passion: [], profession: '', level: '', - school: '', - reasons: '', - support: '', + location: '', + description: '', + mission: '', contact: '', phone: '', email: '', + country: '', + lat: '', + lon: '', + city: '', interestedMembers: 0, }); const [submitError, setSubmitError] = useState(''); const [errors, setErrors] = useState({}); const [isSubmit, toggleSubmit] = useState(false); - const [activeButton, setActiveButton] = useState('section_1'); const [sections, setSections] = useState({ section_1: true, section_2: false, @@ -61,8 +113,12 @@ const InterestForm = function ({ token }) { section_5: false, section_6: false, section_7: false, + section_8: false, + section_9: false, }); + Geocode.setApiKey('AIzaSyAj-BtIthMo51RCnyjesNP11pF_R07qbMA&callback'); + const handleChange = (event) => { const { name } = event.target; const { value } = event.target; @@ -88,9 +144,28 @@ const InterestForm = function ({ token }) { const result = (validateField(sections, values)); handleError(result); if (Object.keys(result).length === 0) { - const newSections = { ...sections }; - const newSectionsArray = Object.keys(newSections); + let newSections = { ...sections }; + let newSectionsArray = Object.keys(newSections); + if (values.profession === 'Professional') { + newSectionsArray = newSectionsArray.filter((e) => e !== 'section_2'); + delete newSections.section_2; + } else if (values.profession === 'student' && newSections.section_1) { + newSections = { + section_1: true, + section_2: false, + section_3: false, + section_4: false, + section_5: false, + section_6: false, + section_7: false, + section_8: false, + section_9: false, + }; + newSectionsArray = Object.keys(newSections); + } let id = null; + setSections(newSections); + newSectionsArray.forEach((_, idx, arr) => { if (newSections[arr[idx]]) { id = idx; @@ -98,9 +173,32 @@ const InterestForm = function ({ token }) { }); newSections[newSectionsArray[id]] = false; newSections[newSectionsArray[id + 1]] = true; - setActiveButton(newSectionsArray[id + 1]); setSections(newSections); } + if (sections.section_4 === true) { + // Get latitude & longitude from address. + Geocode.setRegion(values.country.value.toLowerCase()); + Geocode.fromAddress(values.location).then( + (response) => { + const { lat, lng } = response.results[0].geometry.location; + const newValue = values; + newValue.lat = lat; + newValue.lon = lng; + setValues(newValue); + }, + (error) => { + countriesLoaction.forEach((country) => { + if (country.code === values.country.value) { + const newValue = values; + newValue.lat = country.latitude; + newValue.lon = country.longitude; + setValues(newValue); + } + }); + console.error(error); + }, + ); + } }; const handlePrev = () => { @@ -115,12 +213,19 @@ const InterestForm = function ({ token }) { }); newSections[newSectionsArray[id]] = false; newSections[newSectionsArray[id - 1]] = true; - setActiveButton(newSectionsArray[id - 1]); setSections(newSections); }; - + const getWidth = (stats) => { + let step = 0; + const arr = Object.values(stats); + step = arr.indexOf(true); + step /= (arr.length - 1); + step = `${step * 100}%`; + return step; + }; const handleSubmit = () => { setErrors({}); + console.log(values); const result = (validateForm(values)); if (Object.keys(result).length === 0) { let _values = { ...values }; @@ -138,14 +243,36 @@ const InterestForm = function ({ token }) { }); if (token) { - axios.post(`${process.env.BASE_URI}/chapter`, { - ..._values, - }, { + console.log(_values); + toggleSubmit(true); + + // Main St, Harrisonburg, US + const inputs = { + location: _values.location, + LocationName: `${_values.city}, ${_values.country.value}`, + chapter_leader: `${userData.firstName} ${userData.lastName}`, + description: _values.description, + mission: _values.mission, + latitude: _values.lat, + longitude: _values.longitude, + member_size: '1', + phone: _values.phone, + email: _values.email, + interestedMembers: _values.interestedMembers, + profession: _values.profession, + passion: _values.passion, + interest: _values.interest, + // eslint-disable-next-line new-cap + date_founded: new Date().toDateString(), + }; + setSubmitError(''); + axios.post('http://localhost:5000/api/v1/location', inputs, { headers: { Authorization: ` Bearer ${token}`, }, }) - .then(() => { + .then((res) => { + console.log(res.data.data); setSubmitError(''); successToast('Your chapter was successfully created'); toggleSubmit(true); @@ -163,45 +290,6 @@ const InterestForm = function ({ token }) { handleError(result); } }; - - const handleStepperClick = (step) => { - const result = (validateStepper(sections, values, step)); - if (Object.keys(result).length === 0) { - const newSections = { ...sections }; - Object.keys(newSections).forEach((section_key) => { - if (section_key === step) { - newSections[section_key] = true; - setActiveButton(section_key); - } else { - newSections[section_key] = false; - } - }); - setSections(newSections); - } else { - // handleError(result) - } - }; - - const getButtonStatus = (button) => { - const sectionsToArray = Object.keys(sections); - if (sectionsToArray.indexOf(activeButton) > sectionsToArray.indexOf(button)) { - return { background: 'pink' }; - } if (sectionsToArray.indexOf(activeButton) < sectionsToArray.indexOf(button)) { - return { background: '#d1d3d1' }; - } - return { background: '#ff00b8' }; - }; - - const getLineStatus = (button) => { - const sectionsToArray = Object.keys(sections); - if (sectionsToArray.indexOf(activeButton) > sectionsToArray.indexOf(button)) { - return { background: 'pink' }; - } if (sectionsToArray.indexOf(activeButton) < sectionsToArray.indexOf(button)) { - return { background: '#d1d3d1' }; - } - return { background: 'pink' }; - }; - return (
@@ -219,95 +307,125 @@ const InterestForm = function ({ token }) {
)} -
Interest Form
{ !isSubmit ? ( <> +
+
+
+
+ {' '} + {`Question ${(Object.values(sections).indexOf(true)) + 1}`} +
+
- + +
+
handleChange({ target: { name: 'profession', value: 'student' } })} + > + student +
+ Student +
+
+
{ setValues({ ...values, location: '', level: '' }); handleChange({ target: { name: 'profession', value: 'Professional' } }); }} + > + Professional +
+ Professional +
+
+ {errors.profession && ( +
{errors.profession}
+ )} +
+
+
+
-
+
- Student + High School Student
-
+
{ setValues({ ...values, school: '', level: '' }); handleChange(e); }} + onChange={handleChange} /> - Professional + College Student
- {errors.profession && ( -
{errors.profession}
+ {errors.level && ( +
{errors.level}
)}
+
+ + + +
+ +
+ {errors.school && ( +
{errors.school}
+ )} +
- { - values.profession === 'student' ? ( - <> -
- -
-
- - High School Student -
-
- - College Student -
- {errors.level && ( -
{errors.level}
- )} -
-
- -
- - - {errors.school && ( -
{errors.school}
- )} -
- - ) : null - } - -
- +
+
-
+