Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public BirthDayServicesImpl(MemberProfileServices memberProfileServices) {
public List<BirthDayResponseDTO> findByValue(String[] months, Integer[] daysOfMonth) {
Set<MemberProfile> memberProfiles = memberProfileServices.findByValues(null, null, null, null, null, null, false);
List<MemberProfile> memberProfileAll = new ArrayList<>(memberProfiles);
if (months == null && daysOfMonth == null) {
// If nothing was passed in, get all members without birthdays.
memberProfileAll = memberProfileAll
.stream()
.filter(member -> member.getBirthDate() == null)
.toList();
}
if (months != null) {
for (String month : months) {
if (month != null) {
Expand Down Expand Up @@ -66,7 +73,9 @@ private List<BirthDayResponseDTO> profileToBirthDateResponseDto(List<MemberProfi
BirthDayResponseDTO birthDayResponseDTO = new BirthDayResponseDTO();
birthDayResponseDTO.setUserId(member.getId());
birthDayResponseDTO.setName(member.getFirstName() + "" +member.getLastName());
birthDayResponseDTO.setBirthDay(member.getBirthDate().getMonthValue() + "/" +member.getBirthDate().getDayOfMonth());
if (member.getBirthDate() != null) {
birthDayResponseDTO.setBirthDay(member.getBirthDate().getMonthValue() + "/" +member.getBirthDate().getDayOfMonth());
}
birthDays.add(birthDayResponseDTO);
}
}
Expand Down
22 changes: 19 additions & 3 deletions web-ui/src/api/birthdayanniversary.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,28 @@ export const getTodaysCelebrations = async cookie => {

export const getBirthdays = async (months, cookie) => {
const results = [];
for (let month of months) {
if (months) {
for (let month of months) {
const res = await resolve({
url: `${birthdayReportUrl}?month=${month}`,
headers: { 'X-CSRF-Header': cookie, Accept: 'application/json' }
});
if (res.error) {
console.error(res.error);
} else {
results.push(...res.payload.data);
}
}
} else {
const res = await resolve({
url: `${birthdayReportUrl}?month=${month}`,
url: birthdayReportUrl,
headers: { 'X-CSRF-Header': cookie, Accept: 'application/json' }
});
results.push(...res.payload.data);
if (res.error) {
console.error(res.error);
} else {
results.push(...res.payload.data);
}
}
return results;
};
1 change: 0 additions & 1 deletion web-ui/src/pages/BirthdayAnniversaryReportPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

.select-month {
display: flex;
justify-content: space-between;
align-items: center;
margin-left: 15px;
margin-right: 10px;
Expand Down
21 changes: 18 additions & 3 deletions web-ui/src/pages/BirthdayReportPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useState } from 'react';

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

import { Button, TextField } from '@mui/material';
import { FormControlLabel, Switch, Button, TextField } from '@mui/material';
import Autocomplete from '@mui/material/Autocomplete';

import './BirthdayAnniversaryReportPage.css';
Expand Down Expand Up @@ -45,6 +45,7 @@ const BirthdayReportPage = () => {
const [selectedMonths, setSelectedMonths] = useState(defaultMonths);
const [hasSearched, setHasSearched] = useState(false);
const [loading, setLoading] = useState(false);
const [noBirthday, setNoBirthday] = useState(false);

useQueryParameters([
{
Expand All @@ -61,7 +62,8 @@ const BirthdayReportPage = () => {
const handleSearch = async monthsToSearch => {
setLoading(true);
try {
const birthdayResults = await getBirthdays(monthsToSearch, csrf);
const birthdayResults = await getBirthdays(noBirthday ? null :
monthsToSearch, csrf);
setSearchBirthdayResults(sortBirthdays(birthdayResults));
setHasSearched(true);
} catch(e) {
Expand Down Expand Up @@ -101,12 +103,25 @@ const BirthdayReportPage = () => {
placeholder="Choose a month"
/>
)}
disabled={noBirthday}
/>
<FormControlLabel
control={
<Switch
checked={noBirthday}
onChange={event => {
const { checked } = event.target;
setNoBirthday(checked);
}}
/>
}
label="No Birthday Registered"
/>
</div>
<div className="birthday-anniversary-search halfWidth">
<Button
onClick={() => {
if (!selectedMonths) {
if (!noBirthday && selectedMonths.length == 0) {
window.snackDispatch({
type: UPDATE_TOAST,
payload: {
Expand Down
30 changes: 30 additions & 0 deletions web-ui/src/pages/__snapshots__/BirthdayReportPage.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,36 @@ exports[`renders correctly 1`] = `
</div>
</div>
</div>
<label
class="MuiFormControlLabel-root MuiFormControlLabel-labelPlacementEnd css-j204z7-MuiFormControlLabel-root"
>
<span
class="MuiSwitch-root MuiSwitch-sizeMedium css-julti5-MuiSwitch-root"
>
<span
class="MuiButtonBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary PrivateSwitchBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary css-byenzh-MuiButtonBase-root-MuiSwitch-switchBase"
>
<input
class="PrivateSwitchBase-input MuiSwitch-input css-1m9pwf3"
type="checkbox"
/>
<span
class="MuiSwitch-thumb css-jsexje-MuiSwitch-thumb"
/>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</span>
<span
class="MuiSwitch-track css-1yjjitx-MuiSwitch-track"
/>
</span>
<span
class="MuiTypography-root MuiTypography-body1 MuiFormControlLabel-label css-ahj2mt-MuiTypography-root"
>
No Birthday Registered
</span>
</label>
</div>
<div
class="birthday-anniversary-search halfWidth"
Expand Down