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(register-new-machine): making location required if category is of certain type #17276

Merged
merged 4 commits into from
Dec 19, 2024

Conversation

sigruntg
Copy link
Member

@sigruntg sigruntg commented Dec 18, 2024

...

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

    • Introduced a new LocationInputField component for location input in the machine registration form.
    • Updated the RegisterMachineForm to utilize the new location input field.
  • Bug Fixes

    • Enhanced validation for the location input based on machine category.
  • Chores

    • Streamlined TypeScript configuration for better file management and type declarations.

@sigruntg sigruntg added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Dec 18, 2024
@sigruntg sigruntg requested a review from a team as a code owner December 18, 2024 10:02
Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > tempy > del > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/codegen > [email protected]: Glob versions prior to v9 are no longer supported
warning react-native > @react-native/community-cli-plugin > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning react-native > @react-native-community/cli > @react-native-community/cli-tools > [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
warning react-native > @react-native/community-cli-plugin > @react-native/dev-middleware > @rnx-kit/chromium-edge-launcher > [email protected]: Rimraf versions prior to v4 are no longer supported
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
warning next-auth > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning next-auth > [email protected]: this version is no longer supported
warning next-auth > @next-auth/typeorm-legacy-adapter > typeorm > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > stylus > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > webpack-dev-server > [email protected]: Rimraf versions prior to v4 are no longer supported
warning @nx/next > @nx/webpack > fork-ts-checker-webpack-plugin > [email protected]: this will be v4
warning @nx/next > @nx/webpack > webpack-dev-server > webpack-dev-middleware > [email protected]: this will be v4
warning workspace-aggregator-c3d360cd-a92a-4b85-a797-ca3b17a5cf09 > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.

Walkthrough

This pull request introduces a new LocationInputField component for the machine registration form, replacing a standard text field with a custom input field. The changes include creating a new component in the LocationInputField/index.tsx file, updating the exports in index.ts, modifying the MachineBasicInformation form configuration, and adjusting the TypeScript configuration for the project. The new component adds custom validation logic specific to machine location input, particularly for certain machine categories.

Changes

File Change Summary
libs/application/templates/aosh/register-new-machine/src/fields/LocationInputField/index.tsx New component created with custom form input and validation logic
libs/application/templates/aosh/register-new-machine/src/fields/index.ts Added export for new LocationInputField component
libs/application/templates/aosh/register-new-machine/src/forms/RegisterMachineForm/MachineSection/MachineBasicInformation.ts Replaced buildTextField with buildCustomField for location input
libs/application/templates/aosh/register-new-machine/tsconfig.lib.json Updated TypeScript compiler options, files, exclude, and include configurations

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • berglindoma13
  • thorkellmani

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 81fe93a and a120688.

📒 Files selected for processing (1)
  • libs/application/templates/aosh/register-new-machine/src/fields/LocationInputField/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/application/templates/aosh/register-new-machine/src/fields/LocationInputField/index.tsx

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.

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.69%. Comparing base (62ed00f) to head (0f0431e).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17276      +/-   ##
==========================================
- Coverage   35.70%   35.69%   -0.01%     
==========================================
  Files        6948     6921      -27     
  Lines      148865   148517     -348     
  Branches    42503    42419      -84     
==========================================
- Hits        53149    53010     -139     
+ Misses      95716    95507     -209     
Flag Coverage Δ
api 3.33% <ø> (ø)
application-system-api 38.74% <ø> (ø)
application-template-api-modules 27.70% <ø> (-0.09%) ⬇️
application-templates-accident-notification 27.61% <ø> (ø)
application-ui-shell 22.31% <ø> (ø)

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

see 31 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 62ed00f...0f0431e. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 18, 2024

Datadog Report

All test runs 566d70d 🔗

5 Total Test Services: 0 Failed, 5 Passed
⬆️ Test Sessions change in coverage: 1 increased (+0.01%), 7 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.36s 1 no change Link
application-system-api 0 0 0 46 0 2m 9.26s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 7.17s 1 increased (+0.01%) Link
application-templates-accident-notification 0 0 0 140 0 13.97s 1 no change Link
application-ui-shell 0 0 0 74 0 31.72s 1 no change Link

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: 4

🧹 Nitpick comments (3)
libs/application/templates/aosh/register-new-machine/src/fields/LocationInputField/index.tsx (2)

42-44: Improve error message specificity

The current error message uses a default generic message. Consider using a more specific error message that explains the location requirement for elevators.

 error={
   displayError && location.length === 0
-    ? formatMessage(coreErrorMessages.defaultError)
+    ? formatMessage(machine.errors.locationRequiredForElevator)
     : undefined
 }

18-19: Add type safety for form values

The watch function results are type cast without validation. Consider using zod or similar for runtime type checking.

+import { z } from 'zod';
+
+const aboutMachineSchema = z.object({
+  category: z.object({
+    nameIs: z.string()
+  }).nullable()
+});
+
-const watchMachine = watch('machine.aboutMachine') as AboutMachine
+const watchMachine = aboutMachineSchema.parse(watch('machine.aboutMachine'))
libs/application/templates/aosh/register-new-machine/tsconfig.lib.json (1)

8-9: Consider using path mapping for node_modules references

Using relative paths to node_modules can be fragile. Consider using TypeScript's path mapping feature instead.

{
  "compilerOptions": {
+   "paths": {
+     "@nx/react/*": ["node_modules/@nx/react/*"]
+   }
  },
  "files": [
-   "../../../../../node_modules/@nx/react/typings/cssmodule.d.ts",
-   "../../../../../node_modules/@nx/react/typings/image.d.ts"
+   "@nx/react/typings/cssmodule.d.ts",
+   "@nx/react/typings/image.d.ts"
  ]
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 478aa01 and 81fe93a.

📒 Files selected for processing (4)
  • libs/application/templates/aosh/register-new-machine/src/fields/LocationInputField/index.tsx (1 hunks)
  • libs/application/templates/aosh/register-new-machine/src/fields/index.ts (1 hunks)
  • libs/application/templates/aosh/register-new-machine/src/forms/RegisterMachineForm/MachineSection/MachineBasicInformation.ts (1 hunks)
  • libs/application/templates/aosh/register-new-machine/tsconfig.lib.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
libs/application/templates/aosh/register-new-machine/src/forms/RegisterMachineForm/MachineSection/MachineBasicInformation.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/aosh/register-new-machine/src/fields/LocationInputField/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."
libs/application/templates/aosh/register-new-machine/tsconfig.lib.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/aosh/register-new-machine/src/fields/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."
🔇 Additional comments (4)
libs/application/templates/aosh/register-new-machine/src/fields/index.ts (1)

6-6: LGTM!

The export follows the established pattern in the file.

libs/application/templates/aosh/register-new-machine/tsconfig.lib.json (2)

12-20: LGTM! Test exclusion patterns are well-structured

The exclude patterns are comprehensive and follow a consistent pattern.


22-22: LGTM! Include pattern is appropriately broad

The include pattern correctly captures all relevant source files.

libs/application/templates/aosh/register-new-machine/src/forms/RegisterMachineForm/MachineSection/MachineBasicInformation.ts (1)

129-129: Verify the LocationInputField component implementation

Let's ensure the new custom component exists and follows the library's guidelines for reusable components.

✅ Verification successful

Let me gather more information about the component's implementation and type definitions.


LocationInputField component implementation verified successfully

The component is properly implemented following the library's guidelines:

  • Correctly exported and imported in the fields index
  • Extends FieldBaseProps from @island.is/application/types
  • Follows the same pattern as other form field components in the codebase
  • Implements proper form validation and error handling
  • Uses shared UI components (InputController) and localization utilities
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if LocationInputField component exists and exports types
rg -A 10 "export.*LocationInputField" "libs/application/templates/aosh/register-new-machine/src/"

# Verify component follows TypeScript guidelines
ast-grep --pattern 'interface $name {
  $$$
}' "libs/application/templates/aosh/register-new-machine/src/fields/LocationInputField/"

# Check if the component is properly exported from the fields index
rg "export.*LocationInputField" "libs/application/templates/aosh/register-new-machine/src/fields/index.ts"

Length of output: 2001


Script:

#!/bin/bash
# Check the full implementation of LocationInputField
rg -l "LocationInputField" "libs/application/templates/aosh/register-new-machine/src/" | xargs cat

# Check for any type definitions in the component directory
fd "types?.ts" "libs/application/templates/aosh/register-new-machine/src/fields/LocationInputField" --exec cat

# Check if the component uses FieldBaseProps from a shared location
rg "FieldBaseProps" "libs/application/templates/aosh/register-new-machine/src/"

Length of output: 9181

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: 3

🧹 Nitpick comments (4)
libs/application/templates/aosh/register-new-machine/src/fields/LocationInputField/index.tsx (1)

32-48: Consider extracting error message logic

The error message logic in the render method could be simplified by extracting it to a separate function.

+const getErrorMessage = (
+  displayError: boolean,
+  location: string,
+  formatMessage: (message: MessageDescriptor) => string
+) =>
+  displayError && location.length === 0
+    ? formatMessage(coreErrorMessages.defaultError)
+    : undefined

 return (
   <Box paddingTop={2}>
     <InputController
       {...}
-      error={
-        displayError && location.length === 0
-          ? formatMessage(coreErrorMessages.defaultError)
-          : undefined
-      }
+      error={getErrorMessage(displayError, location, formatMessage)}
     />
   </Box>
 )
libs/application/templates/aosh/register-new-machine/tsconfig.lib.json (1)

22-22: Consider restricting include patterns

The current include pattern ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] might be too broad as it includes files from all directories. Consider restricting it to the src directory to prevent including unwanted files.

