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

Iterate the pre-check to include an interoperability check #239

Draft
wants to merge 48 commits into
base: main
Choose a base branch
from

Conversation

mpanne
Copy link
Contributor

@mpanne mpanne commented Dec 16, 2024

  • Add questions regarding EU interoperability
  • Update pre-check landing and result pages to include information about interoperability
  • Add page with general information prior to pre-check questions
  • Update content of some pre-check pages

@mpanne mpanne marked this pull request as draft December 16, 2024 10:17
@mpanne mpanne force-pushed the feature_interoperability-pre-check branch 5 times, most recently from 7640927 to a480736 Compare December 19, 2024 13:57
For smaller screens additionally to progress bar.
In many places number of questions of the pre-check was hardcoded which was changed to work dynamically. Also button text was used to click a certain button which was replaced with a dedicated data-testid
For some reason the constant location resulted in failing e2e tests due to not resolvable dependencies in vorpruefung._index.tsx
Additionally to the result for digital rediness aspects.
- including interoperability result
- showing all reasons no matter if positive, negative or unsure
- show faq
mpanne and others added 17 commits December 19, 2024 15:58
Additional to the active element, all preceding elements are colored blue too, to better visualise the progress made.
Together with a small refactoring
We might want to revert that once the interoperebility pre-check has been evaluated on staging
- to prevent email app to open when running tests locally
- to be able to validate the mail data (working for all browsers)
-removes info "VO tritt ab Januar in Kraft"
- changed word from "EU-Länder" to "EU-Mitgliedsstaaten
@mpanne mpanne force-pushed the feature_interoperability-pre-check branch from 1ce6d24 to 9c30b6d Compare December 19, 2024 14:59
Copy link
Contributor

@HendrikSchmidt HendrikSchmidt left a comment

Choose a reason for hiding this comment

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

Hey, great work! I left a mix of nitpicks and medium proposals, lmk if you need any clarification.

With the possible refactorings and maybe pulling some components out of ResultPage (ReasoningList first and foremost probably), I am starting to think we might get away without the three files and could still merge route.tsx and ResultPage. Interested in your thoughts!

@@ -26,7 +26,6 @@ jobs:

build-and-push-image:
needs: [check-and-test-shared]
if: ${{ github.ref == 'refs/heads/main' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this lead to PR branches (e.g. by dependabot) being deployed, too?

const [isExpanded, setIsExpanded] = useState(false);

return (
<details
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the implementation through a details tag!


export default function AccordionItem(props: AccordionItemProps) {
const { headline, content, id, boldAppearance } = props;
const [isExpanded, setIsExpanded] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

This would allow multiple AccordionItems to be open at the same time, correct? Why do we explicitly need this state here? Shouldn't the native element handle a11y already? Also, have you considered using name to handle the case that only one accordion should be open?


return (
<details
onToggle={() => setIsExpanded(!isExpanded)}
Copy link
Contributor

Choose a reason for hiding this comment

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

See above comment if this is really necessary.

id={id}
>
<summary
role="button"
Copy link
Contributor

Choose a reason for hiding this comment

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

Also seems superfluous, but unsure?

(tuple) => tuple.question.interoperability && tuple.answer === "unsure",
);

function getReasonListItem(data: {
Copy link
Contributor

Choose a reason for hiding this comment

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

As this and the next three functions don't access local variables, I would pull them out of ResultPage and also simplify them to something like

function getReasonListItem(tuple: QuestionAndAnswer) {
  const classes = classNames("w-28 h-auto", {
    "fill-green-900": tuple.answer === "yes",
    "fill-red-900": tuple.answer === "no",
  });
  const resultType =
    tuple.answer === "no" ? "negativeResult" : "positiveResult";
  const resultHint = tuple.question?.resultHint?.[resultType];
  return (
    <>
      {tuple.answer === "yes" && <ControlPointOutlined className={classes} />}
      {tuple.answer === "no" && <RemoveCircleOutline className={classes} />}
      {tuple.answer === "unsure" && <HelpOutline className={classes} />}
      <span>
        <span>
          {tuple.question?.[resultType]}
          {resultHint && <RichText markdown={resultHint} />}
        </span>
      </span>
    </>
  );
}

function getReasonsList(questions: QuestionAndAnswer[], intro: string) {
  return (
    questions.length !== 0 && (
      <>
        <RichText className="mt-40" markdown={intro} />
        <ul className="ds-stack-16 mt-16">
          {questions
            .toSorted((t1) => (t1.answer === "yes" ? -1 : 1))
            .map((tuple) => (
              <li key={tuple.question.id} className="flex items-start gap-12">
                {getReasonListItem(tuple)}
              </li>
            ))}
        </ul>
      </>
    )
  );
}

Warning

Not tested!

}
>
<Container backgroundColor="white" additionalClassNames="rounded-b-lg">
<div className="pb-40 border-solid border-0 border-b-2 border-gray-400 last:border-0 last:pb-0">
Copy link
Contributor

Choose a reason for hiding this comment

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

border-0 seems unnecessary here

[ResultType.NEGATIVE]: preCheck.result.negative.nextSteps,
};

function matchQuestionsAndAnswers(answers: PreCheckAnswers) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about the following changes in tandem with the lower comments

function getRelevantQuestionsAndAnswers(
  answers: PreCheckAnswers,
  interoperability: boolean,
  sure: boolean,
) {
  return questions
    .filter(
      (q) =>
        !!q.interoperability === interoperability &&
        (answers[q.id] !== "unsure") === sure,
    )
    .map((q) => ({ question: q, answer: answers[q.id] }));
}

answers: PreCheckAnswers;
result: TResult;
}>) {
const questionsAndAnswers = matchQuestionsAndAnswers(answers);
Copy link
Contributor

Choose a reason for hiding this comment

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

const { reasoningIntro } = preCheck.result;
  const reasoning = [
    {
      intro: reasoningIntro.digital.sure,
      questions: getRelevantQuestionsAndAnswers(answers, false, true),
    },
    {
      intro: reasoningIntro.digital.unsure,
      questions: getRelevantQuestionsAndAnswers(answers, false, false),
    },
    {
      intro: reasoningIntro.interoperability.sure,
      questions: getRelevantQuestionsAndAnswers(answers, true, true),
    },
    {
      intro: reasoningIntro.interoperability.unsure,
      questions: getRelevantQuestionsAndAnswers(answers, true, false),
    },
  ];

>
<Container backgroundColor="white" additionalClassNames="rounded-b-lg">
<div className="pb-40 border-solid border-0 border-b-2 border-gray-400 last:border-0 last:pb-0">
{getReasonsList(
Copy link
Contributor

Choose a reason for hiding this comment

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

With the above changes the following four elements become just this

            {reasoning.map(({ intro, questions }) =>
              getReasonsList(questions, intro),
            )}

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