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

fix(secondary school): More fixes + stop user if no programs are open for admission + handle if only 1 school or program available #17522

Merged
merged 9 commits into from
Jan 20, 2025

Conversation

johannaagma
Copy link
Member

@johannaagma johannaagma commented Jan 15, 2025

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Added validation for school admission status based on student type
    • Introduced checks to determine if schools are open for freshman and general applications
    • Enhanced error handling for school selection process
  • Bug Fixes

    • Improved logic for displaying school selection options
    • Fixed conditional rendering of program selections
  • Documentation

    • Added new error messages for scenarios with no available schools for admission
  • Chores

    • Updated language constants
    • Refined type definitions for secondary school data

Copy link
Contributor

coderabbitai bot commented Jan 15, 2025

Walkthrough

This pull request introduces comprehensive changes to the secondary school application template, focusing on enhancing admission and school selection processes. The modifications span multiple files and involve adding new validation logic for school admissions, updating type definitions, and improving user interface components. The changes primarily address how schools are retrieved, filtered, and displayed based on student status and admission availability, with a particular emphasis on freshman and general application types.

Changes

File Change Summary
libs/application/template-api-modules/src/lib/modules/templates/secondary-school/secondary-school.service.ts Updated getSchools method to validate student information and check school admission availability
libs/application/template-api-modules/src/lib/modules/templates/secondary-school/utils.ts Modified school selection priority initialization values
libs/application/templates/secondary-school/src/fields/schoolSelection/SelectionItem.tsx Added showSecondProgram state, updated filtering logic for school options
libs/application/templates/secondary-school/src/forms/secondarySchoolForm/* Various updates to form validation, error handling, and language constants
libs/application/templates/secondary-school/src/lib/SecondarySchoolTemplate.ts Added submission permissions for organization reviewers
libs/application/templates/secondary-school/src/lib/dataSchema.ts Enhanced applicationType schema with admission status validation
libs/clients/secondary-school/src/clientConfig.json Added new endpoint for checking school admission status

Suggested Labels

automerge, deploy-feature

Suggested Reviewers

  • veronikasif
  • thorkellmani

Possibly Related PRs

Finishing Touches

  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 15, 2025

Datadog Report

All test runs e5a9c99 🔗

4 Total Test Services: 0 Failed, 4 Passed
➡️ Test Sessions change in coverage: 10 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.42s 1 no change Link
application-system-api 0 0 0 46 0 2m 11.42s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 4.57s 1 no change Link
application-ui-shell 0 0 0 74 0 32.13s 1 no change Link

Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 10.00000% with 18 lines in your changes missing coverage. Please review.

Project coverage is 35.64%. Comparing base (c75825f) to head (d9b1460).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...lates/secondary-school/secondary-school.service.ts 0.00% 9 Missing ⚠️
...n/templates/secondary-school/src/lib/dataSchema.ts 0.00% 6 Missing ⚠️
...ry-school/src/lib/secondarySchoolClient.service.ts 0.00% 2 Missing ⚠️
...rc/lib/modules/templates/secondary-school/utils.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17522      +/-   ##
==========================================
+ Coverage   35.58%   35.64%   +0.05%     
==========================================
  Files        7027     7015      -12     
  Lines      150397   150005     -392     
  Branches    42924    42811     -113     
==========================================
- Hits        53517    53467      -50     
+ Misses      96880    96538     -342     
Flag Coverage Δ
api 3.33% <ø> (ø)
application-system-api 38.68% <10.00%> (-0.02%) ⬇️
application-template-api-modules 27.56% <0.00%> (-0.01%) ⬇️
application-ui-shell 22.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...econdary-school/src/lib/SecondarySchoolTemplate.ts 31.11% <ø> (ø)
...mplates/secondary-school/src/lib/messages/error.ts 100.00% <ø> (ø)
...ondary-school/src/lib/messages/extraInformation.ts 100.00% <ø> (ø)
...ates/secondary-school/src/utils/constants/index.ts 100.00% <100.00%> (ø)
...rc/lib/modules/templates/secondary-school/utils.ts 9.85% <0.00%> (ø)
...ry-school/src/lib/secondarySchoolClient.service.ts 12.72% <0.00%> (-0.49%) ⬇️
...n/templates/secondary-school/src/lib/dataSchema.ts 27.77% <0.00%> (-5.56%) ⬇️
...lates/secondary-school/secondary-school.service.ts 19.35% <0.00%> (-1.83%) ⬇️

... and 108 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a548dd...d9b1460. Read the comment docs.

@johannaagma johannaagma marked this pull request as ready for review January 17, 2025 10:15
@johannaagma johannaagma requested a review from a team as a code owner January 17, 2025 10:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
libs/application/templates/secondary-school/src/lib/messages/error.ts (1)

Line range hint 8-15: Fix incorrect message ID in errorValidateCanCreateDescription.

The ID references the title message instead of the description message.

   errorValidateCanCreateDescription: {
-    id: 'ss.application:error.errorValidateCanCreateTitle',
+    id: 'ss.application:error.errorValidateCanCreateDescription',
     defaultMessage:
       'Þú ert með aðra opna umsókn í gangi, vinsamlegast eyðið henni áður en opnað er nýja umsókn',
     description: 'Error validate can create description',
   },
🧹 Nitpick comments (13)
libs/application/template-api-modules/src/lib/modules/templates/secondary-school/secondary-school.service.ts (1)

55-59: Consider renaming the variable for clarity.

The variable schoolIsOpenForAdmission holds a SecondarySchool object rather than a boolean value. Renaming it to availableSchool or openSchoolForAdmission may improve code readability.

Suggested change:

-        const schoolIsOpenForAdmission = schools.find((x) =>
+        const availableSchool = schools.find((x) =>
libs/clients/secondary-school/src/lib/secondarySchoolClient.types.ts (1)

16-17: LGTM! Consider adding JSDoc comments.

The new boolean properties are well-typed and follow naming conventions. Consider adding JSDoc comments to document the purpose and usage of these properties for better maintainability.

 export interface SecondarySchool {
+  /** Indicates if the school is accepting general admission applications */
   isOpenForAdmissionGeneral: boolean
