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.

FilesPage.js 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 {
  7. selectCategories,
  8. selectChildParentRelations,
  9. } from "../../store/selectors/categoriesSelector";
  10. import table from "../../assets/images/table.png";
  11. import { FILES_PAGE } from "../../constants/pages";
  12. import FileTable from "./FileTable";
  13. import { useParams } from "react-router-dom";
  14. const FilesPage = ({ history }) => {
  15. const categories = useSelector(selectCategories);
  16. const childParentRelations = useSelector(selectChildParentRelations);
  17. const dispatch = useDispatch();
  18. const [trigger, setTrigger] = useState(0);
  19. let { id } = useParams();
  20. useEffect(() => {
  21. if (id === undefined) {
  22. dispatch(setCategoriesReq(undefined));
  23. } else {
  24. dispatch(setCategoriesReq({ parentCategoryId: id }));
  25. }
  26. }, [id]);
  27. const getNameHandler = (name) => {
  28. if (name.length > 15) return name.substr(0, 15) + "...";
  29. return name;
  30. };
  31. const ColoredLine = () => (
  32. <hr
  33. style={{
  34. color: "#F5F5F5",
  35. backgroundColor: "#F5F5F5",
  36. height: 1,
  37. }}
  38. />
  39. );
  40. return (
  41. <>
  42. <div className="l-t-rectangle"></div>
  43. <div className="r-b-rectangle"></div>
  44. <div
  45. className="pl-144"
  46. style={{ paddingTop: "36px" }}
  47. onClick={() => {
  48. setTrigger((trigger) => trigger + 1);
  49. }}
  50. >
  51. <div style={{ marginBottom: "50px" }}>
  52. <div style={{ marginBottom: "30px" }}>
  53. <h1 className="page-heading">Folderi</h1>
  54. <ColoredLine />
  55. <div className="page-navigation-buttons">
  56. <div
  57. onClick={() => history.push({ pathname: FILES_PAGE })}
  58. style={{ marginLeft: 0 }}
  59. className="files-file-routing"
  60. >
  61. Root
  62. </div>
  63. {childParentRelations.map((relation) => (
  64. <div
  65. style={{ display: "flex", alignItems: "center" }}
  66. key={relation.id}
  67. >
  68. <span
  69. style={{
  70. cursor: "auto",
  71. color: "#A9A9A9",
  72. fontWeight: "bold",
  73. marginLeft: "10px",
  74. }}
  75. >
  76. &gt;
  77. </span>
  78. <div
  79. className="files-file-routing"
  80. onClick={() => history.push({ pathname: relation.id })}
  81. >
  82. {relation.name}
  83. </div>
  84. </div>
  85. ))}
  86. </div>
  87. <ColoredLine />
  88. </div>
  89. <div className="files-page-categories">
  90. {categories &&
  91. categories.map((category) => (
  92. <div
  93. className="files-page-categories-category"
  94. key={category.id}
  95. >
  96. <IconButton
  97. className="c-btn c-btn--primary-outlined files-page-category-button"
  98. data-testid="pattern-details-send-email"
  99. onClick={() =>
  100. history.push({
  101. pathname: FILES_PAGE + "/" + category.id,
  102. })
  103. }
  104. >
  105. <img
  106. style={{
  107. marginRight: "5px",
  108. width: "12px",
  109. height: "12px",
  110. }}
  111. src={table}
  112. />
  113. {getNameHandler(category.name)}
  114. </IconButton>
  115. </div>
  116. ))}
  117. </div>
  118. </div>
  119. <div style={{ marginBottom: "50px" }}>
  120. <div style={{ marginBottom: "30px" }}>
  121. <h1 className="page-heading">Fajlovi</h1>
  122. </div>
  123. <div className="files-page-categories">
  124. <FileTable trigger={trigger} />
  125. </div>
  126. </div>
  127. </div>
  128. </>
  129. );
  130. };
  131. FilesPage.propTypes = {
  132. history: PropTypes.shape({
  133. replace: PropTypes.func,
  134. push: PropTypes.func,
  135. location: PropTypes.shape({
  136. pathname: PropTypes.string,
  137. }),
  138. }),
  139. setFile: PropTypes.func,
  140. };
  141. export default FilesPage;