diff --git a/src/components/FormUpdate/index.tsx b/src/components/FormUpdate/index.tsx index 3299960..dee9fef 100644 --- a/src/components/FormUpdate/index.tsx +++ b/src/components/FormUpdate/index.tsx @@ -5,10 +5,12 @@ 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'; interface FormUpdateProps { + emailIsNotAllowed?: boolean; handleSubmit: any; formRef: any; hasPasswordField?: boolean; @@ -30,6 +32,7 @@ interface ParamsProps { email: string; } function FormUpdate({ + emailIsNotAllowed, handleSubmit, formRef, inviteInfo, @@ -64,12 +67,24 @@ function FormUpdate({ title="Empresa" /> - + {emailIsNotAllowed ? ( + + ) : ( + + )} @@ -98,6 +113,7 @@ function FormUpdate({ } FormUpdate.defaultProps = { + emailIsNotAllowed: false, hasPasswordField: false, user: { name: '', diff --git a/src/components/Input/Input.tsx b/src/components/Input/Input.tsx index 2f470f7..859f82b 100644 --- a/src/components/Input/Input.tsx +++ b/src/components/Input/Input.tsx @@ -4,6 +4,7 @@ import { StyledInput } from './styles'; interface InputProps extends InputHTMLAttributes { title: string; color?: string; + weight?: string; Size?: string; styleWidth?: string; Type?: string; @@ -14,6 +15,7 @@ const Input: React.FC = ({ color, Size, styleWidth, + weight, Type, ...rest }: InputProps) => { @@ -22,6 +24,7 @@ const Input: React.FC = ({ InputWidth={styleWidth || '23.75rem'} Color={color || 'var(--black)'} Size={Size || '1.5rem'} + weight={weight} className="input-styled" >

{title}

@@ -34,8 +37,9 @@ const Input: React.FC = ({ Input.defaultProps = { Type: '', Size: '', + weight: '', styleWidth: '23.75rem', - color: '', + color: 'var(--black)', }; export default Input; diff --git a/src/components/Input/styles.ts b/src/components/Input/styles.ts index ce06b53..f2d81c2 100644 --- a/src/components/Input/styles.ts +++ b/src/components/Input/styles.ts @@ -4,6 +4,7 @@ interface Props { InputWidth: string; Color: string; Size: string; + weight?: string; } export const StyledInput = styled.div` @@ -33,12 +34,13 @@ export const StyledInput = styled.div` font-family: Roboto; font-size: 1.3rem; font-style: normal; - font-weight: 400; + font-weight: ${props => props.weight || '400'}; outline: none; border: 0; border-radius: 1.25rem; + color: ${props => props.Color || 'var(--black)'}; max-width: ${props => props.InputWidth || '23.75rem'}; width: 100%; } diff --git a/src/components/Route/index.tsx b/src/components/Route/index.tsx index 90e5f60..003a454 100644 --- a/src/components/Route/index.tsx +++ b/src/components/Route/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Route as ReactRoute } from 'react-router-dom'; +import { Route as ReactRoute, Redirect } from 'react-router-dom'; import { useAuth } from 'contexts/auth'; import Header from 'components/Header'; @@ -11,15 +11,26 @@ interface RouteProps { path: string; exact?: boolean; isPrivate?: boolean; + onlyAdmin?: boolean; } -const Route = ({ component: Component, isPrivate, ...rest }: RouteProps) => { +const Route = ({ + component: Component, + isPrivate, + onlyAdmin, + ...rest +}: RouteProps) => { const { user: userContext } = useAuth(); const user = getUser(); + const userIsAdmin = user?.type === 'Admin'; const userToken = getUserToken(); const userIsAuthenticated = !!user && !!userToken; + if (onlyAdmin && !userIsAdmin) { + return ; + } + return ( { Route.defaultProps = { exact: false, + onlyAdmin: false, isPrivate: false, }; diff --git a/src/pages/UserUpdate/index.tsx b/src/pages/UserUpdate/index.tsx index 615a6de..0dd6e8b 100644 --- a/src/pages/UserUpdate/index.tsx +++ b/src/pages/UserUpdate/index.tsx @@ -11,7 +11,7 @@ import { useUsers } from 'contexts/user'; import { IUser } from 'DTOs/User'; import getValidationErrors from 'utils/getValidationErrors'; -import updateSchemaValidation from 'utils/updateSchemaValidation copy'; +import updateSchemaValidation from 'utils/updateSchemaValidation'; import ModalUpdateUser from './ModalUpdateUser'; @@ -62,6 +62,7 @@ function UserUpdate() { inviteInfo={inviteInfo} handleSubmit={handleSubmit} user={user} + emailIsNotAllowed /> diff --git a/src/routes.tsx b/src/routes.tsx index da2db0a..fdeb570 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -1,10 +1,8 @@ import React from 'react'; -import { Switch, BrowserRouter } from 'react-router-dom'; +import { Switch, BrowserRouter, Redirect } from 'react-router-dom'; import Route from 'components/Route'; -import { useAuth } from 'contexts/auth'; - import Recovery from 'pages/Recovery'; import UserUpdate from 'pages/UserUpdate'; import ResetPassword from 'pages/ResetPassword'; @@ -17,9 +15,6 @@ import NotFound from 'pages/NotFound'; import Users from 'pages/Users'; export default function Routes() { - const { user } = useAuth(); - const userIsAdmin = user?.type === 'Admin'; - return ( @@ -33,12 +28,10 @@ export default function Routes() { - {userIsAdmin && ( - <> - - - - )} + + + + ); diff --git a/src/utils/updateSchemaValidation copy.ts b/src/utils/updateSchemaValidation.ts similarity index 100% rename from src/utils/updateSchemaValidation copy.ts rename to src/utils/updateSchemaValidation.ts