+  /** Indicates if the school is accepting freshman admission applications */
   isOpenForAdmissionFreshman: boolean
libs/application/templates/secondary-school/src/lib/dataSchema.ts (1)

126-140: Enhance refinement with custom error messages.

The schema validation is correct, but adding custom error messages would improve the user experience.

   applicationType: z
     .object({
       value: z.nativeEnum(ApplicationType),
       isOpenForAdmissionFreshman: z.boolean().optional(),
       isOpenForAdmissionGeneral: z.boolean().optional(),
     })
     .refine(
       ({ value, isOpenForAdmissionFreshman, isOpenForAdmissionGeneral }) => {
         if (value === ApplicationType.FRESHMAN)
           return isOpenForAdmissionFreshman
         else if (value === ApplicationType.GENERAL_APPLICATION)
           return isOpenForAdmissionGeneral
         return true
       },
+      {
+        message: "School is not open for the selected application type",
+        path: ["value"]
+      }
     ),
libs/application/template-api-modules/src/lib/modules/templates/secondary-school/utils.ts (1)

119-119: LGTM! Consider using an enum for priorities.

The change to start priorities from 1 instead of 0 is more intuitive. However, to improve maintainability and prevent magic numbers, consider defining an enum for priority values.

+export enum Priority {
+  FIRST = 1,
+  SECOND = 2,
+  THIRD = 3,
+}

 let schoolPriority = Priority.FIRST
 // ...
 programs: [
   {
-    priority: 1,
+    priority: Priority.FIRST,
     programId: selectionItem.firstProgram.id,
   },
   {
-    priority: 2,
+    priority: Priority.SECOND,
     programId: selectionItem.secondProgram?.include
       ? selectionItem.secondProgram.id || ''
       : '',
   },
 ]

Also applies to: 137-141

libs/application/templates/secondary-school/src/forms/secondarySchoolForm/userInformationSection/personalSubSection.ts (1)

108-158: Consider extracting duplicate admission status checks.

The validation logic for checking if schools are open for admission is well-implemented but contains duplicate code. Consider extracting the common logic into a helper function.

