From 64fc708bf7c6510475a6c21220aff1f8b657f180 Mon Sep 17 00:00:00 2001 From: JBB0807 <104856796+JBB0807@users.noreply.github.com> Date: Thu, 8 May 2025 00:14:50 -0700 Subject: [PATCH] bug fix on assignments --- src/components/Navbar.jsx | 2 +- src/pages/AssignmentPage.jsx | 62 ++++++++++++---------------- src/scss/components/_assignment.scss | 4 +- src/scss/page/_assignment.scss | 10 ++++- 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index 496e5e4..d9ee9c9 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -141,7 +141,7 @@ const Navbar = () => {
  • { useEffect(() => { document.title = "Assignment"; - fetchAssignments(); // Add `await` here if it's also async + fetchAssignments(); }, []); @@ -89,24 +89,13 @@ const AssignmentPage = () => { return () => clearTimeout(timer); // Clear timeout on QR code number change }, [qrCodeNumber]); - const getCurrentUser = async () => { + const fetchAssignments = async () => { try { const authResponse = await fetch(`${authUrl}/auth/current_user`, { credentials: "include", }); const user = await authResponse.json(); - console.log("Current user fetched:", user); setUser(user); - } catch (error) { - console.error("Error fetching current user:", error); - } - }; - - const fetchAssignments = async () => { - try { - await getCurrentUser(); // Fetch the current user first - if (!user.userId) return; // Check if user is logged in - // Check if user is logged in console.log("User:", user); const res = await fetch( @@ -138,6 +127,8 @@ const AssignmentPage = () => { setStudentName(""); setCampID(""); setProgramID(""); + setQrCodeNumber(""); + setAppName(""); setPassword(""); setDescription(""); setFile(null); @@ -145,6 +136,7 @@ const AssignmentPage = () => { }; const handleEditClick = (qrCodeNumber) => { + console.log("Navigating to editor with QR Code Number:", qrCodeNumber); navigate('/editor', { state: { qrCodeNumber: qrCodeNumber } }); }; @@ -163,21 +155,6 @@ const AssignmentPage = () => { formData.append("password", password); formData.append("description", description); - setTimeout(() => { - //replace with api - // if (editingIndex !== null) { - // const updatedProjects = [...projects]; - // updatedProjects[editingIndex] = newProject; - // setProjects(updatedProjects); - // } else { - // setProjects([...projects, newProject]); - // } - - alert(editingIndex !== null ? "Assignment updated!" : "Assignment submitted!"); - resetForm(); - setShowModal(false); - setLoading(false); - }, 2000); if (editingIndex !== null) { //edit mode await fetch(`${VITE_ASSIGNMENT_URL}/instructor/update/${assignmentId}`, { @@ -233,6 +210,7 @@ const AssignmentPage = () => { editingIndex !== null ? "Assignment updated!" : "Assignment submitted!" ); + setLoading(false); fetchAssignments(); // Refresh the assignments list resetForm(); setShowModal(false); @@ -353,6 +331,16 @@ const AssignmentPage = () => { /> +
    + + setQrCodeNumber(e.target.value)} + required + /> +
    +
    @@ -427,15 +415,17 @@ const AssignmentPage = () => {

    Student Name: {project.studentname || project.studentName}

    -

    CampID: {project.campid || project.campID}

    -

    ProgramID: {project.programid || project.programID}

    +

    QR Number: {project.qrcodenumber || project.qrCodeNumber}

    +

    App Name: {project.appname || project.appName}

    +

    Game Snake ID: {project.snakegameid || project.snakeGameId}

    +

    URL: {project.assignmenturl || project.assignmentUrl}

    - {project.title &&

    {project.title}

    } + {/* {project.title &&

    {project.title}

    } {project.description &&

    {project.description}

    } - {project.fileName &&

    Uploaded File: {project.fileName}

    } + {project.fileName &&

    Uploaded File: {project.fileName}

    } */} - {project.assignmenturl && ( + {/* {project.assignmenturl && (

    { View Assignment

    - )} + )} */} {project.originalfile && (

    {

    -
    diff --git a/src/scss/components/_assignment.scss b/src/scss/components/_assignment.scss index 6e5f81d..44c9184 100644 --- a/src/scss/components/_assignment.scss +++ b/src/scss/components/_assignment.scss @@ -1,10 +1,10 @@ .assignment-page { max-width: 100%; padding: 20px; - margin-top: 90rem; + margin-top: 50rem; overflow-x: hidden; overflow-y: auto; - // min-height: 100vh; + min-height: 100vh; box-sizing: border-box; form { diff --git a/src/scss/page/_assignment.scss b/src/scss/page/_assignment.scss index 04c9baf..0cea9de 100644 --- a/src/scss/page/_assignment.scss +++ b/src/scss/page/_assignment.scss @@ -1,10 +1,18 @@ // Assignment Page Styling +body { + justify-content: flex-starts; +} .assignment-page { + position: relative; display: flex; flex-direction: column; align-items: center; - padding: 2rem; + + a { + text-decoration: none; + color: #AAC5E5; + } section { width: 100%;