Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPDX-7865 Rename Contact Statuses #898

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

caleballdrin
Copy link
Contributor

Description

https://jira.cru.org/secure/RapidBoard.jspa?rapidView=3&view=detail&selectedIssue=MPDX-7865#

  • Remove hard-coded statuses
  • Create object from StatusEnum with translated name and phase
  • Set default status when a contact is created

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

@caleballdrin caleballdrin self-assigned this Mar 22, 2024
Copy link

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

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

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.

I left some comments. I know this is still in review, so I didn't highlight everything.

src/lib/MPDPhases.ts Show resolved Hide resolved
src/components/Shared/Filters/FilterPanel.tsx Show resolved Hide resolved
Copy link
Contributor

@canac canac left a comment

Choose a reason for hiding this comment

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

I see several TODOs left, but what you have looks pretty good so far!

src/lib/MPDPhases.ts Show resolved Hide resolved
src/hooks/useContactPhaseData.ts Show resolved Hide resolved
}, [activity]);

return [phaseData, setActivity];
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it seems that activity is only being used for the useEffect, I think it might be cleaner to remove the activity useState and return a setActivity function. I think it's also better to return an object from the hook instead of a tuple so that it's super clear what each of the members are.

const phaseFromActivity = (
  activity: PhaseTypeEnum | null,
): ContactPhaseData | null => {
  if (activity) {
    return (
      allPhaseData.find((phase) => phase.phase === activity.toLowerCase()) ??
      null
    );
  }

  return null;
};

export const useGetPhaseData = (
  activityId: PhaseTypeEnum | null,
): UseGetPhaseData => {
  const [phaseData, setPhaseData] = useState<ContactPhaseData | null>(
    phaseFromActivity(activityId),
  );

  const setActivity = useCallback((activity: PhaseTypeEnum | null) => {
    setPhaseData(phaseFromActivity(activity));
  }, []);

  return { phaseData, setActivity };
};

src/lib/MPDPhases.ts Show resolved Hide resolved
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.

3 participants