+const isSchoolOpenForAdmission = (
+  externalData: object,
+  type: ApplicationType,
+): boolean => {
+  const schools = getValueViaPath<SecondarySchool[]>(
+    externalData,
+    'schools.data',
+  )
+  return !!schools?.find(
+    (x) =>
+      type === ApplicationType.FRESHMAN
+        ? x.isOpenForAdmissionFreshman
+        : x.isOpenForAdmissionGeneral,
+  )
+}

 buildHiddenInput({
   id: 'applicationType.isOpenForAdmissionFreshman',
   condition: (_, externalData) =>
-    !!getValueViaPath<SecondarySchool[]>(
-      externalData,
-      'schools.data',
-    )?.find((x) => x.isOpenForAdmissionFreshman),
+    isSchoolOpenForAdmission(externalData, ApplicationType.FRESHMAN),
   defaultValue: true,
 }),
 buildHiddenInput({
   id: 'applicationType.isOpenForAdmissionGeneral',
   condition: (_, externalData) =>
-    !!getValueViaPath<SecondarySchool[]>(
-      externalData,
-      'schools.data',
-    )?.find((x) => x.isOpenForAdmissionGeneral),
+    isSchoolOpenForAdmission(externalData, ApplicationType.GENERAL_APPLICATION),
   defaultValue: true,
 }),
libs/application/templates/secondary-school/src/fields/schoolSelection/index.tsx (4)

23-26: Consider using a custom hook for school data retrieval.

The schools data fetching logic could be moved to a custom hook to improve reusability and separation of concerns.

-  const schools = getValueViaPath<SecondarySchool[]>(
-    application.externalData,
-    'schools.data',
-  )
+  const schools = useSchoolData(application.externalData)

33-38: Consider consolidating related state variables.

The component has multiple related state variables for selection visibility. Consider using a single state object to manage these related states.

-  const [showSecondAddRemoveButtons, setShowSecondAddRemoveButtons] = useState<boolean>(false)
-  const [showThirdAddRemoveButtons, setShowThirdAddRemoveButtons] = useState<boolean>(false)
-  const [showSecondSelection, setShowSecondSelection] = useState<boolean>(false)
-  const [showThirdSelection, setShowThirdSelection] = useState<boolean>(false)
+  const [selectionState, setSelectionState] = useState({
+    showSecondAddRemoveButtons: false,
+    showThirdAddRemoveButtons: false,
+    showSecondSelection: false,
+    showThirdSelection: false,
+  })

141-143: Consider extracting the filter logic to a utility function.

The filtering logic for schools could be moved to a separate utility function for better reusability and testability.

-  const filteredSchools = schools?.filter((x) =>
-    isFreshman ? x.isOpenForAdmissionFreshman : x.isOpenForAdmissionGeneral,
-  )
+  const filteredSchools = filterAvailableSchools(schools, isFreshman)

198-243: Consider extracting selection UI into a separate component.

The second selection UI block is complex and could be extracted into a reusable component to improve maintainability.

+interface SelectionBlockProps {
+  showSelection: boolean
+  showButtons: boolean
+  onAdd: () => void
+  onRemove: () => void
+  field: FieldBaseProps['field']
+  otherFieldIds: string[]
+}
+
+const SelectionBlock: FC<SelectionBlockProps> = ({ ... }) => {
+  // Extract the selection block UI here
+}

-  {(showSecondSelection || showSecondAddRemoveButtons) && (
-    <>
-      <Text variant="h5" marginTop={2}>
-        {showSecondSelection
-          ? formatMessage(school.secondSelection.subtitle)
-          : formatMessage(school.secondSelection.addSubtitle)}
-      </Text>
-      ...
-    </>
-  )}
+  <SelectionBlock
+    showSelection={showSecondSelection}
+    showButtons={showSecondAddRemoveButtons}
+    onAdd={onClickAddSecond}
+    onRemove={onClickRemoveSecond}
+    field={props.field}
+    otherFieldIds={[`${props.field.id}.first`, `${props.field.id}.third`]}
+  />
libs/application/templates/secondary-school/src/fields/schoolSelection/SelectionItem.tsx (2)

38-38: Consider using derived state for second program visibility.

The showSecondProgram state could be derived from props and other state variables instead of being managed separately.

-  const [showSecondProgram, setShowSecondProgram] = useState<boolean>(true)
+  const showSecondProgram = useMemo(() => 
+    isFreshman && programOptions.length > 1, 
+    [isFreshman, programOptions.length]
+  )

261-264: Extract program visibility logic to a custom hook.

The effect for managing second program visibility could be moved to a custom hook for better reusability.

+const useSecondProgramVisibility = (
+  isFreshman: boolean,
+  programOptions: Program[],
+  fieldId: string,
+  setValue: (path: string, value: any) => void
+) => {
+  useEffect(() => {
+    const showSecondProgram = isFreshman && programOptions.length !== 1
+    setValue(`${fieldId}.secondProgram.include`, showSecondProgram)
+    return showSecondProgram
+  }, [isFreshman, programOptions.length, fieldId, setValue])
+}

