Skip to content

Commit 6318fa6

Browse files
authored
Merge pull request #2745 from objectcomputing/bugfix-2741/allow-search-for-missing-birthdays
Bugfix 2741/allow search for missing birthdays
2 parents ce2ec7b + f376644 commit 6318fa6

File tree

5 files changed

+77
-8
lines changed

5 files changed

+77
-8
lines changed

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/birthday/BirthDayServicesImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public BirthDayServicesImpl(MemberProfileServices memberProfileServices) {
2323
public List<BirthDayResponseDTO> findByValue(String[] months, Integer[] daysOfMonth) {
2424
Set<MemberProfile> memberProfiles = memberProfileServices.findByValues(null, null, null, null, null, null, false);
2525
List<MemberProfile> memberProfileAll = new ArrayList<>(memberProfiles);
26+
if (months == null && daysOfMonth == null) {
27+
// If nothing was passed in, get all members without birthdays.
28+
memberProfileAll = memberProfileAll
29+
.stream()
30+
.filter(member -> member.getBirthDate() == null)
31+
.toList();
32+
}
2633
if (months != null) {
2734
for (String month : months) {
2835
if (month != null) {
@@ -66,7 +73,9 @@ private List<BirthDayResponseDTO> profileToBirthDateResponseDto(List<MemberProfi
6673
BirthDayResponseDTO birthDayResponseDTO = new BirthDayResponseDTO();
6774
birthDayResponseDTO.setUserId(member.getId());
6875
birthDayResponseDTO.setName(member.getFirstName() + "" +member.getLastName());
69-
birthDayResponseDTO.setBirthDay(member.getBirthDate().getMonthValue() + "/" +member.getBirthDate().getDayOfMonth());
76+
if (member.getBirthDate() != null) {
77+
birthDayResponseDTO.setBirthDay(member.getBirthDate().getMonthValue() + "/" +member.getBirthDate().getDayOfMonth());
78+
}
7079
birthDays.add(birthDayResponseDTO);
7180
}
7281
}

web-ui/src/api/birthdayanniversary.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,28 @@ export const getTodaysCelebrations = async cookie => {
2525

2626
export const getBirthdays = async (months, cookie) => {
2727
const results = [];
28-
for (let month of months) {
28+
if (months) {
29+
for (let month of months) {
30+
const res = await resolve({
31+
url: `${birthdayReportUrl}?month=${month}`,
32+
headers: { 'X-CSRF-Header': cookie, Accept: 'application/json' }
33+
});
34+
if (res.error) {
35+
console.error(res.error);
36+
} else {
37+
results.push(...res.payload.data);
38+
}
39+
}
40+
} else {
2941
const res = await resolve({
30-
url: `${birthdayReportUrl}?month=${month}`,
42+
url: birthdayReportUrl,
3143
headers: { 'X-CSRF-Header': cookie, Accept: 'application/json' }
3244
});
33-
results.push(...res.payload.data);
45+
if (res.error) {
46+
console.error(res.error);
47+
} else {
48+
results.push(...res.payload.data);
49+
}
3450
}
3551
return results;
3652
};

web-ui/src/pages/BirthdayAnniversaryReportPage.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
.select-month {
2222
display: flex;
23-
justify-content: space-between;
2423
align-items: center;
2524
margin-left: 15px;
2625
margin-right: 10px;

web-ui/src/pages/BirthdayReportPage.jsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useContext, useState } from 'react';
22

33
import { AppContext } from '../context/AppContext';
44

5-
import { Button, TextField } from '@mui/material';
5+
import { FormControlLabel, Switch, Button, TextField } from '@mui/material';
66
import Autocomplete from '@mui/material/Autocomplete';
77

88
import './BirthdayAnniversaryReportPage.css';
@@ -45,6 +45,7 @@ const BirthdayReportPage = () => {
4545
const [selectedMonths, setSelectedMonths] = useState(defaultMonths);
4646
const [hasSearched, setHasSearched] = useState(false);
4747
const [loading, setLoading] = useState(false);
48+
const [noBirthday, setNoBirthday] = useState(false);
4849

4950
useQueryParameters([
5051
{
@@ -61,7 +62,8 @@ const BirthdayReportPage = () => {
6162
const handleSearch = async monthsToSearch => {
6263
setLoading(true);
6364
try {
64-
const birthdayResults = await getBirthdays(monthsToSearch, csrf);
65+
const birthdayResults = await getBirthdays(noBirthday ? null :
66+
monthsToSearch, csrf);
6567
setSearchBirthdayResults(sortBirthdays(birthdayResults));
6668
setHasSearched(true);
6769
} catch(e) {
@@ -101,12 +103,25 @@ const BirthdayReportPage = () => {
101103
placeholder="Choose a month"
102104
/>
103105
)}
106+
disabled={noBirthday}
107+
/>
108+
<FormControlLabel
109+
control={
110+
<Switch
111+
checked={noBirthday}
112+
onChange={event => {
113+
const { checked } = event.target;
114+
setNoBirthday(checked);
115+
}}
116+
/>
117+
}
118+
label="No Birthday Registered"
104119
/>
105120
</div>
106121
<div className="birthday-anniversary-search halfWidth">
107122
<Button
108123
onClick={() => {
109-
if (!selectedMonths) {
124+
if (!noBirthday && selectedMonths.length == 0) {
110125
window.snackDispatch({
111126
type: UPDATE_TOAST,
112127
payload: {

web-ui/src/pages/__snapshots__/BirthdayReportPage.test.jsx.snap

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,36 @@ exports[`renders correctly 1`] = `
131131
</div>
132132
</div>
133133
</div>
134+
<label
135+
class="MuiFormControlLabel-root MuiFormControlLabel-labelPlacementEnd css-j204z7-MuiFormControlLabel-root"
136+
>
137+
<span
138+
class="MuiSwitch-root MuiSwitch-sizeMedium css-julti5-MuiSwitch-root"
139+
>
140+
<span
141+
class="MuiButtonBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary PrivateSwitchBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary css-byenzh-MuiButtonBase-root-MuiSwitch-switchBase"
142+
>
143+
<input
144+
class="PrivateSwitchBase-input MuiSwitch-input css-1m9pwf3"
145+
type="checkbox"
146+
/>
147+
<span
148+
class="MuiSwitch-thumb css-jsexje-MuiSwitch-thumb"
149+
/>
150+
<span
151+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
152+
/>
153+
</span>
154+
<span
155+
class="MuiSwitch-track css-1yjjitx-MuiSwitch-track"
156+
/>
157+
</span>
158+
<span
159+
class="MuiTypography-root MuiTypography-body1 MuiFormControlLabel-label css-ahj2mt-MuiTypography-root"
160+
>
161+
No Birthday Registered
162+
</span>
163+
</label>
134164
</div>
135165
<div
136166
class="birthday-anniversary-search halfWidth"

0 commit comments

Comments
 (0)