Skip to content

Commit 9c85d20

Browse files
committed
Fix overlapping Project box in 'Hours Completed' chart section
1 parent d144280 commit 9c85d20

3 files changed

Lines changed: 97 additions & 83 deletions

File tree

src/components/Reports/TeamReport/TeamReport.jsx

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export function TeamReport({ match }) {
3939
isActive: false,
4040
isInactive: false,
4141
});
42+
43+
// Add state for the search input value (separate from searchParams)
44+
const [searchInputValue, setSearchInputValue] = useState('');
4245
const hasFetchIds = useRef(new Set());
4346

4447
const [selectedTeams] = useState([]);
@@ -150,17 +153,7 @@ export function TeamReport({ match }) {
150153
}
151154
};
152155

153-
const debounceSearchByName = debounce(value => {
154-
setSearchParams(prevParams => ({
155-
...prevParams,
156-
teamName: value,
157-
}));
158-
}, 300);
159-
160-
function handleSearchByName(event) {
161-
event.persist();
162-
debounceSearchByName(event.target.value);
163-
}
156+
// Removed automatic search - now search only happens on button click
164157

165158
function handleCheckboxChange(event) {
166159
const { id, checked } = event.target;
@@ -201,6 +194,7 @@ export function TeamReport({ match }) {
201194
}
202195
}, [dispatch, allTeams]);
203196

