+//
+//
{lessonName}
+//
+//
+//
+//
+// Окутуучу:
+// {teacherName}
+// {teacherLastName}
+//
+//
+//
+// Тип:
+// {lessonType}
+//
+// {
+// //
+//
+// // Курска өтүү ->
+// }
+//
+//
+//
+
+//
+// );
+// }
+
+'use client';
+import { itemsCourseInfo } from '@/services/studentMain';
+import Link from 'next/link';
+import { Button } from 'primereact/button';
+import React from 'react';
+
+export default function ItemCard({
+ lessonName,
+ streams,
+ connection
+}: {
+ lessonName: string;
+ streams: { teacher?: { name: string; last_name?: string }; subject_type_name?: { name_kg: string } }[];
+ connection: { id: number; course_id: number; id_myedu_stream: number }[];
+}) {
+ console.log('conn',connection);
+
+ return (
+
+
+
{lessonName}
+
+
+
+ {streams.map((stream, idx) => (
+
+
+ Окутуучу:
+ {stream.teacher?.name}
+ {stream.teacher?.last_name}
+
+
+
+ Тип:
+ {stream.subject_type_name?.short_name_kg}
+
+ {connection.map((item) => {
+ if (item.id_myedu_stream === stream.id) {
+ return
;
+ }
+ })}
+
+
+ ))}
+
+
+ );
+}
diff --git a/app/components/cards/LessonCard.tsx b/app/components/cards/LessonCard.tsx
new file mode 100644
index 00000000..6324c51a
--- /dev/null
+++ b/app/components/cards/LessonCard.tsx
@@ -0,0 +1,107 @@
+import Redacting from '../popUp/Redacting';
+import { getRedactor } from '@/utils/getRedactor';
+import { getConfirmOptions } from '@/utils/getConfirmOptions';
+import { Button } from 'primereact/button';
+import { faPlay} from "@fortawesome/free-solid-svg-icons";
+import MyFontAwesome from '../MyFontAwesome';
+
+export default function LessonCard({
+ status,
+ onSelected,
+ onDelete,
+ cardValue,
+ cardBg,
+ typeColor,
+ type,
+ lessonDate,
+ urlForPDF
+}: {
+ status: string;
+ onSelected?: (id: number, type: string) => void;
+ onDelete?: (id: number) => void;
+ cardValue: { title: string; id: number; desctiption?: string; type?: string; photo?: string };
+ cardBg: string;
+ type: { typeValue: string; icon: string };
+ typeColor: string;
+ lessonDate: string;
+ urlForPDF: ()=> void;
+}) {
+
+ const toSentPDF = () => {
+ console.log('privet ');
+ urlForPDF();
+ }
+
+ const cardHeader =
+ type.typeValue === 'video' && status === 'working' ? (
+
+ ) : (
+
+
+
+ );
+
+ const videoPreviw =
+ type.typeValue === 'video' && status === 'working' ? (
+
+

+
+ ) : type.typeValue === 'video' && status === 'student' ? (
+
+
+
+ {/* Волна */}
+ {/*
*/}
+
+ {/* Иконка-кнопка */}
+
+
+
+
+
+

+
+ ) : ''
+
+ const btnLabel = type.typeValue === 'doc' && status === 'working' ? 'Көчүрүү' : type.typeValue === 'doc' && status === 'student' ? 'Ачуу' : type.typeValue === 'link' ? 'Өтүү' : '';
+
+ return (
+
+ {type.typeValue === 'link' &&
}
+
+
{status === 'working' && }
+ {cardHeader}
+
+
+
+ {/*
{!cardValue.photo &&

}
*/}
+
{cardValue.title}
+
{cardValue?.desctiption && cardValue.desctiption} lore10lfkjslk
+ {status === 'working' && type.typeValue !== 'video' && (
+
+
+ {lessonDate}
+
+ )}
+
+
+ {/* video preview */}
+ {videoPreviw}
+
+ {/* button */}
+ {btnLabel &&
}
+
+
+ );
+}
diff --git a/app/components/cards/PrototypeCard.tsx b/app/components/cards/PrototypeCard.tsx
new file mode 100644
index 00000000..22855f12
--- /dev/null
+++ b/app/components/cards/PrototypeCard.tsx
@@ -0,0 +1,20 @@
+import React from 'react';
+import MySkeleton from '../skeleton/MySkeleton';
+
+export default function PrototypeCard({ value }: { value: string }) {
+
+ return (
+
+
+
+
+
+
+
+
+
+
{value ? value : }
+
+
+ );
+}
diff --git a/app/components/lessons/LessonTyping.tsx b/app/components/lessons/LessonTyping.tsx
new file mode 100644
index 00000000..bf6d5fcd
--- /dev/null
+++ b/app/components/lessons/LessonTyping.tsx
@@ -0,0 +1,897 @@
+'use client';
+
+import { LayoutContext } from '@/layout/context/layoutcontext';
+import { Button } from 'primereact/button';
+import { FileUpload } from 'primereact/fileupload';
+import { InputText } from 'primereact/inputtext';
+import React, { useContext, useEffect, useState } from 'react';
+import LessonCard from '../cards/LessonCard';
+import { getToken } from '@/utils/auth';
+import { addLesson, deleteLesson, fetchLesson, fetchVideoType, updateLesson } from '@/services/courses';
+import useErrorMessage from '@/hooks/useErrorMessage';
+import FormModal from '../popUp/FormModal';
+import { useForm } from 'react-hook-form';
+import { yupResolver } from '@hookform/resolvers/yup';
+import { lessonStateType } from '@/types/lessonStateType';
+import { lessonSchema } from '@/schemas/lessonSchema';
+import { lessonType } from '@/types/lessonType';
+import { NotFound } from '../NotFound';
+import { EditableLesson } from '@/types/editableLesson';
+import { Dropdown } from 'primereact/dropdown';
+import PDFViewer from '../PDFBook';
+import { useMediaQuery } from '@/hooks/useMediaQuery';
+import { useRouter } from 'next/navigation';
+
+export default function LessonTyping({ mainType, courseId, lessonId }: { mainType: string; courseId: string | null; lessonId: string | null }) {
+ // types
+ interface editingType {
+ key: string;
+ file: string;
+ url: string;
+ link: string;
+ video_type_id?: number | null;
+ }
+
+ interface videoType {
+ name: string;
+ status: boolean;
+ id: number;
+ }
+
+ interface videoInsideType {
+ id: number;
+ is_link: boolean;
+ short_title: string;
+ title: string;
+ }
+ // validate
+ const {
+ setValue,
+ formState: { errors }
+ } = useForm({
+ resolver: yupResolver(lessonSchema),
+ mode: 'onChange'
+ });
+
+ const media = useMediaQuery('(max-width: 640px)');
+ const router = useRouter();
+
+ // doc
+ const [documents, setDocuments] = useState([]);
+ const [docValue, setDocValue] = useState
({
+ title: '',
+ description: '',
+ file: null,
+ url: '',
+ video_link: ''
+ });
+ const [docShow, setDocShow] = useState(false);
+ const [urlPDF, setUrlPDF] = useState('');
+ const [PDFVisible, setPDFVisible] = useState(false);
+
+ // links
+ const [links, setLinks] = useState([]);
+ const [linksValue, setLinksValue] = useState({
+ title: '',
+ description: '',
+ file: null,
+ url: '',
+ video_link: ''
+ });
+ const [linksShow, setLinksShow] = useState(false);
+
+ // videos
+ const [video, setVideo] = useState([]);
+ const [selectedCity, setSelectedCity] = useState({ name: '', status: true, id: 1 });
+ const [videoSelect, setVideoSelect] = useState([]);
+ const [videoTypes, setVideoTypes] = useState([]);
+ const [videoValue, setVideoValue] = useState({
+ title: '',
+ description: '',
+ file: null,
+ url: '',
+ video_link: ''
+ });
+ const [videoShow, setVideoShow] = useState(false);
+
+ // auxiliary
+ const showError = useErrorMessage();
+ const { setMessage } = useContext(LayoutContext);
+ const [selectId, setSelectId] = useState(null);
+ const [selectType, setSelectType] = useState('');
+ const [visible, setVisisble] = useState(false);
+ const [editingLesson, setEditingLesson] = useState(null);
+
+ // functions
+ const handleUpdate = () => {
+ if (selectType === 'doc') {
+ handleUpdateLesson();
+ } else if (selectType === 'url') {
+ handleUpdateLink();
+ } else if (selectType === 'video') {
+ handleUpdateVideo();
+ }
+ };
+
+ const selectedForEditing = (id: number, type: string) => {
+ console.log('Открытие окна... ', id, type);
+
+ setSelectId(id);
+ setSelectType(type);
+ editing(type, id);
+ setVisisble(true);
+ };
+
+ // Предоставляю данные из сервера для изменения
+ const editing = async (type: string, selected: number) => {
+ console.log(type, selected);
+
+ const token = getToken('access_token');
+ const data = await fetchLesson(type, courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null);
+ console.log(data);
+
+ const lesson: editingType =
+ type === 'doc'
+ ? { key: 'documents', file: 'document', url: '', link: '', video_type_id: 1 }
+ : type === 'url'
+ ? { key: 'links', file: '', url: 'url', link: '', video_type_id: 1 }
+ : type === 'video'
+ ? { key: 'videos', file: '', url: '', link: 'link', video_type_id: 1 }
+ : { key: '', file: '', url: '', link: '', video_type_id: 1 };
+ // console.log(lesson);
+ // console.log(data[lesson.key]);
+
+ if (data.success) {
+ if (data[lesson.key]) {
+ const arr = data[lesson.key].find((item: lessonType) => item.id === selected);
+ console.log(arr);
+
+ setEditingLesson({
+ title: arr.title,
+ description: arr?.description,
+ document: arr[lesson.file],
+ url: arr[lesson.url],
+ video_link: arr[lesson.link],
+ video_type_id: arr?.video_type_id
+ });
+ }
+ }
+ };
+
+ const clearValues = () => {
+ setLinksValue({ title: '', description: '', file: null, url: '', video_link: '' });
+ setEditingLesson(null);
+ setSelectId(null);
+ setSelectType('');
+ };
+
+ // DOC SECTION
+
+ const sentToPDF = (url) => {
+ console.log(url);
+ setUrlPDF(url);
+ if(media){
+ router.push(`/pdf/${url}`);
+ } else {
+ setPDFVisible(true);
+ }
+ };
+
+ const documentView = (
+ <>
+
+
setPDFVisible(false)}>
+
+
+ >
+ );
+
+ const docSection = () => {
+ return (
+
+ {PDFVisible ? (
+ documentView
+ ) : (
+ <>
+
+
{}}
+ accept="application/pdf"
+ onSelect={(e) =>
+ setDocValue((prev) => ({
+ ...prev,
+ file: e.files[0]
+ }))
+ }
+ />
+
+ {
+ setDocValue((prev) => ({ ...prev, title: e.target.value }));
+ setValue('title', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {errors.title?.message}
+
+ setDocValue((prev) => ({ ...prev, description: e.target.value }))} className="w-full" />
+
+ {/* */}
+
+
+
+
+
+ {docShow ? (
+
+ ) : (
+ documents.map((item: lessonType) => (
+ <>
+ selectedForEditing(id, type)}
+ onDelete={(id: number) => handleDeleteDoc(id)}
+ cardValue={{ title: item?.title, id: item.id, type: 'doc' }}
+ cardBg={'#ddc4f51a'}
+ type={{ typeValue: 'doc', icon: 'pi pi-file' }}
+ typeColor={'var(--mainColor)'}
+ lessonDate={'xx-xx'}
+ urlForPDF={() => sentToPDF(item.document)}
+ />
+ >
+ ))
+ )}
+
+
+ >
+ )}
+
+ );
+ };
+
+ // fetch document
+ const handleFetchDoc = async () => {
+ // skeleton = false
+
+ const data = await fetchLesson('doc', courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null);
+
+ if (data?.success) {
+ if (data.documents) {
+ // Присваиваю себе. Для отображения
+ setDocValue({ title: '', description: '', file: null, url: '', video_link: '' });
+ setDocuments(data.documents);
+ setDocShow(false);
+ } else {
+ setDocShow(true);
+ }
+ } else {
+ setDocShow(true);
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Проблема с соединением. Повторите заново' }
+ });
+ if (data?.response?.status) {
+ showError(data.response.status);
+ }
+ // skeleton = false
+ }
+ };
+
+ // add document
+ const handleAddDoc = async () => {
+ const token = getToken('access_token');
+
+ const data = await addLesson('doc', token, courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null, docValue, 0);
+
+ if (data.success) {
+ handleFetchDoc();
+ setMessage({
+ state: true,
+ value: { severity: 'success', summary: 'Ийгиликтүү Кошулдуу!', detail: '' }
+ });
+ } else {
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Ошибка при при добавлении' }
+ });
+ if (data.response.status) {
+ showError(data.response.status);
+ }
+ }
+ };
+
+ // update document
+ const handleUpdateLesson = async () => {
+ const token = getToken('access_token');
+
+ const data = await updateLesson('doc', token, courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null, Number(selectId), editingLesson);
+ console.log(data);
+
+ if (data?.success) {
+ handleFetchDoc();
+ clearValues();
+ setMessage({
+ state: true,
+ value: { severity: 'success', summary: 'Ийгиликтүү өзгөртүлдү!', detail: '' }
+ });
+ } else {
+ setDocValue({ title: '', description: '', file: null, url: '', video_link: '' });
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Ошибка при при изменении урока' }
+ });
+ if (data?.response?.status) {
+ showError(data.response.status);
+ }
+ }
+ };
+
+ // delete document
+ const handleDeleteDoc = async (id: number) => {
+ const token = getToken('access_token');
+ const data = await deleteLesson('doc', Number(courseId), Number(lessonId), id);
+
+ if (data.success) {
+ handleFetchDoc();
+ setMessage({
+ state: true,
+ value: { severity: 'success', summary: 'Ийгиликтүү өчүрүлдү!', detail: '' }
+ });
+ } else {
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Ошибка при при удалении' }
+ });
+ if (data.response.status) {
+ showError(data.response.status);
+ }
+ }
+ };
+
+ // LINKS SECTION
+
+ const linkSection = () => {
+ return (
+
+
+
{
+ setLinksValue((prev) => ({ ...prev, url: e.target.value }));
+ setValue('usefulLink', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {errors.usefulLink?.message}
+
+ {
+ setLinksValue((prev) => ({ ...prev, title: e.target.value }));
+ setValue('title', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {errors.title?.message}
+
+ setLinksValue((prev) => ({ ...prev, description: e.target.value }))} className="w-full" />
+
+
+
+
+
+
+
+ {linksShow ? (
+
+ ) : (
+ links.map((item: lessonType) => (
+ <>
+ selectedForEditing(id, type)}
+ onDelete={(id: number) => handleDeleteLink(id)}
+ cardValue={{ title: item.title, id: item.id, desctiption: item?.description, type: 'url', photo: item?.photo }}
+ cardBg={'#7bb78112'}
+ type={{ typeValue: 'link', icon: 'pi pi-link' }}
+ typeColor={'var(--mainColor)'}
+ lessonDate={'xx-xx'}
+ />
+ >
+ ))
+ )}
+
+
+
+ );
+ };
+
+ // fetch link
+ const handleFetchLink = async () => {
+ // skeleton = false
+ const data = await fetchLesson('url', courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null);
+ console.log(data);
+
+ if (data?.success) {
+ if (data.links) {
+ // Присваиваю себе. Для отображения
+ setLinksValue({ title: '', description: '', file: null, url: '', video_link: '' });
+ setLinks(data.links);
+ setLinksShow(false);
+ } else {
+ setLinksShow(true);
+ }
+ } else {
+ setLinksShow(true);
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Проблема с соединением. Повторите заново' }
+ });
+ if (data?.response?.status) {
+ showError(data.response.status);
+ }
+ // skeleton = false
+ }
+ };
+
+ // add link
+ const handleAddLink = async () => {
+ const token = getToken('access_token');
+
+ const data = await addLesson('url', token, courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null, linksValue, 0);
+ console.log(data);
+
+ if (data.success) {
+ handleFetchLink();
+ setMessage({
+ state: true,
+ value: { severity: 'success', summary: 'Ийгиликтүү Кошулдуу!', detail: '' }
+ });
+ } else {
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Ошибка при при добавлении' }
+ });
+ if (data.response.status) {
+ showError(data.response.status);
+ }
+ }
+ };
+
+ // delete link
+ const handleDeleteLink = async (id: number) => {
+ const data = await deleteLesson('url', Number(courseId), Number(lessonId), id);
+
+ if (data.success) {
+ handleFetchLink();
+ setMessage({
+ state: true,
+ value: { severity: 'success', summary: 'Ийгиликтүү өчүрүлдү!', detail: '' }
+ });
+ } else {
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Ошибка при при удалении' }
+ });
+ if (data.response.status) {
+ showError(data.response.status);
+ }
+ }
+ };
+
+ // update link
+ const handleUpdateLink = async () => {
+ const token = getToken('access_token');
+
+ const data = await updateLesson('url', token, courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null, Number(selectId), editingLesson);
+ console.log(data);
+
+ if (data.success) {
+ handleFetchLink();
+ clearValues();
+ setMessage({
+ state: true,
+ value: { severity: 'success', summary: 'Ийгиликтүү өзгөртүлдү!', detail: '' }
+ });
+ } else {
+ setLinksValue({ title: '', description: '', file: null, url: '', video_link: '' });
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Ошибка при при изменении урока' }
+ });
+ if (data.response.status) {
+ showError(data.response.status);
+ }
+ }
+ };
+
+ // VIDEO SECTIONS
+ const toggleVideoType = (e: videoType) => {
+ console.log(e);
+
+ setSelectedCity(e);
+ setVideoValue({ title: '', description: '', file: null, url: '', video_link: '' });
+ };
+
+ const videoSection = () => {
+ return (
+
+
+
{
+ toggleVideoType(e.value);
+ }}
+ options={videoSelect}
+ optionLabel="name"
+ placeholder="Танданыз"
+ className="w-[213px] sm:w-full md:w-14rem"
+ />
+
+ {selectedCity?.status ? (
+
+ {
+ setVideoValue((prev) => ({ ...prev, video_link: e.target.value }));
+ setValue('usefulLink', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {errors.usefulLink?.message}
+
+ ) : (
+
{}}
+ accept="video/"
+ onSelect={(e) =>
+ setVideoValue((prev) => ({
+ ...prev,
+ file: e.files[0]
+ }))
+ }
+ />
+ )}
+
+
+
+
{
+ setVideoValue((prev) => ({ ...prev, title: e.target.value }));
+ setValue('title', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {errors.title?.message}
+
+ setVideoValue((prev) => ({ ...prev, description: e.target.value }))} className="w-full" />
+
+
+
+
+
+
+
+ {/* selectedForEditing(id, type)}
+ onDelete={(id: number) => handleDeleteVideo(id)}
+ cardValue={{ title: 'item.title', id: 8, desctiption: 'item?.description', type: '', photo: ''}}
+ cardBg={'#fff'}
+ type={{ typeValue: 'Лекция', icon: 'pi pi-lecture' }}
+ typeColor={'var(--mainColor)'}
+ lessonDate={'xx-xx'}
+ /> */}
+
+ {videoShow ? (
+
+ ) : (
+ video.map((item: lessonType) => (
+ <>
+ {/* {
+ status: 'student',
+ description: item.desctiption,
+ lessonType: item.role? // lecture/lab
+ } */}
+ selectedForEditing(id, type)}
+ onDelete={(id: number) => handleDeleteVideo(id)}
+ cardValue={{ title: item.title, id: item.id, desctiption: item?.description, type: 'video', photo: item?.photo }}
+ cardBg={'#f1b1b31a'}
+ type={{ typeValue: 'video', icon: 'pi pi-video' }}
+ typeColor={'var(--mainColor)'}
+ lessonDate={'xx-xx'}
+ />
+ >
+ ))
+ )}
+
+
+
+ );
+ };
+
+ const handleVideoType = async () => {
+ const data = await fetchVideoType();
+ console.log(data);
+
+ if (data && Array.isArray(data)) {
+ setVideoTypes(data);
+ }
+ };
+
+ // fetch video
+ const handleFetchVideo = async () => {
+ // skeleton = false
+ const data = await fetchLesson('video', courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null);
+ // console.log(data);
+
+ if (data?.success) {
+ if (data.videos) {
+ setVideoValue({ title: '', description: '', file: null, url: '', video_link: '' });
+ setVideo(data.videos);
+ setVideoShow(false);
+ } else {
+ setVideoShow(true);
+ }
+ } else {
+ setVideoShow(true);
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Проблема с соединением. Повторите заново' }
+ });
+ if (data?.response?.status) {
+ showError(data.response.status);
+ }
+ // skeleton = false
+ }
+ };
+
+ // add vieo
+ const handleAddVideo = async () => {
+ const token = getToken('access_token');
+
+ const data = await addLesson('video', token, courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null, videoValue, selectedCity?.id);
+ console.log(data);
+
+ if (data.success) {
+ handleFetchVideo();
+ setMessage({
+ state: true,
+ value: { severity: 'success', summary: 'Ийгиликтүү Кошулдуу!', detail: '' }
+ });
+ } else {
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Ошибка при при добавлении' }
+ });
+ if (data.response.status) {
+ showError(data.response.status);
+ }
+ }
+ };
+
+ // update video
+ const handleUpdateVideo = async () => {
+ const token = getToken('access_token');
+
+ const data = await updateLesson('video', token, courseId ? Number(courseId) : null, lessonId ? Number(lessonId) : null, Number(selectId), editingLesson);
+
+ if (data.success) {
+ handleFetchVideo();
+ clearValues();
+ setMessage({
+ state: true,
+ value: { severity: 'success', summary: 'Ийгиликтүү өзгөртүлдү!', detail: '' }
+ });
+ } else {
+ setVideoValue({ title: '', description: '', file: null, url: '', video_link: '' });
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Ошибка при изменении урока' }
+ });
+ if (data.response.status) {
+ showError(data.response.status);
+ }
+ }
+ };
+
+ // delete video
+ const handleDeleteVideo = async (id: number) => {
+ const data = await deleteLesson('video', Number(courseId), Number(lessonId), id);
+
+ if (data.success) {
+ handleFetchVideo();
+ setMessage({
+ state: true,
+ value: { severity: 'success', summary: 'Ийгиликтүү өчүрүлдү!', detail: '' }
+ });
+ } else {
+ setMessage({
+ state: true,
+ value: { severity: 'error', summary: 'Ошибка', detail: 'Ошибка при при удалении' }
+ });
+ if (data.response.status) {
+ showError(data.response.status);
+ }
+ }
+ };
+
+ // USEEFFECTS
+
+ useEffect(() => {
+ if (mainType === 'doc') handleFetchDoc();
+ if (mainType === 'link') handleFetchLink();
+ if (mainType === 'video') {
+ handleFetchVideo();
+ handleVideoType();
+ }
+ }, []);
+
+ useEffect(() => {
+ console.log('selected id ', selectId);
+ }, [selectId]);
+
+ useEffect(() => {
+ links.length < 1 ? setLinksShow(true) : setLinksShow(false);
+ documents.length < 1 ? setDocShow(true) : setDocShow(false);
+ }, [links, documents]);
+
+ useEffect(() => {
+ console.log(videoTypes);
+
+ if (videoTypes) {
+ const forSelect = videoTypes.map((item) => {
+ return { name: item.title, status: item.is_link, id: item.id };
+ });
+
+ setVideoSelect(forSelect);
+ setSelectedCity(forSelect[0]);
+ }
+ }, [videoTypes]);
+
+ // useEffect(() => {
+ // console.log(videoSelect);
+ // }, [videoSelect]);
+
+ // useEffect(() => {
+ // console.log(selectedCity);
+ // }, [selectedCity]);
+
+ return (
+
+
+
+
+ {selectType === 'doc' ? (
+ <>
+
{}}
+ accept="application/pdf"
+ onSelect={(e) => {
+ if (e.files[0]) setEditingLesson((prev) => prev && { ...prev, file: e.files[0] });
+ }}
+ />
+ {String(editingLesson?.document)}
+ {
+ setEditingLesson((prev) => prev && { ...prev, title: e.target.value });
+ setValue('title', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {errors.title?.message}
+ setEditingLesson((prev) => prev && { ...prev, description: e.target.value })} className="w-full" />
+ >
+ ) : selectType === 'url' ? (
+ <>
+ {
+ setEditingLesson((prev) => prev && { ...prev, url: e.target.value });
+ setValue('usefulLink', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {
+ setEditingLesson((prev) => prev && { ...prev, title: e.target.value });
+ setValue('title', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {errors.title?.message}
+ setEditingLesson((prev) => prev && { ...prev, description: e.target.value })} className="w-full" />
+ >
+ ) : selectType === 'video' ? (
+ <>
+ {editingLesson?.video_type_id ? (
+
+ {
+ setEditingLesson((prev) => prev && { ...prev, video_link: e.target.value });
+ setValue('usefulLink', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {errors.usefulLink?.message}
+
+ ) : (
+ <>
+ {}}
+ accept="video/"
+ onSelect={(e) =>
+ setEditingLesson(
+ (prev) =>
+ prev && {
+ ...prev,
+ file: e.files[0]
+ }
+ )
+ }
+ />
+ {String(editingLesson?.video_link)}
+ >
+ )}
+ {
+ setEditingLesson((prev) => prev && { ...prev, title: e.target.value });
+ setValue('title', e.target.value, { shouldValidate: true });
+ }}
+ />
+ {errors.title?.message}
+ setEditingLesson((prev) => prev && { ...prev, description: e.target.value })} className="w-full" />
+ >
+ ) : (
+ ''
+ )}
+
+
+
+
+ {mainType === 'doc' && docSection()}
+ {mainType === 'link' && linkSection()}
+ {mainType === 'video' && videoSection()}
+
+ );
+}
diff --git a/app/components/loading/GlobalLoading.tsx b/app/components/loading/GlobalLoading.tsx
new file mode 100644
index 00000000..65be1f01
--- /dev/null
+++ b/app/components/loading/GlobalLoading.tsx
@@ -0,0 +1,27 @@
+import React, { useContext } from 'react';
+import { LayoutContext } from '@/layout/context/layoutcontext';
+
+export default function GlobalLoading() {
+ const { globalLoading } = useContext(LayoutContext);
+
+ if(globalLoading){
+ return (
+ <>
+
+ >
+ );
+ }
+}
diff --git a/app/components/messages/Message.tsx b/app/components/messages/Message.tsx
new file mode 100644
index 00000000..42baa0a2
--- /dev/null
+++ b/app/components/messages/Message.tsx
@@ -0,0 +1,32 @@
+'use client';
+
+import { Toast } from 'primereact/toast';
+import { Toast as ToastRef} from 'primereact/toast';
+import { useContext, useEffect, useRef } from 'react';
+import { LayoutContext } from '@/layout/context/layoutcontext';
+
+type SeverityType = 'success' | 'info' | 'warn' | 'error' | 'secondary' | 'contrast';
+
+export default function Message() {
+ const { message } = useContext(LayoutContext);
+ const toast = useRef(null);
+
+ const showError = () => {
+ toast.current?.show({ severity: message.value.severity as SeverityType, summary: message.value.summary, detail: message.value.detail, life: 3000 });
+ };
+
+ useEffect(() => {
+ const timer = setTimeout(() => {
+ showError();
+ }, 0); // откладываем до следующей итерации event loop
+
+ return () => clearTimeout(timer);
+ }, [message]);
+
+ return (
+
+ {/* */}
+
+
+ );
+}
diff --git a/app/components/popUp/ConfirmModal.tsx b/app/components/popUp/ConfirmModal.tsx
new file mode 100644
index 00000000..e003d3e3
--- /dev/null
+++ b/app/components/popUp/ConfirmModal.tsx
@@ -0,0 +1,27 @@
+'use client';
+import { confirmDialog } from 'primereact/confirmdialog';
+type ConfirmDialogOptions = {
+ message: string;
+ header?: string;
+ icon?: string;
+ defaultFocus?: 'accept' | 'reject';
+ accept?: () => void;
+ reject?: () => void;
+ acceptLabel?: string;
+ rejectLabel?: string;
+ acceptClassName?: string;
+ rejectClassName?: string;
+};
+export default function ConfirmModal({confirmVisible}: {confirmVisible: ConfirmDialogOptions}) {
+ const handleClick = () => {
+ console.log(confirmVisible);
+
+ confirmDialog(confirmVisible);
+ };
+
+ return (
+
+
+
+ );
+}
diff --git a/app/components/popUp/DocumentModal.tsx b/app/components/popUp/DocumentModal.tsx
new file mode 100644
index 00000000..31ac10cf
--- /dev/null
+++ b/app/components/popUp/DocumentModal.tsx
@@ -0,0 +1,32 @@
+'use client';
+
+import { Button } from 'primereact/button';
+import { Dialog } from 'primereact/dialog';
+import { ReactNode, useEffect } from 'react';
+
+export default function DocumentModal({children, title, fetchValue, visible, setVisible}:
+ {
+ children: ReactNode,
+ title: string,
+ fetchValue: ()=> void,
+ visible: boolean,
+ setVisible: (params: boolean)=> void,
+ }
+ ){
+
+ return (
+
+
+
+ );
+}
diff --git a/app/components/popUp/FormModal.tsx b/app/components/popUp/FormModal.tsx
new file mode 100644
index 00000000..9ec91e8d
--- /dev/null
+++ b/app/components/popUp/FormModal.tsx
@@ -0,0 +1,49 @@
+'use client';
+
+import { Button } from 'primereact/button';
+import { Dialog } from 'primereact/dialog';
+import { ReactNode, useEffect } from 'react';
+
+export default function FormModal({children, title, fetchValue, clearValues, visible, setVisible, start}:
+ {
+ children: ReactNode,
+ title: string,
+ fetchValue: ()=> void,
+ clearValues: ()=> void,
+ visible: boolean,
+ setVisible: (params: boolean)=> void,
+ start: boolean
+ }
+ ){
+
+ const footerContent = (
+
+
+ );
+
+ return (
+
+
+
+ );
+}
diff --git a/app/components/popUp/Redacting.tsx b/app/components/popUp/Redacting.tsx
new file mode 100644
index 00000000..b42664ec
--- /dev/null
+++ b/app/components/popUp/Redacting.tsx
@@ -0,0 +1,40 @@
+import { Menu } from 'primereact/menu';
+import type { Menu as MenuRef } from 'primereact/menu';
+import { MenuItem } from 'primereact/menuitem';
+import { useRef } from 'react';
+
+export default function Redacting({ redactor, textSize }: {redactor: MenuItem[], textSize: string}) {
+ const menuLeft = useRef(null);
+
+ return (
+
+ menuLeft.current?.toggle(event)} aria-controls="popup_menu_left" aria-haspopup />
+
+
+ );
+}
diff --git a/app/components/popUp/Tiered.tsx b/app/components/popUp/Tiered.tsx
new file mode 100644
index 00000000..c35ae1fa
--- /dev/null
+++ b/app/components/popUp/Tiered.tsx
@@ -0,0 +1,72 @@
+'use client';
+
+import { useRef } from 'react';
+import { Button } from 'primereact/button';
+import { TieredMenu } from 'primereact/tieredmenu';
+import type { TieredMenu as TieredMenuRef } from 'primereact/tieredmenu';
+import { useMediaQuery } from '@/hooks/useMediaQuery';
+// import type { Menu, Menu as MenuRef } from 'primereact/menu';
+
+import { MenuItem } from 'primereact/menuitem';
+
+type CustomMenuItem = Omit