feat: add documents to Lesson materials (#572)

* feat: Initial logic for the pdf upload

* feat: uploa logic, translations and ui flow complete

* chore:console log cleanup

* feat: fixed upload issue and added cancel upload button

* feat: fixing the download document ish

* feat: All done and ready for use

* feat: updated the document viewing logic

* feat: some minor refactor

* feat: added migration file

* fix: dark mode, translations, restyling,

---------

Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
Nwosu Emmanuel
2025-09-10 11:39:06 +01:00
committed by GitHub
co-authored by Rotimi Best
parent 7a77bd6c79
commit 937f1d8155
32 changed files with 1682 additions and 50 deletions
@@ -265,6 +265,7 @@ export async function getMarks(courseId) {
}
export async function fetchLesson(lessonId: Lesson['id']) {
// TODO: add documents to the query
const { data, error } = await supabase
.from('lesson')
.select(
@@ -273,6 +274,7 @@ export async function fetchLesson(lessonId: Lesson['id']) {
note,
videos,
slide_url,
documents,
call_url,
totalExercises:exercise(count),
totalComments:lesson_comment(count),
@@ -737,7 +737,9 @@
"upgrade": "Aktualisieren Sie Ihren Plan, um Videos hochzuladen",
"uploading": "Hochladen...",
"invalid_youtube": "Ungültige YouTube-Link(s)",
"invalid_link": "Ungültige Links"
"invalid_link": "Ungültige Links",
"cancel_upload": "Upload abbrechen",
"upload_cancelled": "Vom Benutzer abgebrochen hochladen"
}
},
"slide": {
@@ -753,6 +755,41 @@
"note": "Unterrichtsnotiz erstellen",
"activities": "Unterrichtsaktivitäten erstellen"
}
},
"document": {
"title": "Dokumentieren",
"add_document": "Dokument hinzufügen",
"no_document": "Noch keine Dokumente hochgeladen",
"view_document": "Dokument anzeigen",
"download": "Herunterladen",
"upload_document": "Dokument hochladen",
"upload_title": "Dokument hochladen",
"upload_description": "Laden Sie PDF-, DOCX- oder DOC -Dateien hoch. Maximale Größe: 5 MB",
"drag_drop": "Ziehen Sie Ihr Dokument hier und lassen Sie sie fallen",
"or": "oder",
"choose_file": "Datei wählen",
"cancel": "Stornieren",
"uploading": "Hochladen ...",
"upload_success": "Dokument erfolgreich hochgeladen!",
"upload_error": "Dokument nicht hochladen",
"file_type_error": "Dateityp nicht unterstützt. Bitte laden Sie PDF-, DOCX- oder DOC -Dateien hoch.",
"file_size_error": "Dateigröße zu groß. Die maximale Größe ist {Größe}.",
"type": "Typ",
"size": "Größe",
"upload_error_title": "Fehler hochladen",
"upload_error_message": "Nicht unterstütztes Dateiformat oder Upload ist fehlgeschlagen",
"upload_error_try_again": "Bitte versuchen Sie es erneut mit einer gültigen Dokumentdatei",
"try_again": "Versuchen Sie es erneut",
"cancel_upload": "Upload abbrechen",
"upload_cancelled": "Vom Benutzer abgebrochen hochladen",
"downloading": "Herunterladen ...",
"view_pdf": "PDF anzeigen",
"delete": "Löschen",
"page_of": "Seite {page} von {total}",
"loading_pdf": "PDF laden ...",
"failed_to_load_pdf": "Das PDF -Dokument konnte nicht geladen werden",
"failed_to_render_pdf": "Die PDF -Seite versäumte es, PDF -Seite zu rendern",
"use_arrow_keys": "Verwenden Sie Pfeiltasten, um zu navigieren, +/-, um zu zoomen, oder klicken Sie auf die obigen Steuerelemente. Mit der rechten Maustaste ist deaktiviert."
}
}
},
@@ -1517,4 +1554,4 @@
"average_grade": "Durchschnittsnote",
"average_grade_description": "Durchschnittsnote aller abgeschlossenen Aufgaben"
}
}
}
@@ -663,8 +663,46 @@
"upgrade": "Upgrade your plan to upload vidoes",
"uploading": "Uploading...",
"invalid_youtube": "Invalid YouTube link(s)",
"invalid_link": "Invalid link(s)"
"invalid_link": "Invalid link(s)",
"cancel_upload": "Cancel Upload",
"upload_cancelled": "Upload cancelled by user"
}
},
"document": {
"title": "Docs",
"add_document": "Add Document",
"no_document": "No documents uploaded yet",
"view_document": "View Document",
"download": "Download",
"upload_document": "Upload Document",
"upload_title": "Upload Document",
"upload_description": "Upload PDF, DOCX, or DOC files. Maximum size: 5MB",
"drag_drop": "Drag and drop your document here",
"or": "or",
"choose_file": "Choose File",
"cancel": "Cancel",
"uploading": "Uploading...",
"upload_success": "Document uploaded successfully!",
"upload_error": "Failed to upload document",
"file_type_error": "File type not supported. Please upload PDF, DOCX, or DOC files.",
"file_size_error": "File size too large. Maximum size is {size}.",
"type": "Type",
"size": "Size",
"upload_error_title": "Upload Error",
"upload_error_message": "Unsupported file format or upload failed",
"upload_error_try_again": "Please try again with a valid document file",
"try_again": "Try Again",
"cancel_upload": "Cancel Upload",
"upload_cancelled": "Upload cancelled by user",
"downloading": "Downloading...",
"view_pdf": "View PDF",
"delete": "Delete",
"page_of": "Page {page} of {total}",
"loading_pdf": "Loading PDF...",
"failed_to_load_pdf": "Failed to load PDF document",
"failed_to_render_pdf": "Failed to render PDF page",
"use_arrow_keys": "Use arrow keys to navigate, +/- to zoom, or click the controls above. Right-click is disabled."
}
},
"button_done": "Done"
@@ -737,7 +737,9 @@
"upgrade": "Actualiza tu plan para subir videos",
"uploading": "Subiendo...",
"invalid_youtube": "Enlace(s) de YouTube no válido(s)",
"invalid_link": "Enlace(s) no válido(s)"
"invalid_link": "Enlace(s) no válido(s)",
"cancel_upload": "Cancelar la carga",
"upload_cancelled": "Carga cancelada por el usuario"
}
},
"slide": {
@@ -753,6 +755,41 @@
"note": "Generar nota de lección",
"activities": "Generar actividades lectivas"
}
},
"document": {
"title": "Documento",
"add_document": "Agregar documento",
"no_document": "No hay documentos cargados todavía",
"view_document": "Ver documento",
"download": "Descargar",
"upload_document": "Cargar documento",
"upload_title": "Cargar documento",
"upload_description": "Sube archivos PDF, DOCX o DOC. Tamaño máximo: 5 MB",
"drag_drop": "Arrastre y suelte su documento aquí",
"or": "o",
"choose_file": "Elija archivo",
"cancel": "Cancelar",
"uploading": "Subiendo ...",
"upload_success": "¡Documento cargado con éxito!",
"upload_error": "No se pudo subir al documento",
"file_type_error": "Tipo de archivo no compatible. Sube archivos PDF, DOCX o DOC.",
"file_size_error": "Tamaño de archivo demasiado grande. El tamaño máximo es {tamaño}.",
"type": "Tipo",
"size": "Tamaño",
"upload_error_title": "Error de carga",
"upload_error_message": "Falló el formato de archivo o la carga no compatible",
"upload_error_try_again": "Vuelva a intentarlo con un archivo de documento válido",
"try_again": "Intentar otra vez",
"cancel_upload": "Cancelar la carga",
"upload_cancelled": "Carga cancelada por el usuario",
"downloading": "Descarga ...",
"view_pdf": "Ver PDF",
"delete": "Borrar",
"page_of": "Página {page} de {total}",
"loading_pdf": "Cargando PDF ...",
"failed_to_load_pdf": "No se pudo cargar el documento PDF",
"failed_to_render_pdf": "No se pudo renderizar la página de PDF",
"use_arrow_keys": "Use las teclas de flecha para navegar, +/- para hacer zoom o hacer clic en los controles anteriores. El clic derecho está deshabilitado."
}
}
},
@@ -1517,4 +1554,4 @@
"average_grade": "Calificación promedio",
"average_grade_description": "Calificación promedio de todas las tareas completadas"
}
}
}
@@ -737,7 +737,9 @@
"upgrade": "Mettez à niveau votre forfait pour télécharger des vidéos",
"uploading": "Téléchargement...",
"invalid_youtube": "Lien(s) YouTube invalide(s)",
"invalid_link": "Lien(s) invalide(s)"
"invalid_link": "Lien(s) invalide(s)",
"cancel_upload": "Annuler le téléchargement",
"upload_cancelled": "Télécharger annulé par l'utilisateur"
}
},
"slide": {
@@ -753,6 +755,41 @@
"note": "Générer une note de cours",
"activities": "Générer des activités de cours"
}
},
"document": {
"title": "Document",
"add_document": "Ajouter un document",
"no_document": "Aucun document encore téléchargé",
"view_document": "Afficher le document",
"download": "Télécharger",
"upload_document": "Télécharger le document",
"upload_title": "Télécharger le document",
"upload_description": "Téléchargez les fichiers PDF, DOCX ou DOC. Taille maximale: 5 Mo",
"drag_drop": "Faites glisser et déposez votre document ici",
"or": "ou",
"choose_file": "Choisir le fichier",
"cancel": "Annuler",
"uploading": "Téléchargement ...",
"upload_success": "Document téléchargé avec succès!",
"upload_error": "Échec de la téléchargement du document",
"file_type_error": "Type de fichier non pris en charge. Veuillez télécharger des fichiers PDF, DOCX ou DOC.",
"file_size_error": "Taille de fichier trop grande. La taille maximale est {taille}.",
"type": "Taper",
"size": "Taille",
"upload_error_title": "Télécharger une erreur",
"upload_error_message": "Le format de fichier non pris en charge ou le téléchargement a échoué",
"upload_error_try_again": "Veuillez réessayer avec un fichier de document valide",
"try_again": "Essayer à nouveau",
"cancel_upload": "Annuler le téléchargement",
"upload_cancelled": "Télécharger annulé par l'utilisateur",
"downloading": "Téléchargement...",
"view_pdf": "Afficher le PDF",
"delete": "Supprimer",
"page_of": "Page {page} de {total}",
"loading_pdf": "Chargement du PDF ...",
"failed_to_load_pdf": "Échec du chargement du document PDF",
"failed_to_render_pdf": "Échec de la page PDF",
"use_arrow_keys": "Utilisez des touches flèches pour naviguer, +/- pour zoomer ou cliquez sur les commandes ci-dessus. Le clic droit est désactivé."
}
}
},
@@ -737,7 +737,9 @@
"upgrade": "वीडियो अपलोड करने की अपनी योजना को अपग्रेड करें",
"uploading": "अपलोड हो रहा है...",
"invalid_youtube": "अमान्य यूट्यूब लिंक",
"invalid_link": "अमान्य लिंक"
"invalid_link": "अमान्य लिंक",
"cancel_upload": "अपलोड रद्द करें",
"upload_cancelled": "उपयोगकर्ता द्वारा रद्द किए गए अपलोड"
}
},
"slide": {
@@ -753,6 +755,41 @@
"note": "पाठ नोट जनरेट करें",
"activities": "पाठ गतिविधियाँ उत्पन्न करें"
}
},
"document": {
"title": "दस्तावेज़",
"add_document": "दस्तावेज़ जोड़ें",
"no_document": "कोई दस्तावेज अभी तक अपलोड नहीं किया गया है",
"view_document": "दस्तावेज़ देखें",
"download": "डाउनलोड करना",
"upload_document": "अपलोड दस्तावेज़",
"upload_title": "अपलोड दस्तावेज़",
"upload_description": "PDF, DOCX, या DOC फ़ाइलों को अपलोड करें। अधिकतम आकार: 5 एमबी",
"drag_drop": "अपने दस्तावेज़ को यहां खींचें और ड्रॉप करें",
"or": "या",
"choose_file": "फाइलें चुनें",
"cancel": "रद्द करना",
"uploading": "अपलोड करना ...",
"upload_success": "दस्तावेज़ सफलतापूर्वक अपलोड किया गया!",
"upload_error": "दस्तावेज़ अपलोड करने में विफल",
"file_type_error": "फ़ाइल प्रकार समर्थित नहीं है। कृपया PDF, DOCX, या DOC फ़ाइलें अपलोड करें।",
"file_size_error": "फ़ाइल का आकार बहुत बड़ा है। अधिकतम आकार {आकार} है।",
"type": "प्रकार",
"size": "आकार",
"upload_error_title": "अपलोड त्रुटि",
"upload_error_message": "असमर्थित फ़ाइल प्रारूप या अपलोड विफल",
"upload_error_try_again": "कृपया एक मान्य दस्तावेज़ फ़ाइल के साथ पुनः प्रयास करें",
"try_again": "पुनः प्रयास करें",
"cancel_upload": "अपलोड रद्द करें",
"upload_cancelled": "उपयोगकर्ता द्वारा रद्द किए गए अपलोड",
"downloading": "डाउनलोड करना ...",
"view_pdf": "पीडीएफ देखें",
"delete": "मिटाना",
"page_of": "पृष्ठ {page} {total} का",
"loading_pdf": "लोडिंग पीडीएफ ...",
"failed_to_load_pdf": "पीडीएफ दस्तावेज़ लोड करने में विफल",
"failed_to_render_pdf": "पीडीएफ पेज को प्रस्तुत करने में विफल",
"use_arrow_keys": "ज़ूम करने के लिए नेविगेट करने के लिए तीर कुंजियों का उपयोग करें, या ऊपर दिए गए नियंत्रणों पर क्लिक करें। राइट-क्लिक अक्षम है।"
}
}
},
@@ -1517,4 +1554,4 @@
"average_grade": "औसत क्षेणी",
"average_grade_description": "सभी पूर्ण किए गए असाइनमेंट का औसत ग्रेड"
}
}
}
@@ -889,7 +889,9 @@
"upgrade": "Uaktualnij swój plan przesłania vidoes",
"uploading": "Przesyłanie ...",
"invalid_youtube": "Nieprawidłowe linki do YouTube",
"invalid_link": "Nieprawidłowe linki (y)"
"invalid_link": "Nieprawidłowe linki (y)",
"cancel_upload": "Anuluj przesłanie",
"upload_cancelled": "Prześlij anulowany przez użytkownika"
}
},
"slide": {
@@ -905,6 +907,41 @@
"note": "Wygeneruj notatkę lekcji",
"activities": "Generować zajęcia lekcji"
}
},
"document": {
"title": "Dokument",
"add_document": "Dodaj dokument",
"no_document": "Brak przesłanych dokumentów",
"view_document": "Wyświetl dokument",
"download": "Pobierać",
"upload_document": "Prześlij dokument",
"upload_title": "Prześlij dokument",
"upload_description": "Prześlij pliki PDF, DOCX lub DOC. Maksymalny rozmiar: 5 MB",
"drag_drop": "Przeciągnij i upuść swój dokument tutaj",
"or": "Lub",
"choose_file": "Wybierz plik",
"cancel": "Anulować",
"uploading": "Przesyłanie ...",
"upload_success": "Dokument przesłany pomyślnie!",
"upload_error": "Nie udało się przesłać dokumentu",
"file_type_error": "Typ pliku nie jest obsługiwany. Prześlij pliki PDF, DOCX lub DOC.",
"file_size_error": "Rozmiar pliku za duży. Maksymalny rozmiar to {rozmiar}.",
"type": "Typ",
"size": "Rozmiar",
"upload_error_title": "Prześlij błąd",
"upload_error_message": "Nieprzepustowy format pliku lub przesyłanie nie powiodło się",
"upload_error_try_again": "Spróbuj ponownie z prawidłowym plikiem dokumentu",
"try_again": "Spróbuj ponownie",
"cancel_upload": "Anuluj przesłanie",
"upload_cancelled": "Prześlij anulowany przez użytkownika",
"downloading": "Ściąganie...",
"view_pdf": "Zobacz PDF",
"delete": "Usuwać",
"page_of": "Strona {page} z {total}",
"loading_pdf": "Ładowanie PDF ...",
"failed_to_load_pdf": "Nie udało się załadować dokumentu PDF",
"failed_to_render_pdf": "Nie udało się renderować strony PDF",
"use_arrow_keys": "Użyj klawiszy strzałek do nawigacji, +/-, aby powiększyć lub kliknąć powyższe elementy sterujące. Kliknięcie prawym przyciskiem myszy jest wyłączone."
}
}
},
@@ -1487,4 +1524,4 @@
"seconds": "towary drugiej jakości",
"snackbar_error": "Błąd podczas wysyłania kodu"
}
}
}
@@ -737,7 +737,9 @@
"upgrade": "Atualize seu plano para enviar vídeos",
"uploading": "Enviando...",
"invalid_youtube": "Links inválidos do YouTube",
"invalid_link": "Links inválidos"
"invalid_link": "Links inválidos",
"cancel_upload": "Cancelar upload",
"upload_cancelled": "Upload cancelado pelo usuário"
}
},
"slide": {
@@ -753,6 +755,41 @@
"note": "Gerar nota de aula",
"activities": "Gerar atividades de aula"
}
},
"document": {
"title": "Documento",
"add_document": "Adicione documento",
"no_document": "Nenhum documento enviado ainda",
"view_document": "Exibir documento",
"download": "Download",
"upload_document": "Documento de upload",
"upload_title": "Documento de upload",
"upload_description": "Faça o upload de arquivos PDF, DOCX ou DOC. Tamanho máximo: 5 MB",
"drag_drop": "Arraste e solte seu documento aqui",
"or": "ou",
"choose_file": "Escolha o arquivo",
"cancel": "Cancelar",
"uploading": "Enviando ...",
"upload_success": "Documento enviado com sucesso!",
"upload_error": "Falha ao fazer upload do documento",
"file_type_error": "Tipo de arquivo não suportado. Faça o upload de arquivos PDF, DOCX ou DOC.",
"file_size_error": "Tamanho do arquivo muito grande. O tamanho máximo é {size}.",
"type": "Tipo",
"size": "Tamanho",
"upload_error_title": "Erro de upload",
"upload_error_message": "Formato de arquivo ou upload não suportado",
"upload_error_try_again": "Tente novamente com um arquivo de documento válido",
"try_again": "Tente novamente",
"cancel_upload": "Cancelar upload",
"upload_cancelled": "Upload cancelado pelo usuário",
"downloading": "Download ...",
"view_pdf": "Veja PDF",
"delete": "Excluir",
"page_of": "Página {page} de {total}",
"loading_pdf": "Carregando PDF ...",
"failed_to_load_pdf": "Falha ao carregar o documento PDF",
"failed_to_render_pdf": "Falhou em renderizar a página em PDF",
"use_arrow_keys": "Use as teclas de seta para navegar, +/- zoom ou clique nos controles acima. Clique com o botão direito do mouse está desativado."
}
}
},
@@ -1517,4 +1554,4 @@
"average_grade": "Nota Média",
"average_grade_description": "Nota média de todas as tarefas concluídas"
}
}
}
@@ -737,7 +737,9 @@
"upgrade": "Обновите свой план, чтобы загружать видео",
"uploading": "Загрузка...",
"invalid_youtube": "Недействительная ссылка(и) на YouTube",
"invalid_link": "Неверная ссылка(и)"
"invalid_link": "Неверная ссылка(и)",
"cancel_upload": "Отменить загрузку",
"upload_cancelled": "Загрузить отменен пользователем"
}
},
"slide": {
@@ -753,6 +755,41 @@
"note": "Создать заметку к уроку",
"activities": "Создание заданий урока"
}
},
"document": {
"title": "Документ",
"add_document": "Добавить документ",
"no_document": "Документы еще не загружены",
"view_document": "Просмотреть документ",
"download": "Скачать",
"upload_document": "Загрузить документ",
"upload_title": "Загрузить документ",
"upload_description": "Загрузите PDF, DOCX или DOC -файлы. Максимальный размер: 5 МБ",
"drag_drop": "Перетащите здесь свой документ",
"or": "или",
"choose_file": "Выберите файл",
"cancel": "Отмена",
"uploading": "Загрузка ...",
"upload_success": "Документ загружен успешно!",
"upload_error": "Не удалось загрузить документ",
"file_type_error": "Тип файла не поддерживается. Пожалуйста, загрузите файлы PDF, DOCX или DOC.",
"file_size_error": "Размер файла слишком большой. Максимальный размер - {размер}.",
"type": "Тип",
"size": "Размер",
"upload_error_title": "Ошибка загрузки",
"upload_error_message": "Неупречный формат файла или ошибка загрузки",
"upload_error_try_again": "Пожалуйста, попробуйте еще раз с действительным файлом документа",
"try_again": "Попробуйте еще раз",
"cancel_upload": "Отменить загрузку",
"upload_cancelled": "Загрузить отменен пользователем",
"downloading": "Загрузка ...",
"view_pdf": "Просмотреть PDF",
"delete": "Удалить",
"page_of": "Page {page} {total}",
"loading_pdf": "Загрузка PDF ...",
"failed_to_load_pdf": "Не удалось загрузить документ PDF",
"failed_to_render_pdf": "Не удалось отобразить страницу PDF",
"use_arrow_keys": "Используйте клавиши со стрелками, чтобы перемещаться, +/- до масштабирования или нажмите кнопку элементов управления выше. Щелкнуть правой кнопкой мыши отключено."
}
}
},
@@ -737,7 +737,9 @@
"upgrade": "Nâng cấp kế hoạch tải video lên của bạn",
"uploading": "Đang tải lên...",
"invalid_youtube": "(Các) liên kết YouTube không hợp lệ",
"invalid_link": "(Các) liên kết không hợp lệ"
"invalid_link": "(Các) liên kết không hợp lệ",
"cancel_upload": "Hủy tải lên",
"upload_cancelled": "Tải lên bị hủy bởi người dùng"
}
},
"slide": {
@@ -753,6 +755,41 @@
"note": "Tạo ghi chú bài học",
"activities": "Tạo hoạt động bài học"
}
},
"document": {
"title": "Tài liệu",
"add_document": "Thêm tài liệu",
"no_document": "Chưa có tài liệu nào được tải lên",
"view_document": "Xem tài liệu",
"download": "Tải xuống",
"upload_document": "Tải lên tài liệu",
"upload_title": "Tải lên tài liệu",
"upload_description": "Tải lên các tệp PDF, DOCX hoặc DOC. Kích thước tối đa: 5MB",
"drag_drop": "Kéo và thả tài liệu của bạn tại đây",
"or": "hoặc",
"choose_file": "Chọn Tệp",
"cancel": "Hủy bỏ",
"uploading": "Tải lên ...",
"upload_success": "Tài liệu được tải lên thành công!",
"upload_error": "Không tải lên tài liệu",
"file_type_error": "Loại tệp không được hỗ trợ. Vui lòng tải lên các tệp PDF, DOCX hoặc DOC.",
"file_size_error": "Kích thước tập tin quá lớn. Kích thước tối đa là {kích thước}.",
"type": "Kiểu",
"size": "Kích cỡ",
"upload_error_title": "Lỗi tải lên",
"upload_error_message": "Định dạng tệp không được hỗ trợ hoặc tải lên không thành công",
"upload_error_try_again": "Vui lòng thử lại với một tệp tài liệu hợp lệ",
"try_again": "Hãy thử lại",
"cancel_upload": "Hủy tải lên",
"upload_cancelled": "Tải lên bị hủy bởi người dùng",
"downloading": "Tải xuống ...",
"view_pdf": "Xem PDF",
"delete": "Xóa bỏ",
"page_of": "Trang {page} của {total}",
"loading_pdf": "Tải PDF ...",
"failed_to_load_pdf": "Không tải tài liệu PDF",
"failed_to_render_pdf": "Không thể hiển thị trang PDF",
"use_arrow_keys": "Sử dụng các phím mũi tên để điều hướng, +/- đến phóng to hoặc nhấp vào các điều khiển ở trên. Nhấp chuột phải bị vô hiệu hóa."
}
}
},
@@ -1517,4 +1554,4 @@
"average_grade": "Điểm trung bình",
"average_grade_description": "Điểm trung bình của tất cả các bài tập đã hoàn thành"
}
}
}
@@ -281,6 +281,7 @@ export interface Group_attendance {
}
export type LessonVideoType = 'youtube' | 'generic' | 'upload';
export type LessonDocumentType = any;
export interface LessonPage {
id?: string | null;
@@ -301,6 +302,13 @@ export interface LessonPage {
svid?: string;
};
}>;
documents: Array<{
type: LessonDocumentType;
name: string;
link: string;
size?: number;
key?: string;
}>;
};
exercises: [];
lesson_completion: LessonCompletion[];