From 3540881ec2f9bc81d6866f713677a58a33574c8b Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Thu, 14 May 2020 18:28:49 +0200 Subject: [PATCH] add statuses enum and enable EditProfile Form --- src/constants/statuses.ts | 12 +++ src/hooks/index.ts | 6 +- src/pages/EditProfile.tsx | 161 ++++++++++++++++++++++++++++++++------ 3 files changed, 154 insertions(+), 25 deletions(-) create mode 100644 src/constants/statuses.ts diff --git a/src/constants/statuses.ts b/src/constants/statuses.ts new file mode 100644 index 0000000..0e57d3a --- /dev/null +++ b/src/constants/statuses.ts @@ -0,0 +1,12 @@ +const Statuses: string[] = [ + 'Developer', + 'Junior Developer', + 'Senior Developer', + 'Manager', + 'Student or Learning', + 'Instructor or Teacher', + 'Intern', + 'Other', +]; + +export default Statuses; diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 84809c3..9651bd0 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -9,11 +9,13 @@ import {useState, ChangeEvent} from 'react'; * @returns handleChange function to pass to input tag * @returns resetForm function to revert to initFormData * */ -const useForm = (initFormData: T) => { +const useForm = (initFormData: T) => { const [formData, setFormData] = useState(initFormData); /** update each input state value onChange */ - const handleChange = (e: ChangeEvent): void => + const handleChange = ( + e: ChangeEvent, + ): void => setFormData({ ...formData, [e.target.name]: e.target.value, diff --git a/src/pages/EditProfile.tsx b/src/pages/EditProfile.tsx index a130933..e7a3dba 100644 --- a/src/pages/EditProfile.tsx +++ b/src/pages/EditProfile.tsx @@ -1,4 +1,6 @@ import React, {FC} from 'react'; +import {Link} from 'react-router-dom'; +import Routes from '../constants/routes'; // Style import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; import { @@ -9,11 +11,65 @@ import { faInstagram, } from '@fortawesome/free-brands-svg-icons'; import FormHeader from '../components/FormHeader'; +import Statuses from '../constants/statuses'; +// Form +import useForm from '../hooks'; +interface InitFormData { + status: string; + company: string; + website: string; + location: string; + skills: string; + github: string; + bio: string; + facebook: string; + linkedin: string; + instagram: string; + twitter: string; + youtube: string; +} /** * Form to update dev's personal information. */ const EditProfile: FC = () => { + const initFormData = { + status: '', + company: '', + website: '', + location: '', + skills: '', + github: '', + bio: '', + facebook: '', + linkedin: '', + instagram: '', + twitter: '', + youtube: '', + }; + const {formData, handleChange, resetForm} = useForm( + initFormData, + ); + + const { + status, + company, + website, + location, + skills, + github, + bio, + facebook, + linkedin, + instagram, + twitter, + youtube, + } = formData; + + const handleSubmit = (e: React.FormEvent): void => { + e.preventDefault(); + console.log('Submitted'); + }; return (
{ lead="Let's get some information to make your profile stand out" /> -
+
- - - - - - - - - + {Statuses.map((s: string, i: number) => ( + + ))} Give us an idea of where you are at in your career
- + Could be your own company or one you work for
- + Could be your own or a company website
- + City & state suggested (eg. Boston, MA)
- + Please use comma separated values (eg. HTML,CSS,JavaScript,PHP) @@ -66,7 +144,9 @@ const EditProfile: FC = () => { If you want your latest repos and a Github link, include your @@ -74,7 +154,12 @@ const EditProfile: FC = () => {
- + Tell us a little about yourself
@@ -87,33 +172,63 @@ const EditProfile: FC = () => {
- +
- +
- +
- +
- +
- + Go Back - +
);