Skip to content
Snippets Groups Projects
Commit cc2e8045 authored by Nidharshan A's avatar Nidharshan A
Browse files

Replace FolderNav.js

parent 169e58c3
No related branches found
No related tags found
No related merge requests found
import React from 'react'; import { react } from "react";
import AddFolder from "./AddFolder"; import { Breadcrumb } from "react-bootstrap";
import { Container,Button } from "react-bootstrap"; import { Link } from "react-router-dom";
import { useFolder } from ".././hooks/useFolder"; import { ROOT_FOLDER } from "../hooks/useFolder";
import Folder from "./Folder";
import FolderNav from "./FolderNav";
import { useParams } from "react-router-dom";
const Hero=({handleLogout})=>{ export default function FolderNav( {currentFolder} ) {
const { folderId } = useParams(); let path = currentFolder === ROOT_FOLDER ? [] : [ROOT_FOLDER]
const {folder, childFolders} = useFolder(folderId); if (currentFolder){
path = [...path,...currentFolder.path];
return( }
<>
<section className="hero">
<nav>
<h2>Course File</h2>
<button className="logoutbutton" onClick={handleLogout}>Logout</button>
</nav>
</section>
<Container fluid>Contents</Container>
<Container fluid>
<div className="d-flex align-items-center">
<FolderNav currentFolder={folder}/>
<AddFolder currentFolder={folder}/>
</div>
{childFolders.length > 0 && ( return(
<div className="d-flex flex-wrap"> <Breadcrumb
{childFolders.map(childFolder => ( className="flex-grow-1"
<div listProps = {{ className : "bg-white pl-0 m-0"}}
key = {childFolder.id}
style = { {maxWidth : "250px"}}
className="p-2"
> >
<Folder folder={childFolder}></Folder> {path.map((folder,index) => (
</div> <Breadcrumb.Item
key={folder.id}
linkAs ={Link}
linkProps = {{
to : folder.id ? `/folder/${folder.id}` : "/",
}}
className="text-truncate d-inline-block"
style = { {maxWidth : "175px"} }
>
{folder.name}
</Breadcrumb.Item>
))} ))}
</div> { currentFolder && (
)} <Breadcrumb.Item
className="text-truncate d-inline-block"
style = { {maxWidth : "200px"} }
active
>
{currentFolder.name}
</Breadcrumb.Item>
)
</Container> }
</> </Breadcrumb>
); );
} }
\ No newline at end of file
export default Hero;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment