Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions src/components/Reports/PeopleTableDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
import styles from './PeopleTableDetails.module.css';
import TableFilter from './TableFilter/TableFilter';

/**
* TaskResourceCell Component
* Renders the primary profile pictures for assigned resources (up to 2),
* a collapse/expand toggle button for additional resources, and a hidden/visible
* container for extra resources when expanded.
*/
export function TaskResourceCell({
row,
column,
Expand Down Expand Up @@ -57,6 +63,10 @@
);
}

/**
* YesNoCell Component
* Renders a centered checkmark for 'Yes' values or a cross mark otherwise.
*/
export function YesNoCell({ value }) {
return (
<div style={{ textAlign: 'center' }}>
Expand All @@ -65,11 +75,21 @@
);
}

/**
* CenteredValueCell Component
* Renders any standard text value centered within its table cell.
*/
export function CenteredValueCell({ value }) {
return <div style={{ textAlign: 'center' }}>{value}</div>;
}

/**
* PeopleTableDetails Main Component
* Manages filtering states, table data configuration using react-table,
* desktop table layout, and responsive mobile card view.
*/
function PeopleTableDetails(props) {
// Filter search states
const [name, setName] = useState('');
const [priority, setPriority] = useState('');
const [status, setStatus] = useState('');
Expand Down Expand Up @@ -140,7 +160,6 @@
return filteredList;
};

// REFACTORED: Toggle using state instead of direct DOM manipulation
const toggleMoreResources = useCallback((id) => {
setExpandedTasks((prev) => ({
...prev,
Expand Down Expand Up @@ -244,6 +263,7 @@
Clear Filters
</button>
</div>

<div className={styles['people-table-scrollable']}>
<table {...getTableProps()} className={styles.peopleTableReact}>
<thead className={darkMode ? styles['reports-table-head-dark'] : undefined}>
Expand Down Expand Up @@ -283,8 +303,53 @@
</tbody>
</table>
</div>

<div className={styles['mobileCardContainer']}>
{filteredTasks.map((task) => (
<div key={task._id} className={`${styles['task-card']} ${darkMode ? styles['task-card-dark'] : ''}`}>
<div className={styles['task-header']}>
<span className={styles['people-report-task-name']}>{task.taskName}</span>
<span className={styles['task-status']}>{task.status || 'Started'}</span>
</div>
<div className={styles['task-details']}>
<div className={styles['task-info']}>
<div className={styles['sub-head']}>Priority</div>
<div className={styles['sub-details']}>{task.priority}</div>
</div>
<div className={styles['task-info']}>
<div className={styles['sub-head']}>Resources</div>
<div className={styles['sub-details']}>
{(task.resources || []).flat().map((res, i) => (
<img key={i} alt={res.name} src={res.profilePic || '/pfp-default.png'} className={styles['img-circle']} />

Check warning on line 323 in src/components/Reports/PeopleTableDetails.jsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not use Array index in keys

See more on https://sonarcloud.io/project/issues?id=OneCommunityGlobal_HighestGoodNetworkApp&issues=AaBqC9aGE8II2voIQyJX&open=AaBqC9aGE8II2voIQyJX&pullRequest=5503
))}
</div>
</div>
<div className={styles['task-info']}>
<div className={styles['sub-head']}>Active</div>
<div className={styles['sub-details']}>{task.active}</div>
</div>
<div className={styles['task-info']}>
<div className={styles['sub-head']}>Assign</div>
<div className={styles['sub-details']}>{task.assign}</div>
</div>
<div className={styles['task-info']}>
<div className={styles['sub-head']}>Estimated Hours</div>
<div className={styles['sub-details']}>{task.estimatedHours}</div>
</div>
<div className={styles['task-info']}>
<div className={styles['sub-head']}>Start Date</div>
<div className={styles['sub-details']}>{task.startDate}</div>
</div>
<div className={styles['task-info']}>
<div className={styles['sub-head']}>End Date</div>
<div className={styles['sub-details']}>{task.endDate}</div>
</div>
</div>
</div>
))}
</div>
</>
);
}

export default PeopleTableDetails;
export default PeopleTableDetails;
Loading
Loading