Skip to content

Commit

Permalink
toolbar moved to seperate component, along with logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathanko52 committed Aug 22, 2024
1 parent 63ac2d9 commit 984e00d
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 36 deletions.
25 changes: 25 additions & 0 deletions client/src/components/Projects/ProjectFilterModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import { createUseStyles } from "react-jss";
// import PropTypes from "prop-types";
import "reactjs-popup/dist/index.css";

const useStyles = createUseStyles({
modal: {
color: "#012962"
}
});

const ProjectTableHeader = () => {
const classes = useStyles();

return (
<div className={classes.modal}>
<div>Sort Options</div>
<div>Search Options</div>
</div>
);
};

ProjectTableHeader.propTypes = {};

export default ProjectTableHeader;
80 changes: 44 additions & 36 deletions client/src/components/Projects/ProjectsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import { useNavigate } from "react-router-dom";
import { createUseStyles } from "react-jss";
import UserContext from "../../contexts/UserContext.js";
import { MdFilterAlt, MdArrowDropDown, MdArrowDropUp } from "react-icons/md";
import { MdFilterAlt } from "react-icons/md";
import SearchIcon from "../../images/search.png";
import Pagination from "../UI/Pagination.js";
import ContentContainerNoSidebar from "../Layout/ContentContainerNoSidebar";
Expand All @@ -14,6 +14,7 @@ import * as projectService from "../../services/project.service";
import SnapshotProjectModal from "./SnapshotProjectModal";
import RenameSnapshotModal from "./RenameSnapshotModal";

import ProjectTableHeader from "./ProjectsTableHeader.js";
import DeleteProjectModal from "./DeleteProjectModal";
import CopyProjectModal from "./CopyProjectModal";
import CsvModal from "./CsvModal.js";
Expand Down Expand Up @@ -565,39 +566,39 @@ const ProjectsPage = ({ contentContainerRef }) => {
return true;
};

const headerData = [
{
id: "checkAllProjects",
label: (
<input
style={{
height: "15px"
}}
type="checkbox"
checked={selectAllChecked}
onChange={handleHeaderCheckbox}
/>
)
},
{
id: "dateHidden",
label: "Visibility"
},
{
id: "dateSnapshotted",
label: "Status"
},
{ id: "name", label: "Name" },
{ id: "address", label: "Address" },
{ id: "VERSION_NO", label: "Alternative Number" },
{ id: "firstName", label: "Created By" },
{ id: "dateCreated", label: "Created On" },
{ id: "dateModified", label: "Last Modified" },
{
id: "contextMenu",
label: ""
}
];
// const headerData = [
// {
// id: "checkAllProjects",
// label: (
// <input
// style={{
// height: "15px"
// }}
// type="checkbox"
// checked={selectAllChecked}
// onChange={handleHeaderCheckbox}
// />
// )
// },
// {
// id: "dateHidden",
// label: "Visibility"
// },
// {
// id: "dateSnapshotted",
// label: "Status"
// },
// { id: "name", label: "Name" },
// { id: "address", label: "Address" },
// { id: "VERSION_NO", label: "Alternative Number" },
// { id: "firstName", label: "Created By" },
// { id: "dateCreated", label: "Created On" },
// { id: "dateModified", label: "Last Modified" },
// {
// id: "contextMenu",
// label: ""
// }
// ];

const indexOfLastPost = currentPage * projectsPerPage;
const indexOfFirstPost = indexOfLastPost - projectsPerPage;
Expand Down Expand Up @@ -695,7 +696,7 @@ const ProjectsPage = ({ contentContainerRef }) => {
<div className={classes.tableContainer}>
<table className={classes.table}>
<thead className={classes.thead}>
<tr className={classes.tr}>
{/* <tr className={classes.tr}>
{headerData.map(header => {
const label = header.label;
return (
Expand Down Expand Up @@ -731,7 +732,14 @@ const ProjectsPage = ({ contentContainerRef }) => {
</td>
);
})}
</tr>
</tr> */}
<ProjectTableHeader
handleSort={handleSort}
selectAllChecked={selectAllChecked}
handleHeaderCheckbox={handleHeaderCheckbox}
order={order}
orderBy={orderBy}
/>
</thead>
<tbody className={classes.tbody}>
{projects.length ? (
Expand Down
112 changes: 112 additions & 0 deletions client/src/components/Projects/ProjectsTableHeader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import React from "react";
// import { useState } from "react";
import { createUseStyles } from "react-jss";
import PropTypes from "prop-types";
import { MdArrowDropDown, MdArrowDropUp, MdFilterList } from "react-icons/md";
import "reactjs-popup/dist/index.css";

const useStyles = createUseStyles({
tr: {
background: "#EEF1F4",
color: "#000000"
},
sortArrow: {
margin: "0 0 0 0.5em",
verticalAlign: "baseline",
fontSize: "20px"
// color: "#00F"
}
});

const ProjectTableHeader = ({
handleSort,
selectAllChecked,
handleHeaderCheckbox,
order,
orderBy
}) => {
const classes = useStyles();

const headerData = [
{
id: "checkAllProjects",
label: (
<input
style={{
height: "15px"
}}
type="checkbox"
checked={selectAllChecked}
onChange={handleHeaderCheckbox}
/>
)
},
{
id: "dateHidden",
label: "Visibility"
},
{
id: "dateSnapshotted",
label: "Status"
},
{ id: "name", label: "Name" },
{ id: "address", label: "Address" },
{ id: "VERSION_NO", label: "Alternative Number" },
{ id: "firstName", label: "Created By" },
{ id: "dateCreated", label: "Created On" },
{ id: "dateModified", label: "Last Modified" },
{
id: "contextMenu",
label: ""
}
];

console.log("ORDER", order);

return (
<tr className={classes.tr}>
{headerData.map(header => {
const label = header.label;
return (
<td
key={header.id}
className={
header.id === "contextMenu"
? `${classes.td}`
: `${classes.td} ${classes.theadLabel}`
}
onClick={
header.id == "contextMenu" ? null : () => handleSort(header.id)
}
>
{orderBy === header.id ? (
<span className={classes.labelSpan}>
{label}{" "}
{order === "asc" ? (
<MdArrowDropDown className={classes.sortArrow} />
) : (
<MdArrowDropUp className={classes.sortArrow} />
)}
</span>
) : (
<span className={classes.labelSpan}>{label}</span>
)}
<span className={classes.labelSpan}>
<MdFilterList className={classes.sortArrow} />
</span>
</td>
);
})}
</tr>
);
};

ProjectTableHeader.propTypes = {
handleSort: PropTypes.function,
selectAllChecked: PropTypes.boolean,
handleHeaderCheckbox: PropTypes.function,
order: PropTypes.string,
orderBy: PropTypes.string
};

export default ProjectTableHeader;

0 comments on commit 984e00d

Please sign in to comment.