Skip to content
Snippets Groups Projects
index.tsx 4.69 KiB
Newer Older
  • Learn to ignore specific revisions
  • import React, { useEffect, useState } from "react";
    
    import styles from "./style.module.scss";
    
    
    danieldeng2's avatar
    danieldeng2 committed
    // import { request } from "../../../utils/api"
    // import { api } from "../../../constants/routes"
    
    import MyBreadcrumbs from "components/atoms/MyBreadcrumbs";
    
    import InputGroup from "react-bootstrap/InputGroup";
    import FormControl from "react-bootstrap/FormControl";
    
    import Button from "react-bootstrap/Button";
    
    import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
    
    import { faInfoCircle } from "@fortawesome/free-solid-svg-icons";
    
    import QuickAccessView from "components/molecules/QuickAccessView";
    import ResourcesFolderView from "components/molecules/ResourcesFolderView";
    
    danieldeng2's avatar
    danieldeng2 committed
    import CurrentDirectoryView from "components/molecules/CurrentDirectoryView";
    import { useParams } from "react-router-dom";
    
    danieldeng2's avatar
    danieldeng2 committed
    const ModuleResources: React.FC<{ year: string}> = ({year}) => {
      let {id, scope } = useParams();
    
    danieldeng2's avatar
    danieldeng2 committed
      scope = scope === undefined ? "" : scope;
    
    
    danieldeng2's avatar
    danieldeng2 committed
      const quickAccessItems = resourceItems.filter(
    
    danieldeng2's avatar
    danieldeng2 committed
        ({ tags, folder }) =>
          tags.includes("new") && (scope === "" || scope === folder)
      );
    
    
    danieldeng2's avatar
    danieldeng2 committed
      const currentDirectoryFiles = resourceItems.filter(
    
    danieldeng2's avatar
    danieldeng2 committed
        ({ folder }) => folder === scope
    
    danieldeng2's avatar
    danieldeng2 committed
    	);
    	
    	const module_code = id.startsWith("CO") ? id : id.slice(2);
    
    	//maybe refactor into class?
    
    danieldeng2's avatar
    danieldeng2 committed
    	// const [error, setError] = useState(null);
      // const [isLoaded, setIsLoaded] = useState(false);
      // const [resources, setResources] = useState([]);
    
    danieldeng2's avatar
    danieldeng2 committed
      // useEffect(() => {
      //   setIsLoaded(false);
      //   const onSuccess = (data: any) => {
      //     setIsLoaded(true);
      //     setResources(data.json());
      //   }
      //   const onFailure = (error: any) => {
      //     setIsLoaded(true);
      //     setError(error);
      //   }
    
    danieldeng2's avatar
    danieldeng2 committed
      //   request(api.MATERIALS_RESOURCES, "GET", onSuccess, onFailure, {
      //     "year": year,
      //     "course": module_code
      //   })
      // }, [year, module_code]);
    
          <InputGroup>
            <FormControl
              className={styles.searchBar}
              aria-label="Search"
              placeholder="Search..."
            />
            <InputGroup.Append>
              <Button className={styles.searchBarIcon}>
                <FontAwesomeIcon size="1x" icon={faInfoCircle} />
              </Button>
            </InputGroup.Append>
    
    danieldeng2's avatar
    danieldeng2 committed
          {scope === "" && folderItems.length > 0 ? <ResourcesFolderView folderItems={folderItems} /> : null}
    
          {scope !== "" && currentDirectoryFiles.length > 0 ? <CurrentDirectoryView documentItems={currentDirectoryFiles} /> : null}
    			{scope === "" && quickAccessItems.length > 0 ? <QuickAccessView quickAccessItems={quickAccessItems} /> : null}
    
    		</>
    
    danieldeng2's avatar
    danieldeng2 committed
    export default ModuleResources;
    
    let folderItems = [
      {
        title: "Lecture Notes",
        id: 0,
      },
      {
        title: "Logic Exercise",
        id: 1,
      },
      {
    
        title: "Pandora Lab",
    
    danieldeng2's avatar
    danieldeng2 committed
        id: 2,
      },
      {
        title: "Extra",
        id: 3,
      },
    ];
    
    let resourceItems = [
    
    	{
        title: "How To Use Pandora",
        type: "video",
        tags: ["new", "WATCHME"],
        folder: "Pandora Lab",
        id: 14,
    	},
    	{
        title: "Logic Exercise 1",
        type: "File",
        tags: ["Week 1"],
        folder: "Logic Exercise",
        id: 8,
      },
    
    danieldeng2's avatar
    danieldeng2 committed
      {
    
        title: "Logic Exercise 2",
    
    danieldeng2's avatar
    danieldeng2 committed
        type: "File",
    
        tags: ["Week 2"],
        folder: "Logic Exercise",
        id: 9,
      },
      {
        title: "Logic Exercise 3",
        type: "File",
        tags: ["new", "Week 3"],
        folder: "Logic Exercise",
        id: 10,
      },
      {
        title: "Syntax Semantics Propositional Logic",
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["Slides"],
        folder: "Lecture Notes",
        id: 0,
      },
      {
        title: "Classical First-Order Predicate Logic",
    
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["Slides"],
        folder: "Lecture Notes",
        id: 1,
      },
      {
        title: "Translation Validity",
    
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["new", "Slides"],
        folder: "Lecture Notes",
        id: 2,
      },
      {
        title: "validityPL-part1",
    
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["Slides"],
        folder: "Lecture Notes",
        id: 3,
      },
      {
        title: "validityPL-part2",
    
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["Slides"],
        folder: "Lecture Notes",
        id: 4,
      },
      {
        title: "validityPL-part3",
    
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["new", "Slides"],
        folder: "Lecture Notes",
        id: 5,
      },
      {
        title: "validityFOL-part1",
    
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["Slides"],
        folder: "Lecture Notes",
        id: 6,
      },
      {
        title: "validityFOL-part2",
    
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["new", "Slides"],
        folder: "Lecture Notes",
        id: 7,
      },
      {
    
        title: "Pandora Lab",
    
    danieldeng2's avatar
    danieldeng2 committed
        type: "File",
        tags: [],
    
        folder: "Pandora Lab",
    
    danieldeng2's avatar
    danieldeng2 committed
        id: 11,
      },
      {
        title: "Propositional Logic Exercises",
    
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["new", "Revision"],
        folder: "Extra",
        id: 12,
      },
      {
        title: "Extra Logic Exercises",
    
        type: "pdf",
    
    danieldeng2's avatar
    danieldeng2 committed
        tags: ["new", "Revision"],
        folder: "Extra",
        id: 13,
      },
    ];