This repository has been archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d7f0ac
commit 05e005a
Showing
8 changed files
with
205 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/components/pages/admin/teachers-admin-page/TeachersAdminPage.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import { SxProps, Theme } from '@mui/material/styles'; |
32 changes: 32 additions & 0 deletions
32
src/components/pages/admin/teachers-admin-page/TeachersAdminPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { FC, useEffect, useState } from 'react'; | ||
import { Box } from '@mui/material'; | ||
|
||
import TeachersTable from '@/components/pages/admin/teachers-admin-page/components/teachers-table'; | ||
import teachersApi from '@/lib/api/teacher/TeacherAPI'; | ||
import { GetTeachersResponse } from '@/lib/api/teacher/types/GetTeachersResponse'; | ||
|
||
import * as styles from './TeachersAdminPage.styles'; | ||
|
||
const TeachersAdminPage: FC = () => { | ||
const [teachers, setTeachers] = useState<GetTeachersResponse>(); | ||
|
||
useEffect(() => { | ||
try { | ||
const result = teachersApi.getAll(); | ||
result.then(data => setTeachers(data)); | ||
console.log(teachers); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}, [teachers]); | ||
|
||
console.log(teachers); | ||
|
||
return ( | ||
<Box sx={{ p: '20px 16px 0 16px' }}> | ||
<TeachersTable teachers={teachers?.teachers} /> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default TeachersAdminPage; |
31 changes: 31 additions & 0 deletions
31
...ponents/pages/admin/teachers-admin-page/components/teachers-table/TeachersTable.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { SxProps, Theme } from '@mui/material/styles'; | ||
|
||
export const headItem: SxProps<Theme> = { | ||
typography: 'body1Bold', | ||
color: 'white.main', | ||
borderBottom: '1px solid', | ||
borderColor: 'backgroundDark.400', | ||
}; | ||
|
||
export const bodyItem: SxProps<Theme> = { | ||
typography: 'body1Medium', | ||
color: 'white.main', | ||
borderBottom: '1px solid', | ||
borderColor: 'backgroundDark.400', | ||
}; | ||
|
||
export const tag: SxProps<Theme> = { | ||
typography: 'body1Medium', | ||
color: 'white.main', | ||
}; | ||
|
||
export const tableColumn: SxProps<Theme> = { | ||
flexDirection: 'row', | ||
gap: '8px', | ||
alignItems: 'center', | ||
}; | ||
|
||
export const button: SxProps<Theme> = { | ||
borderRadius: '8px', | ||
width: '157px', | ||
}; |
133 changes: 133 additions & 0 deletions
133
src/components/pages/admin/teachers-admin-page/components/teachers-table/TeachersTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import React, { FC } from 'react'; | ||
import { PencilSquareIcon } from '@heroicons/react/24/solid'; | ||
import { | ||
Avatar, | ||
Stack, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableRow, | ||
Typography, | ||
} from '@mui/material'; | ||
|
||
import Button from '@/components/common/ui/button-mui'; | ||
import { | ||
ButtonSize, | ||
ButtonVariant, | ||
} from '@/components/common/ui/button-mui/types'; | ||
import { TrashBucketButton } from '@/components/common/ui/icon-button-mui/variants'; | ||
import Tag from '@/components/common/ui/tag'; | ||
import { | ||
TagColor, | ||
TagSize, | ||
TagVariant, | ||
} from '@/components/common/ui/tag/types'; | ||
import TeacherAPI from '@/lib/api/teacher/TeacherAPI'; | ||
import mergeSx from '@/lib/utils/MergeSxStylesUtil'; | ||
import { Teacher } from '@/types/teacher'; | ||
|
||
import * as styles from './TeachersTable.styles'; | ||
|
||
interface TeachersAdminSearchProps { | ||
teachers?: Omit<Teacher, 'role'>[]; | ||
} | ||
|
||
const TeachersTable: FC<TeachersAdminSearchProps> = ({ teachers }) => { | ||
const deleteTeacher = async (id: string) => { | ||
try { | ||
await TeacherAPI.delete(id); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}; | ||
|
||
return ( | ||
<Table> | ||
<TableHead> | ||
<TableCell sx={mergeSx(styles.headItem, { minWidth: '574px' })}> | ||
Викладач | ||
</TableCell> | ||
<TableCell sx={styles.headItem}>Кафедри</TableCell> | ||
<TableCell sx={styles.headItem}>Теги</TableCell> | ||
<TableCell sx={styles.headItem} /> | ||
</TableHead> | ||
<TableBody> | ||
{teachers && | ||
teachers.map((teacher, index) => ( | ||
<TableRow key={index}> | ||
<TableCell sx={styles.bodyItem}> | ||
<Stack sx={styles.tableColumn}> | ||
<Avatar src={teacher.avatar} sx={{ width: 36, height: 36 }} /> | ||
<Typography sx={{ ml: '16px' }}> | ||
{teacher.lastName} {teacher.firstName[0]}.{' '} | ||
{teacher.middleName[0]}. | ||
</Typography> | ||
</Stack> | ||
</TableCell> | ||
<TableCell sx={styles.bodyItem}> | ||
<Stack sx={styles.tableColumn}> | ||
<Tag | ||
text="ОТ" | ||
variant={TagVariant.OUTLINE} | ||
color={TagColor.VIOLET} | ||
size={TagSize.SMALL} | ||
sx={styles.tag} | ||
/> | ||
<Tag | ||
text="ІПІ" | ||
variant={TagVariant.OUTLINE} | ||
color={TagColor.ORANGE} | ||
size={TagSize.SMALL} | ||
sx={styles.tag} | ||
/> | ||
</Stack> | ||
</TableCell> | ||
<TableCell sx={styles.bodyItem}> | ||
<Stack sx={styles.tableColumn}> | ||
<Tag | ||
text="Лекції" | ||
variant={TagVariant.FILL} | ||
color={TagColor.VIOLET} | ||
size={TagSize.SMALL} | ||
sx={styles.tag} | ||
/> | ||
<Tag | ||
text="Практики" | ||
variant={TagVariant.FILL} | ||
color={TagColor.ORANGE} | ||
size={TagSize.SMALL} | ||
sx={styles.tag} | ||
/> | ||
<Tag | ||
text="Лабораторні" | ||
variant={TagVariant.FILL} | ||
color={TagColor.INDIGO} | ||
size={TagSize.SMALL} | ||
sx={styles.tag} | ||
/> | ||
</Stack> | ||
</TableCell> | ||
<TableCell sx={styles.bodyItem}> | ||
<Stack sx={styles.tableColumn}> | ||
<Button | ||
href={`/admin/teachers/${teacher.id}`} | ||
text="Редагувати" | ||
variant={ButtonVariant.OUTLINE} | ||
startIcon={<PencilSquareIcon />} | ||
size={ButtonSize.SMALL} | ||
sx={styles.button} | ||
/> | ||
<TrashBucketButton | ||
onClick={() => deleteTeacher(teacher.id)} | ||
/> | ||
</Stack> | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
); | ||
}; | ||
|
||
export default TeachersTable; |
1 change: 1 addition & 0 deletions
1
src/components/pages/admin/teachers-admin-page/components/teachers-table/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './TeachersTable'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './TeachersAdminPage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters