mirror of
https://github.com/Leado123/Leado123.github.io.git
synced 2026-10-01 00:32:59 +00:00
e
This commit is contained in:
+136
-84
@@ -16,7 +16,10 @@ export const classOptions = [ // TODO REMOVE
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
function findIfMobile() {
|
||||||
|
//return true;
|
||||||
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||||
|
}
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
@@ -26,6 +29,7 @@ function App() {
|
|||||||
const [tempFileId, setTempFileId] = useState<string>("");
|
const [tempFileId, setTempFileId] = useState<string>("");
|
||||||
|
|
||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
|
const [isMobile, setIsMobile] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
const [syllabi, setSyllabi] = useState<ClassListing[]>([]);
|
const [syllabi, setSyllabi] = useState<ClassListing[]>([]);
|
||||||
@@ -54,10 +58,10 @@ function App() {
|
|||||||
|
|
||||||
function uploadFile() {
|
function uploadFile() {
|
||||||
let formdata = new FormData();
|
let formdata = new FormData();
|
||||||
|
|
||||||
if (file === null) {
|
if (file === null) {
|
||||||
alert("File not uploaded");
|
alert("File not uploaded");
|
||||||
throw new Error("File not uploaded");
|
throw new Error("File not uploaded");
|
||||||
}
|
}
|
||||||
formdata.append("upload", file);
|
formdata.append("upload", file);
|
||||||
formdata.append("email", email);
|
formdata.append("email", email);
|
||||||
@@ -67,9 +71,9 @@ function App() {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formdata,
|
body: formdata,
|
||||||
})
|
})
|
||||||
.then(async (response) => {
|
.then(async (response) => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Server error: ${response.statusText}`);
|
throw new Error(`Server error: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
setAccordionOpen(true);
|
setAccordionOpen(true);
|
||||||
let data = await response.json();
|
let data = await response.json();
|
||||||
@@ -77,32 +81,42 @@ function App() {
|
|||||||
setTempFileId(data.fileId);
|
setTempFileId(data.fileId);
|
||||||
setOpenModal(false);
|
setOpenModal(false);
|
||||||
alert("Upload successful! You will receive an email with your volunteer hours within 3 days.");
|
alert("Upload successful! You will receive an email with your volunteer hours within 3 days.");
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Upload failed:", error);
|
console.error("Upload failed:", error);
|
||||||
alert("Upload failed: " + error.message);
|
alert("Upload failed: " + error.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("temp file is", tempFileId)
|
console.log("temp file is", tempFileId)
|
||||||
}, [tempFileId])
|
}, [tempFileId])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleSearch();
|
handleSearch();
|
||||||
|
|
||||||
|
if (findIfMobile()) {
|
||||||
|
// Code for mobile devices
|
||||||
|
setIsMobile(true);
|
||||||
|
console.log("mobile")
|
||||||
|
} else {
|
||||||
|
// Code for desktop devices
|
||||||
|
console.log("pc")
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[])
|
[])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handleFileChange = (e:React.ChangeEvent<HTMLInputElement>) => {
|
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (e.target.files === null) return
|
if (e.target.files === null) return
|
||||||
if (e.target.files[0] === null) return
|
if (e.target.files[0] === null) return
|
||||||
|
|
||||||
setFile(e.target.files[0]);
|
setFile(e.target.files[0]);
|
||||||
setAccordionOpen(true);
|
setAccordionOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
|
function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
@@ -113,33 +127,71 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0" />
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0" />
|
||||||
<h3 className="text-2xl font-bold text-center">Easily View & Share College Syllabi JFKMCHS/Norco College</h3> <br></br>
|
{isMobile === false && <div className="place-items-center p-10">
|
||||||
<div className="">
|
<h3 className="text-2xl font-bold text-center">Easily View & Share College Syllabi JFKMCHS/Norco College</h3> <br></br>
|
||||||
<div className="flex space-x-1">
|
<div className="">
|
||||||
<button onClick={() => setOpenModal(true)} className=" bg-blue-700 p-2 text-yellow-50 rounded-lg flex flex-row">
|
<div className="flex space-x-1">
|
||||||
<span className="flex justify-center items-center aspect-square flex-1"><i className="material-symbols-rounded">attach_file</i></span>
|
<button onClick={() => setOpenModal(true)} className=" bg-blue-700 p-2 text-yellow-50 rounded-lg flex flex-row">
|
||||||
<span className="flex flex-col"> <span className="text-sm">add a syllabus</span>
|
<span className="flex justify-center items-center aspect-square flex-1"><i className="material-symbols-rounded">attach_file</i></span>
|
||||||
<span className="text-xs">2 volunteer hours</span></span>
|
<span className="flex flex-col"> <span className="text-sm">add a syllabus</span>
|
||||||
</button>
|
<span className="text-xs">1 volunteer hours</span></span>
|
||||||
<div className="flex-1 flex bg-white rounded-lg">
|
</button>
|
||||||
<input type="search" onKeyDown={handleKeyDown} placeholder="search, hit enter or the search button to enter query" className="focus:outline-none bg-transparent border-none flex-1 text-black" value={query} onChange={(e) => setQuery(e.target.value)}>
|
<div className="flex-1 flex bg-white rounded-lg">
|
||||||
|
<input type="search" onKeyDown={handleKeyDown} placeholder="search, hit enter or the search button to enter query" className="focus:outline-none bg-transparent border-none flex-1 text-black" value={query} onChange={(e) => setQuery(e.target.value)}>
|
||||||
</input>
|
|
||||||
<button className="aspect-square flex justify-center items-center" onClick={handleSearch}>
|
|
||||||
|
|
||||||
<span className="material-symbols-rounded text-black">
|
|
||||||
search
|
|
||||||
</span>
|
|
||||||
</button></div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div className="listing">
|
|
||||||
{syllabi.map((syllabus, i) => {
|
|
||||||
return <SyllabusListing key={i} fileName={syllabus.fileName} className={syllabus.className} professor={syllabus.professor} />
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</input>
|
||||||
|
<button className="aspect-square flex justify-center items-center" onClick={handleSearch}>
|
||||||
|
<span className="material-symbols-rounded text-black">
|
||||||
|
search
|
||||||
|
</span>
|
||||||
|
</button></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div className="listing">
|
||||||
|
{syllabi.map((syllabus, i) => {
|
||||||
|
return <SyllabusListing key={i} fileName={syllabus.fileName} className={syllabus.className} professor={syllabus.professor} />
|
||||||
|
})}
|
||||||
|
<SyllabusListing fileName={"syllabus.fileName"} className={"syllabus.className"} professor={"syllabus.professor"} />
|
||||||
|
<SyllabusListing fileName={"syllabus.fileName"} className={"syllabus.className"} professor={"syllabus.professor"} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>}
|
||||||
|
{isMobile === true && <div className="p-1 pt-4">
|
||||||
|
<h3 className="text-2xl font-bold">Easily View & Share College Syllabi JFKMCHS/Norco College</h3> <br></br>
|
||||||
|
<div className="">
|
||||||
|
<div className="flex space-x-1">
|
||||||
|
<button onClick={() => setOpenModal(true)} className=" bg-blue-700 p-2 text-yellow-50 rounded-lg flex flex-row">
|
||||||
|
<span className="flex justify-center items-center aspect-square flex-1"><i className="material-symbols-rounded">attach_file</i></span>
|
||||||
|
<span className="flex flex-col"> <span className="text-sm">add a syllabus</span>
|
||||||
|
<span className="text-xs">1 volunteer hours</span></span>
|
||||||
|
</button>
|
||||||
|
<div className="flex-1 flex bg-white rounded-lg">
|
||||||
|
<input type="search" onKeyDown={handleKeyDown} placeholder="search, hit enter or the search button to enter query" className="focus:outline-none bg-transparent border-none flex-1 text-black" value={query} onChange={(e) => setQuery(e.target.value)}>
|
||||||
|
|
||||||
|
</input>
|
||||||
|
<button className="aspect-square flex justify-center items-center" onClick={handleSearch}>
|
||||||
|
<span className="material-symbols-rounded text-black">
|
||||||
|
search
|
||||||
|
</span>
|
||||||
|
</button></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div className="listing">
|
||||||
|
{syllabi.map((syllabus, i) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SyllabusListing key={i} fileName={syllabus.fileName} className={syllabus.className} professor={syllabus.professor} />
|
||||||
|
{i === syllabi.length - 1 && <SyllabusListing key={i + 1} fileName={"syllabus.fileName"} className={"syllabus.className"} professor={"syllabus.professor"} />}
|
||||||
|
</>
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
})}
|
||||||
|
<SyllabusListing fileName={"syllabus.fileName"} className={"syllabus.className"} professor={"syllabus.professor"} />
|
||||||
|
<SyllabusListing fileName={"syllabus.fileName"} className={"syllabus.className"} professor={"syllabus.professor"} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>}
|
||||||
|
|
||||||
|
|
||||||
<Modal show={openModal} size="md" onClose={onCloseModal} popup>
|
<Modal show={openModal} size="md" onClose={onCloseModal} popup>
|
||||||
@@ -148,56 +200,56 @@ search
|
|||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<h3 className="text-xl font-medium text-gray-900 dark:text-white">Upload a Syllabus</h3>
|
<h3 className="text-xl font-medium text-gray-900 dark:text-white">Upload a Syllabus</h3>
|
||||||
<div>
|
<div>
|
||||||
<div className="mb-2 block">
|
|
||||||
<Label htmlFor="large-file-upload" value="(pdf, doc, or docx) *"></Label>
|
|
||||||
</div>
|
|
||||||
<form method="post" className="space-y-6">
|
|
||||||
<FileInput id="large-file-upload" onChange={handleFileChange} sizing="lg" />
|
|
||||||
|
|
||||||
<Accordion>
|
|
||||||
<Accordion.Panel isOpen={accordionOpen}>
|
|
||||||
<Accordion.Title className="">(Optional) Fill out information to get volunteer hours</Accordion.Title>
|
|
||||||
<Accordion.Content className="space-y-6">
|
|
||||||
<div>
|
|
||||||
<div className="mb-2 block">
|
<div className="mb-2 block">
|
||||||
<Label htmlFor="email" value="Your email (cnusd school email is fine)" />
|
<Label htmlFor="large-file-upload" value="(pdf, doc, or docx) *"></Label>
|
||||||
</div>
|
</div>
|
||||||
<TextInput
|
<form method="post" className="space-y-6">
|
||||||
id="email"
|
<FileInput id="large-file-upload" onChange={handleFileChange} sizing="lg" />
|
||||||
placeholder="name@company.com"
|
|
||||||
value={email}
|
<Accordion>
|
||||||
// @ts-ignore
|
<Accordion.Panel isOpen={accordionOpen}>
|
||||||
onChange={(event: Event) => setEmail(event?.target?.value)}
|
<Accordion.Title className="">(Optional) Fill out information to get volunteer hours</Accordion.Title>
|
||||||
|
<Accordion.Content className="space-y-6">
|
||||||
/>
|
<div>
|
||||||
|
<div className="mb-2 block">
|
||||||
</div>
|
<Label htmlFor="email" value="Your email (cnusd school email is fine)" />
|
||||||
<div>
|
</div>
|
||||||
<div className="mb-2 block">
|
<TextInput
|
||||||
<Label value="Your Name" />
|
id="email"
|
||||||
</div>
|
placeholder="name@company.com"
|
||||||
<TextInput
|
value={email}
|
||||||
placeholder="John Doe"
|
// @ts-ignore
|
||||||
value={name}
|
onChange={(event: Event) => setEmail(event?.target?.value)}
|
||||||
// @ts-ignore
|
|
||||||
onChange={(event: Event) => setName(event?.target?.value)}
|
/>
|
||||||
|
|
||||||
/>
|
</div>
|
||||||
</div>
|
<div>
|
||||||
<p className="text-xs text-black">We will handle classifying and organizing your syllabus and will contact you within 3 days to give you community service hours — College Success Club</p>
|
<div className="mb-2 block">
|
||||||
</Accordion.Content>
|
<Label value="Your Name" />
|
||||||
</Accordion.Panel>
|
</div>
|
||||||
</Accordion>
|
<TextInput
|
||||||
|
placeholder="John Doe"
|
||||||
<Button onClick={uploadFile} className="bg-blue-700 text-white">Upload File</Button>
|
value={name}
|
||||||
</form>
|
// @ts-ignore
|
||||||
|
onChange={(event: Event) => setName(event?.target?.value)}
|
||||||
|
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p className="text-xs text-black">We will handle classifying and organizing your syllabus and will contact you within 3 days to give you community service hours — College Success Club</p>
|
||||||
|
</Accordion.Content>
|
||||||
|
</Accordion.Panel>
|
||||||
|
</Accordion>
|
||||||
|
|
||||||
|
<Button onClick={uploadFile} className="bg-blue-700 text-white">Upload File</Button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
|
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -8,7 +8,7 @@
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
|
||||||
color-scheme: light dark;
|
color-scheme: dark;
|
||||||
color: rgba(255, 255, 255, 0.87);
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
|
||||||
font-synthesis: none;
|
font-synthesis: none;
|
||||||
@@ -29,7 +29,6 @@ a:hover {
|
|||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
place-items: center;
|
|
||||||
min-width: 320px;
|
min-width: 320px;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-10
@@ -1,11 +1,15 @@
|
|||||||
import "./syllabuslisting.css";
|
import "./syllabuslisting.css";
|
||||||
|
import "./App.tsx";
|
||||||
|
|
||||||
export interface ClassListing {
|
export interface ClassListing {
|
||||||
className: string;
|
className: string;
|
||||||
professor: string;
|
professor: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
}
|
}
|
||||||
|
function findIfMobile() {
|
||||||
|
//return true;
|
||||||
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||||
|
}
|
||||||
function SyllabusListing({className, professor, fileName}: ClassListing) {
|
function SyllabusListing({className, professor, fileName}: ClassListing) {
|
||||||
|
|
||||||
async function handleDownload() {
|
async function handleDownload() {
|
||||||
@@ -17,15 +21,28 @@ function SyllabusListing({className, professor, fileName}: ClassListing) {
|
|||||||
window.URL.revokeObjectURL(`https://api.sharesyllabus.me/files/${fileName}`);
|
window.URL.revokeObjectURL(`https://api.sharesyllabus.me/files/${fileName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(
|
if (!findIfMobile()) {
|
||||||
<>
|
|
||||||
<div className="w-full flex bg-white text-black rounded-lg p-3">
|
return(
|
||||||
<span className=" font-extrabold">{className}</span>
|
<>
|
||||||
<span className="flex-1">{professor}</span>
|
<div className="w-full flex bg-white text-black rounded-lg p-3">
|
||||||
<button className="border-2 border-blue-600 p-1 rounded-lg" onClick={handleDownload}>download <br></br>pdf 📄</button>
|
<span className=" font-extrabold">{className}</span>
|
||||||
</div>
|
<span className="flex-1">{professor}</span>
|
||||||
</>
|
<button className="border-2 border-blue-600 p-1 rounded-lg" onClick={handleDownload}>download <br></br>pdf 📄</button>
|
||||||
)
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return(
|
||||||
|
<>
|
||||||
|
<div className="w-full flex flex-col text-left bg-white space-y-2 text-black rounded-lg p-3">
|
||||||
|
<span className=" font-extrabold">{className}</span>
|
||||||
|
<span className="flex-1">{professor}</span>
|
||||||
|
<button className="border-2 h-20 border-blue-600 p-1 rounded-lg" onClick={handleDownload}>view pdf 📄</button>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SyllabusListing;
|
export default SyllabusListing;
|
||||||
Reference in New Issue
Block a user