Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import { memo, useMemo } from 'react'; import { useParams } from '@amalia/ext/react-router-dom'; import { useAuthenticatedContext } from '@amalia/kernel/auth/state'; import { useLtiParticipantGrants } from '@amalia/lti/state'; import { type LtiPlan } from '@amalia/lti/types'; import { LtiParticipantEnrollmentPresentation } from './LtiParticipantEnrollmentPresentation'; export const LtiParticipantEnrollmentView = memo(function LtiParticipantEnrollmentView() { const { ltiGrantId } = useParams<{ ltiGrantId: LtiPlan['id'] }>(); const { authenticatedContext: { user }, } = useAuthenticatedContext(); const { data: ltiGrants, isLoading } = useLtiParticipantGrants(); const { plan, share, grant } = useMemo(() => { const foundGrant = ltiGrants ?.map((ltiGrant) => ({ ...ltiGrant, grants: ltiGrant.grants.filter((g) => g.id === ltiGrantId), })) .find((ltiGrant) => ltiGrant.grants.length); if (!foundGrant) { return { plan: null, grant: null, share: null }; } return { plan: foundGrant.plan, share: foundGrant.share, grant: foundGrant.grants.at(0)!, }; }, [ltiGrants, ltiGrantId]); return ( <LtiParticipantEnrollmentPresentation grant={grant} isLoading={isLoading} plan={plan} share={share} user={user} /> ); }); |