| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- 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 } 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 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;
- };
-
- 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>
- </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,
- }),
- }),
- };
-
- export default FilesPage;
|