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

feat: adding Learner Detail Page component + route #1436

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kiram15
Copy link
Contributor

@kiram15 kiram15 commented Feb 28, 2025

Screenshot 2025-02-27 at 4 41 17 PM Screenshot 2025-02-28 at 7 54 20 AM Screenshot 2025-02-28 at 7 55 39 AM

Jira ticket

For all changes

  • Checkout kiram15/ENT-10006 and run npm run test:stage
  • Go to People Management page to click on View more button
  • Ensure there are only 2 breadcrumbs on LearnerDetailPage
  • Navigate to Group Detail page, and click on hyperlink on user's name
  • Ensure there are 3 breadcrumbs, one to the group
  • Turn off the toggle here, and then make sure you can't see the View more button or the user's name hyperlink

Testing plan

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

@kiram15 kiram15 requested review from katrinan029 and a team February 28, 2025 11:14
Copy link

codecov bot commented Feb 28, 2025

Codecov Report

Attention: Patch coverage is 86.84211% with 5 lines in your changes missing coverage. Please review.

Project coverage is 86.41%. Comparing base (02cc629) to head (d57766c).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/components/PeopleManagement/OrgMemberCard.jsx 33.33% 4 Missing ⚠️
...Management/LearnerDetailPage/LearnerDetailPage.jsx 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1436      +/-   ##
==========================================
- Coverage   86.48%   86.41%   -0.07%     
==========================================
  Files         660      661       +1     
  Lines       14936    14968      +32     
  Branches     3164     3177      +13     
==========================================
+ Hits        12917    12935      +18     
- Misses       1952     1969      +17     
+ Partials       67       64       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


const LearnerDetailPage = ({ enterpriseUUID }) => {
const { enterpriseSlug, groupUuid, learnerId } = useParams();
const { data: enterpriseGroup } = useEnterpriseGroupUuid(groupUuid);
Copy link
Contributor

Choose a reason for hiding this comment

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

[opportunity] Could we typescript annotate the useEnterpriseGroupUuid hook?

enterprise_customer: enterpriseUUID,
user_id: learnerId,
};
const data = await LmsApiService.fetchEnterpriseLearnerData(options);
Copy link
Contributor

Choose a reason for hiding this comment

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

[opportunity] Could we typescript annotate the fetchEnterpriseLearnerData api method?

const LearnerDetailPage = ({ enterpriseUUID }) => {
const { enterpriseSlug, groupUuid, learnerId } = useParams();
const { data: enterpriseGroup } = useEnterpriseGroupUuid(groupUuid);
const [learnerData, setLearnerData] = useState(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

[suggestion (non-blocking)]: let's initialize the state with an empty object instead of null to avoid potential issues when accessing properties

}, [enterpriseUUID, learnerId]);

const intl = useIntl();
const links = [{
Copy link
Contributor

Choose a reason for hiding this comment

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

[sugggestion (non-blocking)]: can we memoize the links array using useMemo to avoid unnecessary re-renders? something like...

const links = useMemo(() => {
    const baseLinks = [{
      label: intl.formatMessage({
        id: 'adminPortal.peopleManagement.learnerDetailPage.breadcrumb.peopleManagement',
        defaultMessage: 'People Management',
        description: 'Breadcrumb label to go back to People Management page',
      }),
      to: `/${enterpriseSlug}/admin/${ROUTE_NAMES.peopleManagement}`,
    }];
    if (groupUuid) {
      baseLinks.push({
        label: intl.formatMessage({
          id: 'adminPortal.peopleManagement.learnerDetailPage.breadcrumb.groupName',
          defaultMessage: `${enterpriseGroup?.name}`,
          description: 'Breadcrumb label to go back to group detail page',
        }),
        to: `/${enterpriseSlug}/admin/${ROUTE_NAMES.peopleManagement}/${groupUuid}`,
      });
    }
    return baseLinks;
  }, [intl, enterpriseSlug, groupUuid, enterpriseGroup])

const [learnerData, setLearnerData] = useState(null);
const [isLoading, setIsLoading] = useState(true);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

[suggestion (non-blocking)]: let's extract this useEffect logic into a custom hook i.e. useLearnerData to simplify this component since it might become convoluted once we add in other sections like the groups section and enrollments

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