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

Revert achievement ii #546

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions src/widgets/ImportantInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { gql } from '../gql';
import { useNavigate } from 'react-router-dom';
import { DateTime } from 'luxon';
import HSection from './HSection';
import { GAMIFICATION_ACTIVE } from '../config';
import { BACKEND_URL, GAMIFICATION_ACTIVE } from '../config';
import { useEffect, useMemo, useState } from 'react';
import useModal from '../hooks/useModal';
import { SuccessModal } from '../modals/SuccessModal';
import NextStepsCard from '../components/achievements/nextStepsCard/NextStepsCard';
import { Achievement, Achievement_Action_Type_Enum } from '../gql/graphql';
import { Achievement, Achievement_Action_Type_Enum, Achievement_State, Achievement_Type_Enum } from '../gql/graphql';
import { PuzzlePieceType, getPuzzleEmptyState } from '../helper/achievement-helper';
import AchievementModal from '../components/achievements/modals/AchievementModal';
import NextStepModal from '../components/achievements/modals/NextStepModal';
import { NextStepLabelType } from '../helper/important-information-helper';
Expand Down Expand Up @@ -116,6 +117,30 @@ query GetOnboardingInfos {
status
}
}
nextStepAchievements {
id
name
title
tagline
footer
subtitle
description
image
alternativeText
actionType
achievementType
achievementState
steps {
name
isActive
}
maxSteps
currentStep
isNewAchievement
progressDescription
actionName
actionRedirectLink
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe as an additional safeguard (and I think it generally makes sense) we could maybe slightly defer the ImportantInformation query a bit (useLazyQuery + useEffect with timeout that triggers it) so that other parts of the page load first and then we have plenty of time to fetch these? For sure we would then make sure that adding the important notifications does not cause a layout shift ...

}
myRoles
}
Expand All @@ -135,6 +160,7 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
const pupil = data?.me?.pupil;
const student = data?.me?.student;
const email = data?.me?.email;
const nextStepAchievements: Achievement[] = !GAMIFICATION_ACTIVE ? [] : data?.me.nextStepAchievements ?? [];
Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove the feature toggle


// eslint-disable-next-line react-hooks/exhaustive-deps
const roles = data?.myRoles ?? [];
Expand Down Expand Up @@ -176,6 +202,8 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
let infos: Information[] = [];

// -------- Verification -----------
// TODO - remove if achievements are included

if (student && !student?.verifiedAt)
infos.push({
label: NextStepLabelType.VERIFY,
Expand All @@ -190,6 +218,7 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
});

// -------- Screening -----------
// TODO - remove if achievements are included
Copy link
Member

Choose a reason for hiding this comment

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

What if already screened users request another screening - e.g. students screened as tutors want to be screened as instructors?

if (
student?.canRequestMatch?.reason === 'not-screened' ||
student?.canCreateCourse?.reason === 'not-screened' ||
Expand Down Expand Up @@ -268,6 +297,8 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
infos.push({ label: NextStepLabelType.PASSWORD, btnfn: [() => navigate('/new-password')], lang: {} });

// -------- New Match -----------
// TODO - remove if achievements are included

pupil?.matches?.forEach((match) => {
if (!match.dissolved && match.createdAt > new Date(Date.now() - 14 * 24 * 60 * 60 * 1000))
infos.push({
Expand All @@ -289,6 +320,8 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
});

// -------- Certificate of Conduct -----------
// TODO - remove if achievements are included [ONBOARDING]?
Copy link
Member

Choose a reason for hiding this comment

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

No, need to keep it - Support can request this even if the user is not currently registering - Or would this show up as a ghost?


if (student && student?.certificateOfConductDeactivationDate)
infos.push({
label: NextStepLabelType.CERTIFICATE_OF_CONDUCT,
Expand Down Expand Up @@ -339,7 +372,7 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
return configurableInfos;
}, [importantInformations, pupil, student]);

if (!infos.length && !configurableInfos.length) return null;
if (!infos.length && !configurableInfos.length && !nextStepAchievements.length) return null;

return (
<Box>
Expand Down Expand Up @@ -422,6 +455,24 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
/>
);
})}
{nextStepAchievements.map((achievement) => {
return (
<NextStepsCard
key={achievement.id}
image={achievement.image}
title={achievement.subtitle || undefined}
name={achievement.name}
actionDescription={achievement.actionName || ''}
description={achievement.description}
actionType={achievement.actionType || Achievement_Action_Type_Enum.Action}
maxSteps={achievement.maxSteps}
currentStep={achievement.currentStep}
onClick={() => {
setSelectedAchievement(achievement);
}}
/>
);
})}
</HSection>
</Box>
);
Expand Down
Loading