197+
204198
useEffect(() => {
205199
let isMounted = true; // flag to check component mount status
206200
const fetchTeamDetails = async teamId => {
@@ -411,13 +405,47 @@ export function TeamReport({ match }) {
411405
>
412406
Name
413407
</label>
414-
<input
415-
type="text"
416-
className="form-control rounded-1 w-auto"
417-
placeholder="Search team name"
418-
id="search-by-name"
419-
onChange={event => handleSearchByName(event)}
420-
/>
408+
<div className="input-group">
409+
<input
410+
type="text"
411+
className="form-control rounded-1"
412+
placeholder="Search team name"
413+
id="search-by-name"
414+
value={searchInputValue}
415+
onChange={event => setSearchInputValue(event.target.value)}
416+
/>
417+
<div className="input-group-append">
418+
<button
419+
type="button"
420+
className={`btn ${darkMode ? 'btn-outline-light' : 'btn-outline-secondary'}`}
421+
onClick={() => {
422+
// Trigger search when button is clicked
423+
setSearchParams(prevParams => ({
424+
...prevParams,
425+
teamName: searchInputValue,
426+
}));
427+
}}
428+
title="Search teams"
429+
>
430+
🔍
431+
</button>
432+
<button
433+
type="button"
434+
className={`btn ${darkMode ? 'btn-outline-light' : 'btn-outline-secondary'}`}
435+
onClick={() => {
436+
// Clear search
437+
setSearchInputValue('');
438+
setSearchParams(prevParams => ({
439+
...prevParams,
440+
teamName: '',
441+
}));
442+
}}
443+
title="Clear search"
444+
>
445+
446+
</button>
447+
</div>
448+
</div>
421449
</div>
422450

423451
{/* Created After Date Picker */}
@@ -514,11 +542,9 @@ export function TeamReport({ match }) {
514542
</td>
515543
</tr>
516544
</thead>
517-
{allTeamsMembers && allTeamsMembers.length > 0 ? (
518-
<tbody className="table">
519-
{/* eslint-disable-next-line no-shadow */}
520-
{/* Note: the handleSearch() function will cause the white page error */}
521-
{handleSearch().map((teamData, index) => (
545+
<tbody className="table">
546+
{allTeamsMembers && allTeamsMembers.length > 0 ? (
547+
handleSearch().map((teamData, index) => (
522548
<tr className={`table-row ${darkMode ? 'bg-yinmn-blue text-light table-hover-dark' : ''}`} key={teamData._id}>
523549
<td>
524550
<input
@@ -566,23 +592,19 @@ export function TeamReport({ match }) {
566592
<td>{handleDate(teamData?.createdDatetime)}</td>
567593
<td>{handleDate(teamData?.modifiedDatetime)}</td>
568594
</tr>
569-
))}
570-
</tbody>
571-
) : (
572-
<tbody>
595+
))
596+
) : (
573597
<tr style={{ backgroundColor: darkMode ? '#3A506B' : 'white' }}>
574-
<td />
575-
<td />
576-
<td />
577-
<td>
578-
<strong className={darkMode ? 'text-light' : ''}>Loading...</strong>
598+
<td colSpan="7" className="text-center">
599+
<strong className={darkMode ? 'text-light' : ''}>
600+
{allTeamsMembers && allTeamsMembers.length === 0
601+
? 'No teams found. Please check your permissions or contact an administrator.'
602+
: 'Loading teams...'}
603+
</strong>
579604
</td>
580-
<td />
581-
<td />
582-
<td />
583605
</tr>
584-
</tbody>
585-
)}
606+
)}
607+
</tbody>
586608
</table>
587609
</ReportPage.ReportBlock>
588610
</div>

src/components/TotalOrgSummary/HoursCompleted/HoursCompletedBarChart.jsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,41 @@ export default function HoursCompletedBarChart({ isLoading, data, darkMode }) {
142142
maxHeight: '548px',
143143
display: 'flex',
144144
flexDirection: 'column',
145+
position: 'relative',
145146
}}
146147
>
148+
{/* Projects box positioned in the right side middle area */}
149+
<div
150+
style={{
151+
position: 'absolute',
152+
top: '40%',
153+
left: '65%',
154+
transform: 'translateY(-50%)',
155+
zIndex: 10,
156+
background: 'white',
157+
borderRadius: 4,
158+
padding: 8,
159+
boxShadow: '0 2px 6px rgba(0,0,0,0.15)',
160+
border: '1px solid #eee',
161+
minWidth: 130,
162+
minHeight: 65,
163+
display: 'grid',
164+
justifyItems: 'center',
165+
gap: 2,
166+
}}
167+
>
168+
<div style={{ color: '#444', fontWeight: 'bold', fontSize: 15 }}>Projects</div>
169+
<div style={{ color: '#222', fontWeight: 'bold', fontSize: 14 }}>
170+
{projectBarInfo.amount}
171+
</div>
172+
<div style={{ color: '#666', fontSize: 10 }}>({projectBarInfo.percentage})</div>
173+
{projectBarInfo.ifcompare && (
174+
<div style={{ color: projectBarInfo.fontcolor, fontSize: 10, fontWeight: 'bold' }}>
175+
{projectBarInfo.change}
176+
</div>
177+
)}
178+
</div>
179+
147180
<div style={{ textAlign: 'center', marginBottom: 0 }}>
148181
<div
149182
style={{
@@ -186,7 +219,6 @@ export default function HoursCompletedBarChart({ isLoading, data, darkMode }) {
186219
tickInterval={tickInterval}
187220
// renderCustomizedLabel={renderCustomizedLabel}
188221
darkMode={darkMode}
189-
projectBarInfo={projectBarInfo}
190222
yAxisLabel="Hours"
191223
/>
192224
</div>

src/components/TotalOrgSummary/TinyBarChart.jsx

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,6 @@ import {
1212
ReferenceLine,
1313
} from 'recharts';
1414

15-
function ProjectLabel({ viewBox, info }) {
16-
return (
17-
<foreignObject
18-
x={viewBox.x + 60}
19-
y={viewBox.y + 10}
20-
width={140}
21-
height={70}
22-
style={{ overflow: 'visible' }}
23-
>
24-
<div
25-
style={{
26-
textAlign: 'left',
27-
color: info.fontcolor,
28-
fontSize: 14,
29-
background: 'white',
30-
borderRadius: 4,
31-
padding: 6,
32-
boxShadow: '0 1px 4px #ccc',
33-
lineHeight: 1.2,
34-
border: '1px solid #eee',
35-
minWidth: 120,
36-
minHeight: 60,
37-
pointerEvents: 'none',
38-
display: 'grid',
39-
justifyItems: 'center',
40-
gap: 1,
41-
}}
42-
>
43-
<div style={{ color: '#444', fontWeight: 'bold', fontSize: 15 }}>Projects</div>
44-
<div style={{ color: '#222', fontWeight: 'bold', fontSize: 14 }}>{info.amount}</div>
45-
<div style={{ color: '#666', fontSize: 10 }}>({info.percentage})</div>
46-
{info.ifcompare && (
47-
<div style={{ color: info.fontcolor, fontSize: 10, fontWeight: 'bold' }}>
48-
{info.change}
49-
</div>
50-
)}
51-
</div>
52-
</foreignObject>
53-
);
54-
}
55-
5615
export default function TinyBarChart(props) {
5716
const {
5817
chartData,
@@ -65,12 +24,13 @@ export default function TinyBarChart(props) {
6524
} = props;
6625

6726
return (
68-
<ResponsiveContainer maxWidth={600} maxHeight={400} minWidth={180} minHeight={340}>
27+
<ResponsiveContainer width="100%" height="100%" maxHeight={400} minWidth={180} minHeight={340}>
6928
<BarChart
7029
data={chartData}
7130
margin={{
7231
top: 50,
7332
bottom: 40,
33+
left: 40,
7434
right: 20,
7535
}}
7636
>
@@ -86,10 +46,11 @@ export default function TinyBarChart(props) {
8646
value: yAxisLabel,
8747
angle: -90,
8848
position: 'insideLeft',
89-
offset: 20,
49+
offset: 5,
9050
fill: darkMode ? 'white' : '#444',
91-
fontSize: 14,
51+
fontSize: 12,
9252
fontWeight: 'bold',
53+
style: { textAnchor: 'middle' },
9354
}}
9455
/>
9556
<Tooltip content={<CustomTooltip />} cursor={{ fill: 'transparent' }} />
@@ -105,7 +66,6 @@ export default function TinyBarChart(props) {
10566
stroke={darkMode ? 'lightgreen' : 'green'}
10667
strokeDasharray="6 6"
10768
ifOverflow="extendDomain"
108-
label={<ProjectLabel info={projectBarInfo} />}
10969
/>
11070
)}
11171
</BarChart>

0 commit comments

Comments
 (0)