Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
05e005a
feature: added teachers table
ihornovykov Nov 19, 2023
8883742
feature: added search field
ihornovykov Nov 23, 2023
5ddbb4e
bugfix: fixed changing proportions of some profile pictures with page…
I-delver-I Nov 27, 2023
9413a4c
build please
Markusplay Nov 28, 2023
bbf1017
bugfix: fixed changing proportions of some profile pictures with page…
I-delver-I Nov 27, 2023
4721dd1
Merge branch 'dev' into bugfix/user-profile-pic
I-delver-I Nov 28, 2023
24a6f8d
bugfix: replaced img tag with Avatar component from mui (#769)
I-delver-I Nov 28, 2023
01d6b73
Merge remote-tracking branch 'origin/bugfix/user-profile-pic' into bu…
I-delver-I Nov 28, 2023
1f58787
removed useless flex property (#769)
I-delver-I Nov 29, 2023
0c001b2
bugfix:teacher sorting issue 👩‍🏫 (#873)
kujo205 Nov 29, 2023
871788a
Merge pull request #876 from fictadvisor/bugfix/user-profile-pic
guywhodiesfirst Nov 30, 2023
7ebb5f6
enhancement: added password validation (#875)
M-Rybalko Dec 3, 2023
41e73c5
bugfix: event create date (#853)
sifes Dec 4, 2023
ae08498
Update issue templates
Markusplay Dec 6, 2023
7c00ad5
feature: added possibility to change order
ihornovykov Jan 4, 2024
88bcd74
feature: added teachers table
ihornovykov Nov 19, 2023
7dd96f7
feature: added search field
ihornovykov Nov 23, 2023
85b8bd8
feature: added possibility to change order
ihornovykov Jan 4, 2024
30f04b3
Merge remote-tracking branch 'origin/feature/admin-teachers-flow' int…
ihornovykov Jan 4, 2024
b680799
feature: added cathedra endpoint
ihornovykov Jan 4, 2024
6903cfb
feature: added create and edit page
ihornovykov Jan 4, 2024
4cd9349
feature: added delete endpoint
ihornovykov Jan 4, 2024
1af0ca1
feature: fixed pages
ihornovykov Jan 4, 2024
e147042
bugfix: fixed textarea component
ihornovykov Jan 4, 2024
41cfc3f
feature: added select for admin pages
ihornovykov Jan 4, 2024
1c0a0bd
feature: added fields to edit page
ihornovykov Jan 4, 2024
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Bug report
about: Create a report to help us improve
title: "[BUG] "
labels: bugfix
labels: ''
assignees: ''

---
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Feature
about: New feature on the front-end site
title: "[FEATURE]"
title: ''
labels: feature
assignees: ''

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/ui/form/input-mui/Input.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const label = (state: InputState): SxProps<Theme> => ({
export const remark = (state: InputState): SxProps<Theme> => ({
margin: '2px 8px 0 16px',
'&.MuiFormHelperText-root': {
textTransform: 'lowercase',
textTransform: 'none',
},

...(state === InputState.ERROR && {
Expand Down
3 changes: 3 additions & 0 deletions src/components/common/ui/form/text-area-mui/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface TextAreaProps {
disabled?: boolean;
showRemark?: boolean;
rowsNumber?: number;
value?: string;
sx?: SxProps<Theme>;
}
const TextArea: React.FC<TextAreaProps> = ({
Expand All @@ -33,6 +34,7 @@ const TextArea: React.FC<TextAreaProps> = ({
disabled = false,
showRemark = false,
rowsNumber = 4,
value = '',
sx = {},
}) => {
const [field, { touched, error }] = useField(name);
Expand All @@ -58,6 +60,7 @@ const TextArea: React.FC<TextAreaProps> = ({
rows={rowsNumber}
inputProps={{ maxLength: MAX_LENGTH }}
color="warning"
value={value}
placeholder={placeholder}
/>
{showRemark && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export const row: SxProps<Theme> = {
mobile: '8px',
desktop: '16px',
},
'& img': {
borderRadius: '50%',
'& .MuiAvatar-root': {
width: { mobile: '36px', desktop: '48px' },
height: { mobile: '36px', desktop: '48px' },
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { PlusIcon } from '@heroicons/react/24/solid';
import { Box, Grid, Typography, useMediaQuery } from '@mui/material';
import { Avatar, Box, Grid, Typography, useMediaQuery } from '@mui/material';

import { Captain } from '@/components/common/icons/Captain';
import { Moderator } from '@/components/common/icons/Moderator';
Expand Down Expand Up @@ -87,7 +87,7 @@ const StudentsTable: React.FC<StudentsTableProps> = ({
<Grid container key={index} sx={gridStyles.row}>
{row.imgSrc && (
<Grid item desktop={4} mobile={9}>
<img width={48} height={48} src={row.imgSrc} alt="avatar" />
<Avatar src={row.imgSrc} alt="avatar" />
{!isMobile && (
<Typography className="name">{row.fullName}</Typography>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const ChangePasswordForm = () => {
type={InputType.PASSWORD}
name="oldPassword"
isSuccessOnDefault={true}
showRemark={true}
/>
{errors.oldPassword === 'Введений пароль недійсний' && (
<Typography variant="body2">
Expand All @@ -77,6 +78,7 @@ const ChangePasswordForm = () => {
name="newPassword"
disabled={!!errors.oldPassword}
isSuccessOnDefault={true}
showRemark={true}
/>
<Input
sx={styles.input}
Expand All @@ -86,6 +88,7 @@ const ChangePasswordForm = () => {
name="confirmationPassword"
disabled={!!errors.oldPassword || !!errors.newPassword}
isSuccessOnDefault={true}
showRemark={true}
/>
<Box sx={styles.confirmButton}>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ export const validationSchema = yup.object().shape({
newPassword: yup
.string()
.required(`Обов'язкове поле`)
.min(8, 'Не коротше 8 символів')
.max(32, 'Не довше 32 символів')
.matches(
/^(?=.*[A-Za-z])(?=.*\d)[\w\W]+$/,
'Мінімум одна латинська літера та одна цифра',
/^(?=.*[A-Z])(?=.*\d)(?=.*[\W_])[\w\W]+$/,
'Мінімум одна велика латинська літера, одна цифра та один спеціальний символ',
),
confirmationPassword: yup
.string()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { SxProps, Theme } from '@mui/material/styles';

export const pagination: SxProps<Theme> = {
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'center',
borderBottom: 'none',
color: 'backgroundDark.600',
'& .MuiTablePagination-selectLabel': {
typography: 'body1Bold',
},
'& .MuiTablePagination-select, & .MuiTablePagination-displayedRows': {
color: 'white.main',
typography: 'body1Medium',
},
'& .MuiTablePagination-selectIcon': {
color: 'backgroundDark.600',
},
'& .MuiTablePagination-actions': {
'& .Mui-disabled': {
color: 'backgroundDark.500',
},
color: 'backgroundDark.600',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React, { FC, useState } from 'react';
import { useQuery } from 'react-query';
import { Box, TablePagination } from '@mui/material';
import { isAxiosError } from 'axios';

import TeachersAdminSearch from '@/components/pages/admin/teachers-admin-page/components/teachers-admin-search';
import { initialValues } from '@/components/pages/admin/teachers-admin-page/components/teachers-admin-search/constants';
import { AdminSearchFormFields } from '@/components/pages/admin/teachers-admin-page/components/teachers-admin-search/types';
import TeachersTable from '@/components/pages/admin/teachers-admin-page/components/teachers-table';
import { useToastError } from '@/hooks/use-toast-error/useToastError';
import teachersApi from '@/lib/api/teacher/TeacherAPI';

import * as styles from './TeachersAdminPage.styles';

const TeachersAdminPage: FC = () => {
const [count, setCount] = useState(0);
const [pageSize, setPageSize] = useState(10);
const [curPage, setCurPage] = useState(0);
const [params, setParams] = useState<AdminSearchFormFields>(initialValues);
const toast = useToastError();
const { data, isLoading, refetch } = useQuery(
[curPage, 'teachers', pageSize],
() => teachersApi.getAll(params, pageSize, curPage),
{
keepPreviousData: true,
refetchOnWindowFocus: false,
onSuccess: data => {
setCount(data?.pagination?.totalAmount || 0);
},
onError: error => {
if (isAxiosError(error)) {
toast.displayError(error.response?.data.message);
}
},
},
);

const handleChange = (values: AdminSearchFormFields) => {
setParams(values);
setCurPage(0);
refetch();
};

const handleRowsPerPageChange = (
event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
) => {
setPageSize(Number(event.target.value));
setCurPage(0);
};

return (
<Box sx={{ p: '20px 16px 0 16px' }}>
<TeachersAdminSearch onSubmit={handleChange} />
<TeachersTable
teachers={data?.teachers}
isLoading={isLoading}
count={pageSize}
/>
<TablePagination
sx={styles.pagination}
count={count}
page={curPage}
rowsPerPage={pageSize}
onPageChange={(e, page) => setCurPage(page)}
onRowsPerPageChange={e => handleRowsPerPageChange(e)}
/>
</Box>
);
};

export default TeachersAdminPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { SxProps, Theme } from '@mui/material/styles';

export const header: SxProps<Theme> = {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
width: '100%',
};

export const form: SxProps<Theme> = {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
gap: '5px',
};

export const input: SxProps<Theme> = {
width: '344px',
};

export const divider: SxProps<Theme> = {
borderColor: 'backgroundDark.600',
height: '46px',
};

export const button: SxProps<Theme> = {
width: '135px',
height: '48px',
borderRadius: '8px',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React, { FC, useCallback, useState } from 'react';
import {
BarsArrowDownIcon,
BarsArrowUpIcon,
} from '@heroicons/react/24/outline';
import { Box, Divider } from '@mui/material';
import { Form, Formik } from 'formik';

import Button from '@/components/common/ui/button-mui';
import { ButtonSize } from '@/components/common/ui/button-mui/types';
import { Input, InputSize, InputType } from '@/components/common/ui/form';
import {
IconButtonColor,
IconButtonShape,
} from '@/components/common/ui/icon-button';
import IconButton from '@/components/common/ui/icon-button-mui';
import { IconButtonSize } from '@/components/common/ui/icon-button-mui/types';
import { initialValues } from '@/components/pages/admin/teachers-admin-page/components/teachers-admin-search/constants';
import { AdminSearchFormFields } from '@/components/pages/admin/teachers-admin-page/components/teachers-admin-search/types';

import * as styles from './TeachersAdminSearch.styles';

export interface TeachersAdminSearchProps {
onSubmit: (values: AdminSearchFormFields) => void;
}

const TeachersAdminSearch: FC<TeachersAdminSearchProps> = ({ onSubmit }) => {
const [order, setOrder] = useState<'asc' | 'desc'>('asc');
const handleFormSubmit = useCallback(
(values: AdminSearchFormFields) => {
onSubmit({ ...values, order });
},
[onSubmit, order],
);

const handleOrderChange = (values: AdminSearchFormFields) => {
setOrder(prevOrder => (prevOrder === 'asc' ? 'desc' : 'asc'));
handleFormSubmit(values);
};

return (
<Formik initialValues={initialValues} onSubmit={handleFormSubmit}>
{({ values }) => (
<Form>
<Box sx={styles.header}>
<Box sx={styles.form}>
<Box>
<Input
value={values.search}
onChange={() => onSubmit(values)}
size={InputSize.LARGE}
type={InputType.SEARCH}
width={344}
name="search"
placeholder="Пошук"
showRemark={false}
/>
</Box>
<Divider orientation="vertical" sx={styles.divider} />
<Box>
<IconButton
onClick={() => handleOrderChange(values)}
shape={IconButtonShape.SQUARE}
color={IconButtonColor.SECONDARY}
size={IconButtonSize.LARGE}
icon={
values.order === 'asc' ? (
<BarsArrowDownIcon />
) : (
<BarsArrowUpIcon />
)
}
/>
</Box>
</Box>
<Button
size={ButtonSize.MEDIUM}
sx={styles.button}
text="Створити"
href="/admin/teachers/create"
/>
</Box>
</Form>
)}
</Formik>
);
};

export default TeachersAdminSearch;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { DropDownOption } from '@/components/common/ui/form/dropdown/types';
import { AdminSearchFormFields } from '@/components/pages/admin/teachers-admin-page/components/teachers-admin-search/types';

export const initialValues: AdminSearchFormFields = {
search: '',
sort: 'lastName',
order: 'asc',
};

export const tags: DropDownOption[] = [
{
label: 'Лекції',
id: 'lecture',
},
{
label: 'Практики',
id: 'practice',
},
{
label: 'Лабораторні',
id: 'laboratory',
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './TeachersAdminSearch';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface AdminSearchFormFields {
search: string;
order: 'desc' | 'asc';
sort: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { SxProps, Theme } from '@mui/material/styles';
Loading