-  useEffect(() => {
-    const showSecondProgram = isFreshman && programOptions.length !== 1
-    setValue(`${props.field.id}.secondProgram.include`, showSecondProgram)
-    setShowSecondProgram(showSecondProgram)
-  }, [isFreshman, programOptions.length, props.field.id, setValue])
+  const showSecondProgram = useSecondProgramVisibility(
+    isFreshman,
+    programOptions,
+    props.field.id,
+    setValue
+  )
libs/clients/secondary-school/src/clientConfig.json (2)

323-350: Consider adding query parameters for admission type.

The new endpoint for checking open admissions could benefit from optional query parameters to check specific admission types.

Consider adding query parameters like this:

 "/v1/schools/admissions/open": {
   "get": {
     "tags": ["Schools"],
     "summary": "[GET] Check if any programme is open for admission for any school.",
+    "parameters": [
+      {
+        "name": "admissionType",
+        "in": "query",
+        "description": "Type of admission to check (general/freshman)",
+        "schema": {
+          "type": "string",
+          "enum": ["general", "freshman"]
+        }
+      }
+    ],
     "responses": {

934-941: Add examples to the admission status properties.

The new admission status properties in SchoolDto would benefit from examples in the schema.

   "anyOpenForAdmissionGeneral": {
     "type": "boolean",
-    "description": "If any programmes are open for admission"
+    "description": "If any programmes are open for admission",
+    "example": true
   },
   "anyOpenForAdmissionFreshman": {
     "type": "boolean",
-    "description": "If any programmes are open for admission for freshman"
+    "description": "If any programmes are open for admission for freshman",
+    "example": false
   },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc196a2 and 1ac3528.

📒 Files selected for processing (15)
  • libs/application/template-api-modules/src/lib/modules/templates/secondary-school/secondary-school.service.ts (1 hunks)
  • libs/application/template-api-modules/src/lib/modules/templates/secondary-school/utils.ts (2 hunks)
  • libs/application/templates/secondary-school/src/fields/schoolSelection/SelectionItem.tsx (6 hunks)
  • libs/application/templates/secondary-school/src/fields/schoolSelection/index.tsx (5 hunks)
  • libs/application/templates/secondary-school/src/forms/secondarySchoolForm/extraInformationSection/index.ts (2 hunks)
  • libs/application/templates/secondary-school/src/forms/secondarySchoolForm/userInformationSection/personalSubSection.ts (5 hunks)
  • libs/application/templates/secondary-school/src/lib/SecondarySchoolTemplate.ts (1 hunks)
  • libs/application/templates/secondary-school/src/lib/dataSchema.ts (1 hunks)
  • libs/application/templates/secondary-school/src/lib/messages/error.ts (1 hunks)
  • libs/application/templates/secondary-school/src/lib/messages/extraInformation.ts (2 hunks)
  • libs/application/templates/secondary-school/src/utils/constants/index.ts (1 hunks)
  • libs/application/templates/secondary-school/src/utils/types/index.ts (1 hunks)
  • libs/clients/secondary-school/src/clientConfig.json (4 hunks)
  • libs/clients/secondary-school/src/lib/secondarySchoolClient.service.ts (1 hunks)
  • libs/clients/secondary-school/src/lib/secondarySchoolClient.types.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • libs/application/templates/secondary-school/src/lib/messages/extraInformation.ts
🧰 Additional context used
📓 Path-based instructions (14)
libs/application/templates/secondary-school/src/utils/types/index.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/secondary-school/src/utils/constants/index.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/clients/secondary-school/src/lib/secondarySchoolClient.types.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/template-api-modules/src/lib/modules/templates/secondary-school/utils.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/clients/secondary-school/src/lib/secondarySchoolClient.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/secondary-school/src/lib/messages/error.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/secondary-school/src/fields/schoolSelection/SelectionItem.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/secondary-school/src/lib/SecondarySchoolTemplate.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/secondary-school/src/lib/dataSchema.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/template-api-modules/src/lib/modules/templates/secondary-school/secondary-school.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/clients/secondary-school/src/clientConfig.json (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/secondary-school/src/forms/secondarySchoolForm/userInformationSection/personalSubSection.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/secondary-school/src/forms/secondarySchoolForm/extraInformationSection/index.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/secondary-school/src/fields/schoolSelection/index.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
📓 Learnings (1)
libs/application/templates/secondary-school/src/lib/dataSchema.ts (1)
Learnt from: veronikasif
PR: island-is/island.is#17513
File: libs/application/templates/new-primary-school/src/lib/dataSchema.ts:155-157
Timestamp: 2025-01-16T16:06:48.438Z
Learning: In Zod schemas for the new-primary-school application, optional fields that accept YES/NO values should use `z.string().optional()` instead of `z.enum([YES, NO]).optional()` as the latter doesn't work correctly for optional fields. Validation of YES/NO values should be handled through refinements.
🔇 Additional comments (8)
libs/application/template-api-modules/src/lib/modules/templates/secondary-school/secondary-school.service.ts (1)

60-68: Good use of error handling when no schools are open for admission.

Throwing a TemplateApiError with a clear title and summary enhances the user experience by providing meaningful feedback.

libs/application/templates/secondary-school/src/utils/constants/index.ts (1)

3-4: Language code constants added correctly.

Defining LANGUAGE_CODE_DANISH as 'da' and LANGUAGE_CODE_ICELANDIC as 'is' improves maintainability and avoids hardcoding string literals.

libs/application/templates/secondary-school/src/utils/types/index.ts (1)

16-17: New properties enhance the SecondarySchool type.

Adding isOpenForAdmissionGeneral and isOpenForAdmissionFreshman as boolean properties appropriately extends the SecondarySchool interface to include admission status.

libs/application/templates/secondary-school/src/lib/messages/error.ts (1)

20-29: LGTM! Error messages are well-structured.

The new error messages follow the established pattern and provide clear feedback for the no-schools-open scenario.

libs/application/templates/secondary-school/src/forms/secondarySchoolForm/extraInformationSection/index.ts (1)

56-56: LGTM! Good use of constants.

Replacing the hardcoded language code with a constant improves maintainability and follows best practices.

libs/clients/secondary-school/src/lib/secondarySchoolClient.service.ts (1)

56-57: LGTM! Good addition of admission status flags.

The new properties correctly handle undefined values and provide essential information about school admission status for both general and freshman applications.

libs/application/templates/secondary-school/src/forms/secondarySchoolForm/userInformationSection/personalSubSection.ts (1)

44-48: LGTM! Consistent handling of freshman status.

The refactored conditions using isFreshmanExternalData improve code consistency and readability.

Also applies to: 58-62, 80-84

libs/application/templates/secondary-school/src/lib/SecondarySchoolTemplate.ts (1)

234-240: Verify organization reviewer submission permissions.

Adding submission actions for organization reviewers is a significant workflow change. Please verify:

  1. This aligns with business requirements
  2. Proper access controls are in place
  3. The submission process handles both applicant and reviewer submissions correctly

Run the following script to check role permissions across the codebase:

✅ Verification successful

Organization reviewer submission permissions are properly implemented.

The implementation includes:

  • Full read/write permissions for organization reviewers
  • Proper state machine transitions for submissions
  • Standard submission workflow consistent with other templates
  • Correct assignee management through state machine actions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check role permissions and access controls for organization reviewers

# Check for role definitions and permissions
rg -A 5 "ORGANISATION_REVIEWER"

# Check for submission handling
ast-grep --pattern 'ApiActions.submitApplication'

Length of output: 9578


Script:

#!/bin/bash
# Check for validation logic and state machine configurations
rg -A 5 "validateCanCreate|validateSubmission|canSubmit" libs/application/templates/secondary-school/

# Check for state machine configurations specific to organization reviewers
ast-grep --pattern 'stateMachineConfig = {
  $$$
}'

# Look for submission middleware or handlers
rg -A 5 "submitApplication.*handler|submitHandler|onSubmit"

Length of output: 71828


Script:

#!/bin/bash
# Check state machine configurations and role validation
rg -A 10 "stateMachineConfig|stateMachineOptions" libs/application/templates/secondary-school/

# Look for role-based validation
ast-grep --pattern 'role === $_ || roles.includes($_)'

# Check for application state transitions
rg -A 5 "transition|state.*draft|state.*submitted" libs/application/templates/secondary-school/

Length of output: 5372

@johannaagma johannaagma enabled auto-merge January 20, 2025 09:29
@johannaagma johannaagma added this pull request to the merge queue Jan 20, 2025
Merged via the queue into main with commit dc4612a Jan 20, 2025
42 checks passed
@johannaagma johannaagma deleted the feat/umsokn-um-framhaldsskola-fixes branch January 20, 2025 09:47
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