62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { useTranslation } from "react-i18next";
|
|
import { lazy, Suspense } from 'react';
|
|
import { Spin } from "antd";
|
|
import useSetPageTitle from "../../Hooks/useSetPageTitle";
|
|
import { useParams } from "react-router-dom";
|
|
import { ParamsEnum } from "../../enums/params";
|
|
import { useGetAllUnit } from "../../api/unit";
|
|
import { ModalEnum } from "../../enums/Model";
|
|
import { useDeleteLesson } from "../../api/lesson";
|
|
|
|
const Table = lazy(() => import('./Table'));
|
|
const AddModalForm = lazy(() => import('./Model/AddModel'));
|
|
const EditModalForm = lazy(() => import('./Model/EditModel'));
|
|
const DeleteModels = lazy(() => import('../../Layout/Dashboard/DeleteModels'));
|
|
|
|
const TableHeader = () => {
|
|
const [t] = useTranslation();
|
|
const deleteMutation = useDeleteLesson();
|
|
|
|
const { unit_id } = useParams<ParamsEnum>();
|
|
const { data: unit } = useGetAllUnit({ show: unit_id });
|
|
const unitName = unit?.data?.name ?? "";
|
|
const SubjectName = unit?.data?.subject?.name ?? "";
|
|
|
|
console.log(unit?.data);
|
|
|
|
useSetPageTitle(
|
|
t(`page_header.subject`) +
|
|
"/" +
|
|
`${SubjectName}` +
|
|
"/" +
|
|
t(`page_title.unit`) +
|
|
"/" +
|
|
`${unitName}`
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
<div className="TableWithHeader">
|
|
<Suspense fallback={<Spin/>}>
|
|
<header>
|
|
<h6>
|
|
{t("models.lessons")} {SubjectName} {unitName}
|
|
</h6>
|
|
|
|
</header>
|
|
<Table />
|
|
<AddModalForm />
|
|
<EditModalForm />
|
|
<DeleteModels
|
|
deleteMutation={deleteMutation}
|
|
ModelEnum={ModalEnum?.LESSON_DELETE}
|
|
/>
|
|
</Suspense>
|
|
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default TableHeader;
|