-"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
+"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
libs/application/templates/aosh/register-new-machine/src/forms/RegisterMachineForm/MachineSection/MachineBasicInformation.ts (2)

125-130: Consider accessibility: Empty title might affect screen readers.

The empty title (title: '') could impact accessibility. If the LocationInputField component handles its own labeling, consider documenting this in a code comment for clarity.

 buildCustomField({
   id: 'machine.basicInformation.location',
-  title: '',
+  title: '', // Note: Field label is handled within LocationInputField component
   width: 'half',
   component: 'LocationInputField',
 }),

125-130: Consider type safety improvements.

Following the libs coding guidelines for TypeScript usage, consider exporting types for the custom field props to ensure type safety across different NextJS apps.

Consider adding:

export interface LocationInputFieldProps {
  value?: string;
  onChange: (value: string) => void;
  required?: boolean;
  error?: string;
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 478aa01 and 81fe93a.

📒 Files selected for processing (4)
  • libs/application/templates/aosh/register-new-machine/src/fields/LocationInputField/index.tsx (1 hunks)
  • libs/application/templates/aosh/register-new-machine/src/fields/index.ts (1 hunks)
  • libs/application/templates/aosh/register-new-machine/src/forms/RegisterMachineForm/MachineSection/MachineBasicInformation.ts (1 hunks)
  • libs/application/templates/aosh/register-new-machine/tsconfig.lib.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
libs/application/templates/aosh/register-new-machine/src/forms/RegisterMachineForm/MachineSection/MachineBasicInformation.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/aosh/register-new-machine/src/fields/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/aosh/register-new-machine/src/fields/LocationInputField/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."
libs/application/templates/aosh/register-new-machine/tsconfig.lib.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."
🔇 Additional comments (2)
libs/application/templates/aosh/register-new-machine/src/fields/index.ts (1)

6-6: LGTM!

The export follows the established pattern in the barrel file.

libs/application/templates/aosh/register-new-machine/src/forms/RegisterMachineForm/MachineSection/MachineBasicInformation.ts (1)

125-130: Verify required validation implementation.

According to the PR objectives, location should be required for certain machine categories. Ensure that the LocationInputField component properly implements this conditional validation.

✅ Verification successful

Let me gather more information about the validation implementation.


Location field validation is properly implemented for specific machine categories

The LocationInputField component correctly implements the conditional required validation:

  • It tracks the machine category using form context
  • Location is required specifically for the category "Fólkslyftur og vörulyftur" (Passenger and cargo lifts)
  • Validation is enforced through both the UI (required field indicator) and form submission validation
  • Error messages are displayed when validation fails

The implementation aligns with the PR objectives for category-specific location requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify LocationInputField implementation of conditional required validation

# Check the LocationInputField component implementation
ast-grep --pattern 'export const LocationInputField = $_' -A 20

# Look for validation logic related to machine categories
rg -l "machine.*category" --type ts

Length of output: 3303


Script:

#!/bin/bash
# Search for LocationInputField implementation
fd LocationInputField --type ts --exec cat {}

# Search for validation rules or schemas related to machine location
rg "location.*required|required.*location" --type ts -A 3

# Look for machine category validation logic
rg "machine\.basicInformation\.location.*validation|validation.*machine\.basicInformation\.location" --type ts -A 3

Length of output: 397


Script:

#!/bin/bash
# Search for LocationInputField implementation with correct extension
fd -e tsx -e ts LocationInputField --exec cat {}

# Search for validation schemas in the register-new-machine directory
rg -t ts -t tsx "validation|schema|required" libs/application/templates/aosh/register-new-machine/src/ -A 3

# Look for machine category conditions
rg -t ts -t tsx "machine.*category.*location|location.*machine.*category" libs/application/templates/aosh/register-new-machine/src/ -A 3

Length of output: 357


Script:

#!/bin/bash
# Search for LocationInputField implementation
find . -type f \( -name "*.ts" -o -name "*.tsx" \) -exec grep -l "LocationInputField" {} \; -exec cat {} \;

# Search for validation schemas in register-new-machine
find ./libs/application/templates/aosh/register-new-machine/src -type f \( -name "*.ts" -o -name "*.tsx" \) -exec grep -A 3 "validation\|schema\|required" {} \;

# Look for machine category validation
find ./libs/application/templates/aosh/register-new-machine/src -type f \( -name "*.ts" -o -name "*.tsx" \) -exec grep -A 3 "machine.*category.*location\|location.*machine.*category" {} \;

Length of output: 10621

Copy link
Member

@berglindoma13 berglindoma13 left a comment

Choose a reason for hiding this comment

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

Eitt líitð komment annars approved

@sigruntg sigruntg removed the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Dec 18, 2024
@sigruntg sigruntg added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Dec 19, 2024
@kodiakhq kodiakhq bot merged commit 15edb19 into main Dec 19, 2024
40 checks passed
@kodiakhq kodiakhq bot deleted the feat/register-new-machine-add-required branch December 19, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants