Skip to content

Conversation

@mvolkmann
Copy link
Collaborator

No description provided.

const birthdayReportUrl = "/services/reports/birthdays";
const celebrationsToday = "/services/today";

export const getAnniversary = async (month, cookie) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to create the branch for this PR from the feature-2209-birthdays-bug branch because I needed those fixes for the changes to work. So some of the changes here are really from that branch.

import React, { useContext, useEffect, useRef, useState } from "react";

import { postEmployeeHours } from "../../api/hours";
import {reportAllMembersCsv} from "../../api/member"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes here are from Prettier. I'll add more comments to describe all the non-Prettier changes.

const links = []

if (selectHasBirthdayAnniversaryReportPermission(state)) {
links.push(["/birthday-anniversary-reports", "Birthdays & Anniversaries"]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link was replaced by two links below, one for Birthdays and one for Anniversaries.

links.push(["/checkins-reports", "Check-ins"]);
}
if (selectHasBirthdayAnniversaryReportPermission(state)) {
links.push(["/anniversary-reports", "Anniversaries"]);
Copy link
Collaborator Author

@mvolkmann mvolkmann Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the two new links.
All remaining changes in this file are from Prettier.


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

import BirthdayAnniversaryReportPage from "../../pages/BirthdayAnniversaryReportPage";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This route is replaced by two new routes below.


const SearchBirthdayAnniversaryResults = ({
hasSearched,
searchBirthdayResults,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of taking two arrays of results, this now only takes one because we no longer operate on both anniversaries AND birthdays.

searchBirthdayResults,
searchAnniversaryResults,
results,
anniversary,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anniversary and birthday are boolean arguments that indicate which kind of data is described by the results array. I could replace these with a single boolean parameter, but then callers would have to explicitly pass true or false instead of just using those as attributes with no value.

const bdate = new Date(b.birthDay);
return adate - bdate;
});
if (anniversary) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We sort the array differently based on whether the items represent anniversaries or birthdays.

import { Button, TextField } from "@mui/material";
import Autocomplete from "@mui/material/Autocomplete";

import "./BirthdayAnniversaryReportPage.css";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was renamed to indicate that it is only used for anniversaries, not birthdays.


import "./BirthdayAnniversaryReportPage.css";

import { getAnniversary, getBirthday } from "../api/birthdayanniversary";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything related to birthdays was removed from this file.

Run Search
</Button>
</div>
<div className="checkbox-row">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need these checkboxes since this page only deals with anniversaries.

@@ -1,16 +1,16 @@
import React from "react";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file was renamed to indicate that it tests the new AnniversaryReportPage component.

@@ -0,0 +1,110 @@
import React, { useContext, useState } from "react";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is like AnniversaryReportPage, but deals with birthdays instead of anniversaries.

@@ -0,0 +1,16 @@
import React from "react";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new test file tests the new BirthdayReportPage component.

@@ -138,30 +138,6 @@ exports[`renders correctly 1`] = `
/>
</button>
</div>
<div
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This snapshot file was updated to remove the row of checkboxes that we no longer render.

@@ -0,0 +1,156 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New snapshot file for new BirthdayReportPage component.

vhscom
vhscom previously approved these changes Apr 23, 2024
Copy link
Contributor

@vhscom vhscom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left one suggestion.


const AnniversaryMap = () => {
if (searchAnniversaryResults.length > 0) {
if (anniversary && results.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have change suggestion:

results.length > 0

To simply:

results.length

This works because results.length is truthy when the number of elements in the array is > 0. This will work for all instances where we check .length > 0, is idiomatic and a little more compact.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also prefer removing > 0. That was old code, but I'm making those changes everywhere that is done in this file.

@mkimberlin mkimberlin merged commit f5f9866 into develop Apr 24, 2024
@mkimberlin mkimberlin deleted the feature-2207-split-birthday-anniversary-reports branch April 24, 2024 02:58
@mkimberlin mkimberlin linked an issue Apr 24, 2024 that may be closed by this pull request
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split Birthdays and Anniversaries Reports

5 participants