From d29a629ca6474a6b3d33b979cb2b1e12ff9082ff Mon Sep 17 00:00:00 2001 From: leonardo messias Date: Sat, 17 Apr 2021 22:13:17 -0300 Subject: [PATCH] fix(invite accept): fix invite accept route payload --- src/DTOs/Auth.tsx | 2 +- src/components/FormUpdate/index.tsx | 16 ++-- .../Minute/components/MinuteViewer/data.js | 79 ------------------- src/pages/Register/index.tsx | 11 +-- src/routes.tsx | 3 +- src/utils/registerSchemaValidation.ts | 1 + 6 files changed, 17 insertions(+), 95 deletions(-) delete mode 100644 src/pages/Minute/components/MinuteViewer/data.js diff --git a/src/DTOs/Auth.tsx b/src/DTOs/Auth.tsx index 781e7c3..ab8252b 100644 --- a/src/DTOs/Auth.tsx +++ b/src/DTOs/Auth.tsx @@ -27,7 +27,7 @@ export interface InviteUserCredentials { } export interface SignUpCredentials { - token: string; + email: string; name: string; password: string; password_confirmation: string; diff --git a/src/components/FormUpdate/index.tsx b/src/components/FormUpdate/index.tsx index 8add678..3299960 100644 --- a/src/components/FormUpdate/index.tsx +++ b/src/components/FormUpdate/index.tsx @@ -1,10 +1,10 @@ import React from 'react'; +import { useParams } from 'react-router-dom'; import { Form } from '@unform/web'; import InputForm from 'components/InputForm'; import Button from 'components/Button/Button'; -import Input from 'components/Input/Input'; import { Container } from './styles'; @@ -26,6 +26,9 @@ interface FormUpdateProps { }; } +interface ParamsProps { + email: string; +} function FormUpdate({ handleSubmit, formRef, @@ -33,6 +36,10 @@ function FormUpdate({ hasPasswordField, user, }: FormUpdateProps) { + const params = useParams(); + + const paramsEmail = params.email; + return (
@@ -57,12 +64,11 @@ function FormUpdate({ title="Empresa" /> - diff --git a/src/pages/Minute/components/MinuteViewer/data.js b/src/pages/Minute/components/MinuteViewer/data.js deleted file mode 100644 index 73bd4bc..0000000 --- a/src/pages/Minute/components/MinuteViewer/data.js +++ /dev/null @@ -1,79 +0,0 @@ -export const minuteData = { - addressAndHour: { - local: - 'Avenida Cesare Monsueto Giulio Lattes, 1350 Distrito - Eugênio de Melo, São José dos Campos - SP, 12247-014', - startDate: '27/3/21', - startHour: '12:41', - }, - projectInfo: { - projectName: - 'Incidente com tentativa de incendio por partes dos funcionarios', - members: [ - { - name: 'Luciano Huck', - role: 'Recursos Humanos', - enterprise: 'globo.tv', - phone: '40028922', - email: 'lc@gmail.com', - }, - { - name: 'Renato Aragão', - role: 'CEO', - enterprise: 'globo.tv', - phone: '12312312', - email: 'ra@gmail.com', - }, - { - name: 'Marcelo Rezende', - role: 'Delegado do DF 23', - enterprise: 'policial.com', - phone: '123010212', - email: 'mr@gmail.com', - }, - { - name: 'Maicon Cristo', - role: 'Apresentador', - enterprise: 'youtube.com', - phone: '123010212', - email: 'mc@gmail.com', - }, - ], - }, - topics: [ - { topic: 'Incendio' }, - { topic: 'Depravação' }, - { topic: 'Falta de deus' }, - ], - subjects: [ - { - subject: `Aqueça o óleo em uma panela. - Acrescente o alho picado e deixe dourar. - Em seguida, coloque a mesma quantidade de água indicada na embalagem para fazer o miojo. - Deixe ferver. - Acrescente o macarrão e em seguida o caldo de galinha. - Mexa por 1 minuto e deixe cozinhar no tempo indicado (geralmente 3 minutos)`, - responsible: 'Matheus Fields', - deadLine: '30/10/24', - }, - { - subject: - 'O tempo é uma grandeza física presente não apenas no cotidiano como também em todas as áreas e cadeiras científicas. Uma definição do mesmo em âmbito científico é por tal não apenas essencial como também, em verdade, um requisito fundamental.', - responsible: 'Siqueira Junior', - deadLine: '30/12/2028', - }, - { - subject: `You went to school to learn girl - Things you never knew before - Like "I" before "E" except after "C" - And why 2 plus 2 makes 4 - Now, now, now - I'm gonna teach you, teach you, teach you - All about love girl, all about love - Sit yourself down, take a seat - All you gotta do is repeat after me`, - responsible: 'Datena', - deadLine: '11/09/2054', - }, - ], - distributions: ['Não sei que é isso', 'Pode crer', 'Daora'], -}; diff --git a/src/pages/Register/index.tsx b/src/pages/Register/index.tsx index a2aff1e..3443a9c 100644 --- a/src/pages/Register/index.tsx +++ b/src/pages/Register/index.tsx @@ -1,5 +1,4 @@ import React, { useRef, useCallback, useState } from 'react'; -import { useParams } from 'react-router-dom'; import * as Yup from 'yup'; import { FormHandles } from '@unform/core'; @@ -19,6 +18,7 @@ import StyledRegisterNewUser from './styles'; interface SignUpData { name: string; + email: string; password: string; password_confirmation: string; office: string; @@ -27,12 +27,7 @@ interface SignUpData { area: string; } -interface ParamsProps { - token: string; -} - const RegisterNewUser = () => { - const params = useParams(); const formRef = useRef(null); const inviteInfo = getInviteInfo(); @@ -49,13 +44,13 @@ const RegisterNewUser = () => { await schema.validate(data, { abortEarly: false }); setOpenRegisterModal(true); - await signUp({ ...data, token: params.token }); + await signUp(data); } catch (err) { const errors = getValidationErrors(err); formRef.current?.setErrors(errors); } }, - [signUp, params], + [signUp], ); return ( diff --git a/src/routes.tsx b/src/routes.tsx index 5f0d1e8..0ae59ed 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -34,14 +34,13 @@ export default function Routes() { - + {userIsAdmin && ( <> - )} diff --git a/src/utils/registerSchemaValidation.ts b/src/utils/registerSchemaValidation.ts index 8490a57..0a2ab12 100644 --- a/src/utils/registerSchemaValidation.ts +++ b/src/utils/registerSchemaValidation.ts @@ -7,6 +7,7 @@ export default { phone: Yup.string().required('Telefone obrigatório'), password: Yup.string().required('Senha obrigatória'), company: Yup.string().required('Empresa obrigatória'), + email: Yup.string().email().required('Email obrigatório'), passwordConfirmation: Yup.string().oneOf( [Yup.ref('password'), null], 'Senhas devem ser iguais',