From a51ee45af3c5bd3d153c288d1f6f28d5c3ff62f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 14 Sep 2022 22:02:20 -0300 Subject: [PATCH] Create profile screen desktop layout --- src/app/AuthenticatedApp.js | 2 + src/screens/Profile/View.js | 194 ++++++++++++++++++++++++++++++++++ src/screens/Profile/index.js | 19 ++++ src/screens/Profile/styles.js | 11 ++ src/screens/Register/View.js | 22 ++-- src/screens/Register/index.js | 5 +- src/services/mocks.js | 2 +- src/utils/constants.js | 9 ++ 8 files changed, 248 insertions(+), 16 deletions(-) create mode 100644 src/screens/Profile/View.js create mode 100644 src/screens/Profile/index.js create mode 100644 src/screens/Profile/styles.js create mode 100644 src/utils/constants.js diff --git a/src/app/AuthenticatedApp.js b/src/app/AuthenticatedApp.js index 94bd986..0f30e7d 100644 --- a/src/app/AuthenticatedApp.js +++ b/src/app/AuthenticatedApp.js @@ -13,6 +13,7 @@ import Classroom from '../screens/Classroom'; import Assignment from '../screens/Assignment'; import { avatarMenuOptions, menuOptions } from './data'; +import Profile from '../screens/Profile'; function AuthenticatedApp() { const navigate = useNavigate(); @@ -46,6 +47,7 @@ function AuthenticatedApp() { } /> } /> } /> + } /> } /> diff --git a/src/screens/Profile/View.js b/src/screens/Profile/View.js new file mode 100644 index 0000000..4f55bba --- /dev/null +++ b/src/screens/Profile/View.js @@ -0,0 +1,194 @@ +import { + Avatar, + Box, + FormControl, + InputLabel, + MenuItem, + Select, + Stack, + TextField, + Typography, + Container, + Button, +} from '@mui/material'; +import dayjs from 'dayjs'; + +import InputMask from '../../components/InputMask'; + +import { COURSES } from '../../utils/constants'; +import { createArrayFrom1ToN } from '../../utils/createArrayFrom1ToN'; + +function View({ data, onChangeInput }) { + const fullName = `${data.firstName} ${data.lastName}`; + const currentYear = dayjs().year(); + + return ( + + + + + + {fullName} + + + Estudante de {COURSES.filter(c => c.value === data.course)[0].name} + + + Turma de {data.year} + + + RA: {data.ra} + + + + + + + + + + + + + + + + + + + Curso + + + + + + Ano da turma + + + + + + + + + + ); +} + +export default View; diff --git a/src/screens/Profile/index.js b/src/screens/Profile/index.js new file mode 100644 index 0000000..e6a7bb3 --- /dev/null +++ b/src/screens/Profile/index.js @@ -0,0 +1,19 @@ +import { useState } from 'react'; +import { useUser } from '../../context/user'; +import View from './View'; + +function Profile() { + const { state } = useUser(); + const [data, setData] = useState(state && state.user); + + const onChangeInput = e => { + const name = e.target.name; + const value = e.target.value; + + setData(prev => ({ ...prev, [name]: value })); + }; + + return ; +} + +export default Profile; diff --git a/src/screens/Profile/styles.js b/src/screens/Profile/styles.js new file mode 100644 index 0000000..e7de216 --- /dev/null +++ b/src/screens/Profile/styles.js @@ -0,0 +1,11 @@ +// ========== Desktop ========== +const desktop = {}; + +// ========== Mobile ========== +const mobile = {}; + +// ========== Unset ========== +const unset = {}; + +const styles = { desktop, mobile, unset }; +export default styles; diff --git a/src/screens/Register/View.js b/src/screens/Register/View.js index 0789d49..162b9c1 100644 --- a/src/screens/Register/View.js +++ b/src/screens/Register/View.js @@ -13,7 +13,6 @@ import { TextField, Typography, } from '@mui/material'; -import dayjs from 'dayjs'; import SnackbarIndicator from '../../components/SnackbarIndicator'; import LoadingIndicator from '../../components/LoadingIndicator'; @@ -23,6 +22,7 @@ import logoImage from '../../assets/if-salas-logo.svg'; import styles from './styles'; import { createArrayFrom1ToN } from '../../utils/createArrayFrom1ToN'; +import { COURSES } from '../../utils/constants'; function View({ isPending, @@ -33,10 +33,10 @@ function View({ onChangeInput, onChangeCheckbox, onTryRegister, + currentYear, }) { const { container, paper, boxLogo, boxForm, logoContainer } = styles[layoutType]; - const currentYear = dayjs().year(); return ( @@ -90,17 +90,11 @@ function View({ label="Curso" onChange={onChangeInput} > - - Bacharelado em Sistemas de Informação - - - Tecnologia em Processos Gerenciais - - Tecnologia em Logística - - Engenharia de Controle e Automação - - Bacharelado em Administração + {COURSES.map(course => ( + + {course.name} + + ))} @@ -117,7 +111,7 @@ function View({ onChange={onChangeInput} > {createArrayFrom1ToN(8).map(i => ( - + {currentYear - (i - 1)} ))} diff --git a/src/screens/Register/index.js b/src/screens/Register/index.js index 39af778..1f921ae 100644 --- a/src/screens/Register/index.js +++ b/src/screens/Register/index.js @@ -1,3 +1,4 @@ +import dayjs from 'dayjs'; import { useState } from 'react'; import { useAuthState } from '../../context/auth'; import { useDocumentTitle } from '../../hooks/useDocumentTitle'; @@ -7,6 +8,7 @@ import View from './View'; function Register() { useDocumentTitle('Criar conta'); + const currentYear = dayjs().year(); const { register, isPending, isError, error } = useAuthState(); const layoutType = useLayoutType(); const [data, setData] = useState({ @@ -14,7 +16,7 @@ function Register() { lastName: '', ra: '', course: 0, - year: 0, + year: currentYear, phone: '', email: '', password: '', @@ -49,6 +51,7 @@ function Register() { onChangeInput={onChangeInput} onChangeCheckbox={onChangeCheckbox} onTryRegister={onTryRegister} + currentYear={currentYear} /> ); } diff --git a/src/services/mocks.js b/src/services/mocks.js index 1555222..a67416e 100644 --- a/src/services/mocks.js +++ b/src/services/mocks.js @@ -535,7 +535,7 @@ const user = { avatar: 'https://i.pravatar.cc/300?img=61', course: 0, termsAgreed: true, - year: 0, + year: 2018, }; const authFailure = { diff --git a/src/utils/constants.js b/src/utils/constants.js new file mode 100644 index 0000000..41528f0 --- /dev/null +++ b/src/utils/constants.js @@ -0,0 +1,9 @@ +const COURSES = [ + { name: 'Bacharelado em Sistemas de Informação', value: 0 }, + { name: 'Tecnologia em Processos Gerenciais', value: 1 }, + { name: 'Tecnologia em Logística', value: 2 }, + { name: 'Engenharia de Controle e Automação', value: 3 }, + { name: 'Bacharelado em Administração', value: 4 }, +]; + +export { COURSES };