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
7 changes: 6 additions & 1 deletion src/components/TeamMemberTasks/TeamMemberTask.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import PropTypes from 'prop-types';
import React, { useRef, useState, useEffect } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { Modal, ModalBody, ModalFooter, ModalHeader, Progress, Table } from 'reactstrap';
import CopyToClipboard from '~/components/common/Clipboard/CopyToClipboard';
import UserStateDisplay from '../UserState/UserStateDisplay';
Expand Down Expand Up @@ -53,6 +53,7 @@ const TeamMemberTask = React.memo(
onCatalogChange,
userStateSelection = [],
onSelectionChange,
expandAll = false,
}) => {
const darkMode = useSelector(state => state.theme.darkMode);
const taskCounts = useSelector(state => state.dashboard?.taskCounts ?? {});
Expand Down Expand Up @@ -133,6 +134,9 @@ const TeamMemberTask = React.memo(

const canTruncate = activeTasks.length > NUM_TASKS_SHOW_TRUNCATE;
const [isTruncated, setIsTruncated] = useState(canTruncate);
useEffect(() => {
if (canTruncate) setIsTruncated(!expandAll);
}, [expandAll, canTruncate]);
const [isTimeOffContentOpen, setIsTimeOffContentOpen] = useState(
showWhoHasTimeOff && (onTimeOff || goingOnTimeOff),
);
Expand Down Expand Up @@ -831,6 +835,7 @@ TeamMemberTask.propTypes = {
onCatalogChange: PropTypes.func,
userStateSelection: PropTypes.array,
onSelectionChange: PropTypes.func,
expandAll: PropTypes.bool,
};

TeamMemberTask.displayName = 'TeamMemberTask';
Expand Down
16 changes: 14 additions & 2 deletions src/components/TeamMemberTasks/TeamMemberTasks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
const [userStateCatalog, setUserStateCatalog] = useState([]);
const [userStateSelections, setUserStateSelections] = useState({});
const [selectionsLoaded, setSelectionsLoaded] = useState(false);
const [expandAll, setExpandAll] = useState(false);

useEffect(() => {
axios
Expand All @@ -78,7 +79,10 @@

// Fetch all selections in ONE call once teamList is ready
useEffect(() => {
if (usersWithTasks.length === 0) return;
if (usersWithTasks.length === 0) {

Check warning on line 82 in src/components/TeamMemberTasks/TeamMemberTasks.jsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'usersWithTasks.length' is missing in props validation

See more on https://sonarcloud.io/project/issues?id=OneCommunityGlobal_HighestGoodNetworkApp&issues=AZ4eACrDvZ6q5f_-uKbu&open=AZ4eACrDvZ6q5f_-uKbu&pullRequest=5262
setSelectionsLoaded(true);
return;
}
const userIds = usersWithTasks.map(u => u.personId);
axios
.post(ENDPOINTS.USER_STATE_SELECTIONS_BATCH, { userIds })
Expand Down Expand Up @@ -448,6 +452,13 @@
<header className={styles['header-box']}>
<section className={[styles.dFlex, styles.flexColumn].join(' ')}>
<h1 className={darkMode ? styles.textLight : ''}>Team Member Tasks</h1>
<button
type="button"
className={`btn btn-sm ${darkMode ? 'btn-outline-light' : 'btn-outline-secondary'}`}
onClick={() => setExpandAll(prev => !prev)}
>
{expandAll ? 'Truncate All' : 'Expand All'}
</button>
</section>

{finishLoading ? (
Expand Down Expand Up @@ -762,10 +773,10 @@
onSelectionChange={(uid, updated) =>
setUserStateSelections(prev => ({ ...prev, [uid]: updated }))
}
expandAll={expandAll}
/>
);
}

return (
<Fragment key={user.personId}>
<TeamMemberTask
Expand Down Expand Up @@ -794,6 +805,7 @@
onSelectionChange={(uid, updated) =>
setUserStateSelections(prev => ({ ...prev, [uid]: updated }))
}
expandAll={expandAll}
/>

{timeEntriesList.length > 0 &&
Expand Down
Loading