Skip to content

Commit

Permalink
Merge branch 'main' of github.com:WBG-Coach/coach-admin-sl
Browse files Browse the repository at this point in the history
  • Loading branch information
Janderson Souza Matias authored and Janderson Souza Matias committed Aug 2, 2023
2 parents 8d1890e + ed572cb commit 112c7e5
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/pages/Settings/EditUser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const EditUser = () => {
General
</Text>
<Text fontWeight={400} mt={'4px'} color={'Gray.$700'}>
Update your photo and your information.
Update your information.
</Text>

<Center w={'100%'} my={'40px'}>
Expand Down
41 changes: 26 additions & 15 deletions src/pages/Settings/Users/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
DrawerFooter,
DrawerHeader,
DrawerOverlay,
FormControl,
FormErrorMessage,
FormLabel,
Input,
Expand Down Expand Up @@ -41,21 +40,33 @@ const UserForm: React.FC<Props> = ({ defaultValues, handleSubmitForm, handleClos
<DrawerHeader>{defaultValues && 'id' in defaultValues ? 'Update user' : 'New user'}</DrawerHeader>

<DrawerBody>
<FormControl isInvalid={!!errors.name}>
<FormLabel htmlFor="name">Name</FormLabel>
<Controller
rules={{ required: true }}
control={control}
name="name"
render={({ field, fieldState }) => (
<Input id="name" {...field} value={field.value} isInvalid={!!fieldState.error} />
)}
/>
<FormLabel htmlFor="name">Name</FormLabel>
<Controller
rules={{ required: true }}
control={control}
name="name"
render={({ field, fieldState }) => (
<Input id="name" {...field} value={field.value} isInvalid={!!fieldState.error} />
)}
/>

<FormErrorMessage>
{errors.name && errors.name.type === 'required' && 'Name is required'}
</FormErrorMessage>
</FormControl>
<FormErrorMessage>{errors.name && errors.name.type === 'required' && 'Name is required'}</FormErrorMessage>

<FormLabel htmlFor="name" style={{ marginTop: '8px' }}>
Email
</FormLabel>
<Controller
rules={{ required: true }}
control={control}
name="email"
render={({ field, fieldState }) => (
<Input id="email" {...field} value={field.value} isInvalid={!!fieldState.error} />
)}
/>

<FormErrorMessage>
{errors.email && errors.email.type === 'required' && 'Email is required'}
</FormErrorMessage>
</DrawerBody>

<DrawerFooter mt="auto">
Expand Down
33 changes: 22 additions & 11 deletions src/pages/Settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Box, HStack, Text, VStack } from '@chakra-ui/react';
import { useState } from 'react';
import { useContext, useState } from 'react';
import { useTranslation } from 'react-i18next';
import EditUser from './EditUser';
import ChangePassword from './ChangePassword';
import Users from './Users';
import Icon from '@/components/Base/Icon';
import HeaderPage from '@/components/HeaderPage';
import Logs from './Logs';
import { UserContext } from '@/contexts/UserContext';

const SettingsPage: React.FC = () => {
const { t } = useTranslation();
const { user } = useContext(UserContext);
const [currentOption, setCurrentOption] = useState(0);
const options = [
{
Expand All @@ -22,16 +24,25 @@ const SettingsPage: React.FC = () => {
icon: 'lock',
component: <ChangePassword />,
},
{
label: t('settings.tabs.users.title'),
icon: 'user',
component: <Users />,
},
{
label: t('settings.tabs.logs.title'),
icon: 'receipt-alt',
component: <Logs />,
},
...(user?.role === 'admin'
? [
{
label: t('settings.tabs.users.title'),
icon: 'user',
component: <Users />,
},
]
: []),

...(user?.role === 'admin'
? [
{
label: t('settings.tabs.logs.title'),
icon: 'receipt-alt',
component: <Logs />,
},
]
: []),
];

return (
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface IUser {
id: string;
email: string;
name: string;
role: 'analist' | 'admin';
password: string;
}

Expand Down

0 comments on commit 112c7e5

Please sign in to comment.