Skip to content

Commit

Permalink
Merge pull request #148 from lucyjemutai/fix-footer
Browse files Browse the repository at this point in the history
Fix footer and ensure logged in users can only upload resources when
  • Loading branch information
lucyjemutai authored Oct 11, 2024
2 parents b66391b + cbdae20 commit 0efe637
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
3 changes: 1 addition & 2 deletions components/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
41 changes: 31 additions & 10 deletions pages/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -230,17 +243,25 @@ function ResourcesKnhts() {
</div>
)}
<br />
<p style={{ fontSize: "1.0em", color: "#777", marginTop: "5px" }}>
You can also add resources by uploading files.
</p>
<div>
{isLoggedIn && (
<Box>
<Typography
style={{ fontSize: "1.0em", color: "#777", marginTop: "5px" }}
>
You can also add resources by uploading files.
</Typography>

<input type="file" onChange={handleFileSelect} multiple />
<button
onClick={handleFileUpload}
disabled={selectedFiles.length === 0}
>
Upload
</button>
<input type="file" onChange={handleFileSelect} multiple />
<button
onClick={handleFileUpload}
disabled={selectedFiles.length === 0}
>
Upload
</button>
</Box>
)}
</div>
</div>
</div>
<Footer />
Expand Down

0 comments on commit 0efe637

Please sign in to comment.