Skip to content

OCD-5234 Code Set Indicator#1501

Open
mattystank wants to merge 3 commits intochpladmin:stagingfrom
mattystank:OCD-5234
Open

OCD-5234 Code Set Indicator#1501
mattystank wants to merge 3 commits intochpladmin:stagingfrom
mattystank:OCD-5234

Conversation

@mattystank
Copy link
Copy Markdown
Contributor

This pull request enhances the display of code set information in the ChplCriterionDetailsView component, especially for users without admin roles. It introduces a visual indicator for code set compliance, improves the code set status calculation, and refines the UI for different user roles.

Code Set Status Display Improvements:

  • Added a visual status indicator using Chip components with "Up-to-date" and "Not up-to-date" labels, including icons and explanatory text, for non-admin users viewing code set requirements.
  • Implemented the getCodeSetStatus function to determine if the listing's code sets are current with requirements, factoring in required dates and applicable code sets.
  • Applied custom styles for the code set status indicators to visually distinguish up-to-date and not-up-to-date states.

Role-Based UI Adjustments:

  • Refactored the code set display so that only admin roles see the detailed list of code sets, while other users see the new status indicator and message. [1] [2]

Dependency and Utility Updates:

  • Added necessary imports for new Material-UI components, icons, and utility functions to support the updated UI and status logic. [1] [2]

These changes improve the clarity and user experience around code set compliance for different types of users.[#OCD-5234]

@mattystank mattystank marked this pull request as ready for review April 17, 2026 19:49
@mattystank mattystank requested a review from andlar as a code owner April 17, 2026 19:49
}) {
const { hasAnyRole, user } = useContext(UserContext);
const { listing } = useContext(ListingContext);
const { data: allCodeSets } = useFetchCodeSets();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should also use the isError and isLoading elements to either leave a blank space or a processing indicator while the network call is being made

className={classes.notUpToDate}
/>
<Typography variant="body2">
{'This listing\u2019s code set does not meet the requirement that took effect'}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We generally use the HTML encoding instead of the \u encodings. My guess is this should be &apos; instead of \u2019\

Comment on lines +185 to +197
{ hasAnyRole(['chpl-admin', 'chpl-onc', 'chpl-onc-acb']) && (
<>
<List>
{ criterion.codeSets.map((cs) => (
<ListItem key={cs.id}>
{ cs.codeSet.name }
</ListItem>
))}
</List>
{ criterion.codeSets?.length === 0 && 'None' }
</>
)}
{ !hasAnyRole(['chpl-admin', 'chpl-onc', 'chpl-onc-acb']) && (() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would extract both of these out of the JSX portion of the component and make a function called something like getDisplayValue that has this same logic. We usually try to more complicated logic out of the "html-ish structure" stuff so it can be reasoned about a little more cleanly

const getCodeSetStatus = () => {
if (!allCodeSets || !criterion.codeSets) return null;
const criterionId = criterion.criterion.id;
const today = new Date().toISOString().split('T')[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need to use moment or LocalDay for this. Our mandate has been to base all date values on Eastern Time, and with this code I believe there'd be a window of time where the code set is not expired yet in ET, but expired in GMT, and so might show the tag/chip/text/whatever incorrectly. I could be wrong, but it's worth looking into

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.

2 participants