Skip to content

Conversation

@canac
Copy link
Contributor

@canac canac commented Nov 8, 2023

Description

Completed the coaching sidebar.

https://jira.cru.org/browse/MPDX-7359

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

@canac canac added the On Staging Will be merged to the staging branch by Github Actions label Nov 8, 2023
},
{
title: t('Tools'),
items: ToolsList.flatMap((toolsGroup) => [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an unrelated simplification I came across.

@aws-amplify-us-east-1
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-816.d3dytjb8adxkk5.amplifyapp.com

@canac canac requested review from caleballdrin and dr-bizz November 8, 2023 20:14
electronicDate: string | null | undefined,
physicalDate: string | null | undefined,
): string | null => {
if (electronicDate && physicalDate) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if you could simplidy this by writing. I haven't tested this. just a thought.

const lastNewsletter = new Date(Math.max([electronicDate.getTime(), physicalDate.getTime()]));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about that. But I liked how this helper function has a single concern: finding the latest date. If I used Math.max, that helper would be either be responsible for finding the latest date and parsing the string into a luxon Date or the helper would need to parse the date for the comparison and then the UI code would need to parse it again to display. Too bad Math.max doesn't work on strings, or I would definitely use it. lodash's max works on strings, but I know in the past you've discouraged using lodash methods. I'm going to leave this the way it is if that's OK.

export const CollapsibleEmailList: React.FC<CollapsibleEmailListProps> = ({
emails,
}) => {
const primaryEmail = emails.find((email) => email.primary) ?? emails[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

For readability it might be worth changing this variable to PrimaryOrFirstEmail but I'm not too fussed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I meant primary here as "the first email shown to the user" as opposed to the secondary emails that are hidden until they click on the expand icon. I can't quickly think of a different name (firstEmail seems just as inaccurate), so I lean towards leaving this as is.

@canac canac requested a review from dr-bizz November 9, 2023 17:46
Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

Looks great! Can you rename AccountListType to AccountListTypeEnum

import { CollapsiblePhoneList } from './CollapsiblePhoneList';
import { getLastNewsletter } from './helpers';

export enum AccountListType {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you rename this to AccountListTypeEnum as it makes it easier to understand what it is when imported into other files.

@canac canac requested a review from dr-bizz November 9, 2023 21:48
@canac canac merged commit fee58f3 into main Nov 14, 2023
@canac canac deleted the 7359-coaching-sidebar branch November 14, 2023 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

On Staging Will be merged to the staging branch by Github Actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants