import React, { useState } from "react"; import styles from './CategoryDetails.module.scss'; import { useLocation } from 'react-router'; import queryString from 'query-string'; import { ReactComponent as ChevronLeft } from '../../assets/icons/chevron-left.svg'; import { ReactComponent as SearchIcon } from '../../assets/icons/bx-search-alt.svg'; import { ReactComponent as PlusCircledIcon } from '../../assets/icons/plus-circle.svg'; import { ReactComponent as ComposeIcon } from '../../assets/icons/compose.svg'; import { ReactComponent as ExportLine } from '../../assets/icons/export-line.svg'; import { CircularProgressbar } from "react-circular-progressbar"; import { NavLink } from "react-router-dom"; import { IShelf } from "../../structure/shelf"; import { useHistory } from "react-router-dom"; import { userProfileData } from "../../App"; import { PopoverOptions } from "../popover-options/PopoverOptions"; export const CategoryDetails: React.FC = () => { const location = useLocation(); const category_id: any = queryString.parse(location.pathname)['/category-details/category_id']; const shelfCount: number = userProfileData.categories[category_id].shelves.length; const [shelfResult, setShelfResult] = useState>(userProfileData.categories[category_id].shelves); const history = useHistory(); const searchShelf = (text: string) => { if (text.length > 0) { let result = userProfileData.categories[category_id].shelves.filter(shelf => { return shelf.name.toLowerCase().includes(text.toLowerCase()); }); setShelfResult(result); } else { setShelfResult(userProfileData.categories[category_id].shelves); } } return
Shelves
{/* eslint-disable-next-line */} profile-image
{ userProfileData.categories[category_id].icon }

{ userProfileData.categories[category_id].name }

{ shelfCount } { shelfCount > 1 ? 'Shelves' : 'Shelf' }

, title: 'Edit', function: () => { console.log("Edit Clicked") } }]} />
searchShelf(event.currentTarget.value)} />
Add Shelf
    { shelfResult.map((shelf, index) => { return
  • { history.push('/shelf-details/category_id=' + category_id + '&&shelf_id=' + index); }}>
    0 ? (shelf.revisedWords.length * 100/ shelf.words.length) : 0} strokeWidth={7} styles={{ path: { stroke: 'white', strokeLinecap: 'round', }, trail: { stroke: 'rgba(255, 255, 255, 0.25)', strokeLinecap: 'round', }} } /> { shelf.words.length > 0 ? (shelf.revisedWords.length * 100/ shelf.words.length) : 0 }%
    { shelf.name }

    { shelf.words.length } words

  • }) }
}