You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import React, { useEffect, useState } from "react";
  2. import PropTypes from "prop-types";
  3. import { useSelector, useDispatch } from "react-redux";
  4. import IconButton from "../../components/IconButton/IconButton";
  5. import { setCategoriesReq } from "../../store/actions/categories/categoriesAction";
  6. import { selectCategories } from "../../store/selectors/categoriesSelector";
  7. import table from "../../assets/images/table.png";
  8. import { FILES_PAGE } from "../../constants/pages";
  9. import FileTable from "./FileTable";
  10. import { useParams } from "react-router-dom";
  11. const FilesPage = ({ history }) => {
  12. const categories = useSelector(selectCategories);
  13. const dispatch = useDispatch();
  14. const [trigger, setTrigger] = useState(0);
  15. let { id } = useParams();
  16. useEffect(() => {
  17. if (id === undefined) {
  18. dispatch(setCategoriesReq(undefined));
  19. } else {
  20. dispatch(setCategoriesReq({ parentCategoryId: id }));
  21. }
  22. }, [id]);
  23. const getNameHandler = (name) => {
  24. if (name.length > 15) return name.substr(0, 15) + "...";
  25. return name;
  26. };
  27. return (
  28. <>
  29. <div className="l-t-rectangle"></div>
  30. <div className="r-b-rectangle"></div>
  31. <div
  32. className="pl-144"
  33. style={{ paddingTop: "36px" }}
  34. onClick={() => {
  35. setTrigger((trigger) => trigger + 1);
  36. }}
  37. >
  38. <div style={{ marginBottom: "50px" }}>
  39. <div style={{ marginBottom: "30px" }}>
  40. <h1 className="page-heading">Folderi</h1>
  41. </div>
  42. <div className="files-page-categories">
  43. {categories &&
  44. categories.map((category) => (
  45. <div
  46. className="files-page-categories-category"
  47. key={category.id}
  48. >
  49. <IconButton
  50. className="c-btn c-btn--primary-outlined files-page-category-button"
  51. data-testid="pattern-details-send-email"
  52. onClick={() =>
  53. history.push({
  54. pathname: FILES_PAGE + "/" + category.id,
  55. })
  56. }
  57. >
  58. <img
  59. style={{
  60. marginRight: "5px",
  61. width: "12px",
  62. height: "12px",
  63. }}
  64. src={table}
  65. />
  66. {getNameHandler(category.name)}
  67. </IconButton>
  68. </div>
  69. ))}
  70. </div>
  71. </div>
  72. <div style={{ marginBottom: "50px" }}>
  73. <div style={{ marginBottom: "30px" }}>
  74. <h1 className="page-heading">Fajlovi</h1>
  75. </div>
  76. <div className="files-page-categories">
  77. <FileTable trigger={trigger} />
  78. </div>
  79. </div>
  80. </div>
  81. </>
  82. );
  83. };
  84. FilesPage.propTypes = {
  85. history: PropTypes.shape({
  86. replace: PropTypes.func,
  87. push: PropTypes.func,
  88. location: PropTypes.shape({
  89. pathname: PropTypes.string,
  90. }),
  91. }),
  92. };
  93. export default FilesPage;