Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions public/app_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/DTOs/Auth.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { StringifyOptions } from 'node:querystring';
import { ReactNode } from 'react';

export interface AuthState {
Expand Down Expand Up @@ -43,8 +42,9 @@ export interface RecoveryCredentials {
}

export interface ResetCredentials {
email: string;
password: string;
confirmPassword: string;
password_confirmation: string;
}

interface InvitationData {
Expand All @@ -65,6 +65,7 @@ interface RecoveryPassowordData {
interface ResetPasswordData {
error: String;
loader: boolean;
success: boolean;
}

export interface AuthContextData {
Expand Down
2 changes: 1 addition & 1 deletion src/components/BoxInformation/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const StyledBoxInformation = styled.div`
justify-content: flex-end;

color: #fff;
font-size: 1.5rem;
font-size: 1rem;
font-weight: 900;
margin: 0;

Expand Down
6 changes: 3 additions & 3 deletions src/components/Button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const StyledButton = styled.button<StyledButtonProps>`
width: ${props => props.size || '17.313rem'};
height: 4.063rem;
border-radius: 1.25rem;
border: none;
outline: none;
border: 0.063rem;
outline: 0.063rem;

font-family: Roboto;
font-style: normal;
font-weight: bold;
font-size: 1.5rem;
font-size: 2rem;

color: ${props => props.colorText || '#fff'};
background: ${props => props.color || '#F60846'};
Expand Down
28 changes: 22 additions & 6 deletions src/components/FormUpdate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,6 +32,7 @@ interface ParamsProps {
email: string;
}
function FormUpdate({
emailIsNotAllowed,
handleSubmit,
formRef,
inviteInfo,
Expand Down Expand Up @@ -64,12 +67,24 @@ function FormUpdate({
title="Empresa"
/>

<InputForm
name="email"
title="E-mail"
defaultValue={paramsEmail || user?.email || ''}
readOnly={!!paramsEmail}
/>
{emailIsNotAllowed ? (
<Input
name="email"
title="E-mail"
styleWidth="40rem"
color="var(--black);"
weight="bold"
defaultValue={paramsEmail || user?.email || ''}
readOnly={!!paramsEmail}
/>
) : (
<InputForm
name="email"
title="E-mail"
defaultValue={paramsEmail || user?.email || ''}
readOnly={!!paramsEmail}
/>
)}

<InputForm defaultValue={user?.phone} name="phone" title="Telefone" />

Expand Down Expand Up @@ -98,6 +113,7 @@ function FormUpdate({
}

FormUpdate.defaultProps = {
emailIsNotAllowed: false,
hasPasswordField: false,
user: {
name: '',
Expand Down
8 changes: 7 additions & 1 deletion src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const Header = () => {
history.push('/minute');
}, [history]);

const handleNavigateToUserUpdate = useCallback(() => {
history.push('/user/update');
}, [history]);

return (
<StyledHeader>
<section className="shortOptions">
Expand All @@ -48,7 +52,9 @@ const Header = () => {
</figure>

<section className="usernameAndLogout">
<h1>{user?.name || 'Nome do usuário'}</h1>
<button type="button" onClick={handleNavigateToUserUpdate}>
<h1>{user?.name || 'Nome do usuário'}</h1>
</button>

<button type="button" onClick={handleLogout}>
<img src={logoutIcon} alt="logout" />
Expand Down
9 changes: 9 additions & 0 deletions src/components/Header/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,13 @@ export const StyledHeader = styled.header`
border: none;
background: none;
}

@media (max-width: 960px) {
zoom: 70%;
height: 6rem;

img {
zoom: 135%;
}
}
`;
6 changes: 5 additions & 1 deletion src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { StyledInput } from './styles';
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
title: string;
color?: string;
weight?: string;
Size?: string;
styleWidth?: string;
Type?: string;
Expand All @@ -14,6 +15,7 @@ const Input: React.FC<InputProps> = ({
color,
Size,
styleWidth,
weight,
Type,
...rest
}: InputProps) => {
Expand All @@ -22,6 +24,7 @@ const Input: React.FC<InputProps> = ({
InputWidth={styleWidth || '23.75rem'}
Color={color || 'var(--black)'}
Size={Size || '1.5rem'}
weight={weight}
className="input-styled"
>
<h3>{title}</h3>
Expand All @@ -34,8 +37,9 @@ const Input: React.FC<InputProps> = ({
Input.defaultProps = {
Type: '',
Size: '',
weight: '',
styleWidth: '23.75rem',
color: '',
color: 'var(--black)',
};

export default Input;
6 changes: 4 additions & 2 deletions src/components/Input/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface Props {
InputWidth: string;
Color: string;
Size: string;
weight?: string;
}

export const StyledInput = styled.div<Props>`
Expand All @@ -16,7 +17,7 @@ export const StyledInput = styled.div<Props>`
margin: 0;

h3 {
font-weight: bold;
font-weight: 500;
font-size: ${props => props.Size || '1.5rem'};
color: ${props => props.Color || 'var(--black)'};

Expand All @@ -33,12 +34,13 @@ export const StyledInput = styled.div<Props>`
font-family: Roboto;
font-size: 1.3rem;
font-style: normal;
font-weight: bold;
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%;
}
Expand Down
16 changes: 14 additions & 2 deletions src/components/Route/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 <Redirect to="404" />;
}

return (
<ReactRoute
{...rest}
Expand Down Expand Up @@ -49,6 +60,7 @@ const Route = ({ component: Component, isPrivate, ...rest }: RouteProps) => {

Route.defaultProps = {
exact: false,
onlyAdmin: false,
isPrivate: false,
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/ScrollBox/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const StyledScrollBox = styled.div`
::-webkit-scrollbar {
width: 12px;
border-radius: 20px;
background: var(--red-pink);
background: #ffe7ed;
}

::-webkit-scrollbar-thumb {
border: 3px solid var(--red-pink);
border: 3px solid #ffe7ed;
border-radius: 20px;
background: white;
}
Expand Down
36 changes: 20 additions & 16 deletions src/contexts/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const AuthProvider = ({ children }: AuthProviderProps) => {

const [resetError, setResetError] = useState<string>('');
const [resetLoader, setResetLoader] = useState<boolean>(false);
const [resetSuccess, setResetSuccess] = useState<boolean>(false);

const [data, setData] = useState<AuthState>(() => {
const token = localStorage.getItem('@Typext:token');
Expand Down Expand Up @@ -130,23 +131,28 @@ const AuthProvider = ({ children }: AuthProviderProps) => {
setRecoveryLoader(false);
}, []);

const resetPassword = useCallback(async ({ password, confirmPassword }) => {
setResetLoader(true);
const resetPassword = useCallback(
async ({ email, password, password_confirmation }) => {
setResetLoader(true);

try {
setRecoveryError('');
try {
setResetError('');

await api.post('/password/reset', { password, confirmPassword });
} catch (err) {
const errorStatus = err.response?.status;
await api.post('/password/reset', {
email,
password,
password_confirmation,
});

if (errorStatus === 401) {
setResetError(err.response?.data.message);
setResetLoader(false);
setResetSuccess(true);
} catch (err) {
setResetLoader(false);
setResetError(err.response?.data.validation.body.message);
}

setResetLoader(false);
}
}, []);
},
[],
);

return (
<AuthContext.Provider
Expand All @@ -168,6 +174,7 @@ const AuthProvider = ({ children }: AuthProviderProps) => {
reset: {
error: resetError,
loader: resetLoader,
success: resetSuccess,
},
signIn,
signUp,
Expand All @@ -193,6 +200,3 @@ function useAuth(): AuthContextData {
}

export { AuthProvider, useAuth };
function async(arg0: { email: any }): any {
throw new Error('Function not implemented.');
}
10 changes: 5 additions & 5 deletions src/pages/Minute/components/Distributions/Distributions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const Distributions = () => {
};

const deleteDistributions = (value: string) => {
setDistributions(distributions.filter(
distributionValue => distributionValue !== value,
));
setDistributions(
distributions.filter(distributionValue => distributionValue !== value),
);
};

return (
Expand All @@ -46,7 +46,7 @@ const Distributions = () => {
<div className="DataDepartments">
<Input
title="Área"
styleWidth="49.375rem"
styleWidth="100%"
value={distribution}
onChange={(e: any) => setDistribution(e.target.value)}
/>
Expand All @@ -63,6 +63,7 @@ const Distributions = () => {
</div>

<div className="Departments">
<h3>Distribuições adicionadas:</h3>
<ScrollBox>
{distributions.map(distributionValue => (
<BoxInformation
Expand All @@ -72,7 +73,6 @@ const Distributions = () => {
<h4>{distributionValue}</h4>
</BoxInformation>
))}

</ScrollBox>
</div>
</div>
Expand Down
Loading