From d4d25faedf8d818210240f0ea8f7fcb486d3edf9 Mon Sep 17 00:00:00 2001 From: lucille Date: Wed, 9 Oct 2024 11:40:34 +0300 Subject: [PATCH 1/2] fix the footer --- components/footer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/footer.js b/components/footer.js index 178fb28..e88408f 100755 --- a/components/footer.js +++ b/components/footer.js @@ -10,8 +10,7 @@ export default function Footer() { backgroundColor: "#fcfcfc", width: "100%", height: "80px", - position: "fixed", - bottom: 0, + position: "absolute", display: "flex", alignItems: "center", justifyContent: "center", From cbdae20aa83b5c75e39f69137f42cd5a235aa7bd Mon Sep 17 00:00:00 2001 From: lucille Date: Wed, 9 Oct 2024 11:57:07 +0300 Subject: [PATCH 2/2] ensure only logged in users can upload resources --- pages/resources.js | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/pages/resources.js b/pages/resources.js index 99b02e6..45f756a 100755 --- a/pages/resources.js +++ b/pages/resources.js @@ -2,14 +2,27 @@ import React, { useState, useEffect } from "react"; import Footer from "@/components/footer"; import Head from "next/head"; import Link from "next/link"; +import { doGetSession } from "@/utilities"; +import { Box, Typography } from "@mui/material"; function ResourcesKnhts() { const [uploadedFiles, setUploadedFiles] = useState([]); const [selectedFiles, setSelectedFiles] = useState([]); const [uploadSuccess, setUploadSuccess] = useState(false); const [uploadError, setUploadError] = useState(null); + const [isLoggedIn, setIsLoggedIn] = useState(false); useEffect(() => { + const checkLoginStatus = async () => { + const sessionData = await doGetSession(); + setIsLoggedIn(sessionData !== null); + }; + + checkLoginStatus(); + }, []); + + useEffect(() => { + //TODO, // Initialize IndexedDB database const request = indexedDB.open("uploadedFilesDB", 1); @@ -230,17 +243,25 @@ function ResourcesKnhts() { )}
-

- You can also add resources by uploading files. -

+
+ {isLoggedIn && ( + + + You can also add resources by uploading files. + - - + + + + )} +