| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import React, { useEffect, useState } from "react";
- import PropTypes from "prop-types";
- import { useSelector, useDispatch } from "react-redux";
- import IconButton from "../../components/IconButton/IconButton";
- import { setCategoriesReq } from "../../store/actions/categories/categoriesAction";
- import {
- selectCategories,
- selectChildParentRelations,
- } from "../../store/selectors/categoriesSelector";
- import table from "../../assets/images/table.png";
- import { FILES_PAGE } from "../../constants/pages";
- import FileTable from "./FileTable";
- import { useParams } from "react-router-dom";
-
- const FilesPage = ({ history }) => {
- const categories = useSelector(selectCategories);
- const childParentRelations = useSelector(selectChildParentRelations);
- const dispatch = useDispatch();
- const [trigger, setTrigger] = useState(0);
- let { id } = useParams();
-
- useEffect(() => {
- if (id === undefined) {
- dispatch(setCategoriesReq(undefined));
- } else {
- dispatch(setCategoriesReq({ parentCategoryId: id }));
- }
- }, [id]);
-
- const getNameHandler = (name) => {
- if (name.length > 15) return name.substr(0, 15) + "...";
- return name;
- };
-
- const ColoredLine = () => (
- <hr
- style={{
- color: "#F5F5F5",
- backgroundColor: "#F5F5F5",
- height: 1,
- }}
- />
- );
-
- return (
- <>
- <div className="l-t-rectangle"></div>
- <div className="r-b-rectangle"></div>
- <div
- className="pl-144"
- style={{ paddingTop: "36px" }}
- onClick={() => {
- setTrigger((trigger) => trigger + 1);
- }}
- >
- <div style={{ marginBottom: "50px" }}>
- <div style={{ marginBottom: "30px" }}>
- <h1 className="page-heading">Folderi</h1>
- <ColoredLine />
- <div className="page-navigation-buttons">
- <div
- onClick={() => history.push({ pathname: FILES_PAGE })}
- style={{ marginLeft: 0 }}
- className="files-file-routing"
- >
- Root
- </div>
- {childParentRelations.map((relation) => (
- <div
- style={{ display: "flex", alignItems: "center" }}
- key={relation.id}
- >
- <span
- style={{
- cursor: "auto",
- color: "#A9A9A9",
- fontWeight: "bold",
- marginLeft: "10px",
- }}
- >
- >
- </span>
- <div
- className="files-file-routing"
- onClick={() => history.push({ pathname: relation.id })}
- >
- {relation.name}
- </div>
- </div>
- ))}
- </div>
- <ColoredLine />
- </div>
- <div className="files-page-categories">
- {categories &&
- categories.map((category) => (
- <div
- className="files-page-categories-category"
- key={category.id}
- >
- <IconButton
- className="c-btn c-btn--primary-outlined files-page-category-button"
- data-testid="pattern-details-send-email"
- onClick={() =>
- history.push({
- pathname: FILES_PAGE + "/" + category.id,
- })
- }
- >
- <img
- style={{
- marginRight: "5px",
- width: "12px",
- height: "12px",
- }}
- src={table}
- />
- {getNameHandler(category.name)}
- </IconButton>
- </div>
- ))}
- </div>
- </div>
-
- <div style={{ marginBottom: "50px" }}>
- <div style={{ marginBottom: "30px" }}>
- <h1 className="page-heading">Fajlovi</h1>
- </div>
- <div className="files-page-categories">
- <FileTable trigger={trigger} />
- </div>
- </div>
- </div>
- </>
- );
- };
-
- FilesPage.propTypes = {
- history: PropTypes.shape({
- replace: PropTypes.func,
- push: PropTypes.func,
- location: PropTypes.shape({
- pathname: PropTypes.string,
- }),
- }),
- setFile: PropTypes.func,
- };
-
- export default FilesPage;
|