-
Notifications
You must be signed in to change notification settings - Fork 61
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(financial-statement-political-party): political party as a new application #16076
Conversation
WalkthroughThe changes introduce a new service for managing financial statements specific to political parties, along with a validation schema using the Zod library. The Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16076 +/- ##
==========================================
- Coverage 36.75% 36.63% -0.13%
==========================================
Files 6804 6788 -16
Lines 140875 141637 +762
Branches 40134 40540 +406
==========================================
+ Hits 51782 51884 +102
- Misses 89093 89753 +660
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 124 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 17
Outside diff range and nitpick comments (12)
libs/application/templates/inao/financial-statement-political-party/src/hooks/useTotals.tsx (1)
5-19
: LGTM! TheuseTotals
hook is well-implemented and adheres to best practices.The hook provides a reusable and efficient way to manage totals in forms by:
- Utilizing the
useFormContext
hook from thereact-hook-form
library to access the current form values.- Maintaining a state variable
total
that is updated whenever thegetSum
function is invoked.- Memoizing the
getSum
function withuseCallback
to optimize performance.- Employing an effect hook (
useEffect
) to callgetSum
whenever the hook is first used or whengetSum
changes.Additionally, the hook adheres to the provided instructions by:
- Being reusable across different NextJS apps.
- Using TypeScript for defining the return type and the
key
parameter.- Utilizing a helper function
getTotal
for effective tree-shaking and bundling.Consider adding a few minor improvements:
- Add a JSDoc comment to document the purpose and usage of the hook.
- Consider renaming the
key
parameter to something more descriptive, such asformFieldKey
, to clarify its purpose.- Consider adding a check to ensure that the
key
parameter is a valid form field key before using it in thegetTotal
function.Here's an example of how you could implement these suggestions:
+/** + * Custom hook to calculate and manage a total value based on form inputs. + * @param {string} formFieldKey - The key of the form field to sum. + * @returns {[() => void, number]} - An array containing the `getSum` function and the current `total`. + */ -export const useTotals = (key: string): [() => void, number] => { +export const useTotals = (formFieldKey: string): [() => void, number] => { const [total, setTotal] = useState(0) const { getValues } = useFormContext() const getSum = useCallback(() => { const values = getValues() + if (!values.hasOwnProperty(formFieldKey)) { + console.warn(`Form field key "${formFieldKey}" not found in form values.`) + return + } - const sum = getTotal(values, key) + const sum = getTotal(values, formFieldKey) setTotal(sum) - }, [key, getValues, setTotal]) + }, [formFieldKey, getValues, setTotal]) useEffect(() => { getSum() }, [getSum]) return [getSum, total] }libs/application/templates/inao/financial-statement-political-party/src/components/FileValueLine.tsx (1)
9-30
: LGTM! TheFileValueLine
component is well-structured and reusable.The component adheres to the coding conventions and best practices. It effectively uses TypeScript for defining the
Props
type and theuseLocale
hook for localization. The component is modular and can be effectively tree-shaken.A few additional suggestions for improvement:
- Consider adding a prop for configuring the background color of the
ActionCard
to make the component more flexible.- Consider adding a prop for configuring the tag label to make the component more reusable.
- Consider adding a prop for configuring the CTA button label and action to make the component more interactive.
libs/application/templates/inao/financial-statement-political-party/src/components/ValueLine.tsx (1)
1-29
: LGTM! TheValueLine
component is well-structured and adheres to the best practices.The component is reusable across different NextJS apps, uses TypeScript for defining props and exporting types, and utilizes the
useLocale
hook for localization. The layout and styling are simple and easy to understand, and the component doesn't have any complex logic or state management, which makes it easy to maintain and test.A few suggestions for further improvement:
- Consider adding prop types for the
label
andvalue
props to ensure that the component receives the expected data types.- Consider adding a default value for the
label
prop to handle cases where the label is not provided.- Consider adding unit tests to ensure that the component renders correctly with different prop combinations.
libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx (1)
18-36
: Consider applying the static analysis hints to improve the code quality and maintainability.The static analysis hints suggest using optional chaining to simplify the code and avoid potential errors.
Apply this diff to use optional chaining:
-setBeforeSubmitCallback && - setBeforeSubmitCallback(async () => { +setBeforeSubmitCallback?.(async () => { const userType = application.externalData.getUserType?.data const hasUserType = !!userType console.log('UserType: ', userType) if (hasUserType) { setError(VALIDATOR, { type: 'custom', message: formatMessage(m.wrongDelegation), }) return [false, formatMessage(m.wrongDelegation)] } else { return [true, null] } })Tools
Biome
[error] 18-34: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 36-36: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/mappers/mapValuesToPartyTypes.ts (1)
4-49
: Add an explicit return type annotation to improve code readability and maintainability.The
mapValuesToPartyTypes
function is well-structured and promotes reusability by encapsulating the mapping logic and exporting it for use in other parts of the application. The use ofgetValueViaPath
ensures safe access to nested properties, preventing potential runtime errors. The conversion of values to numbers facilitates further numerical operations or analyses.However, to improve code readability and maintainability, consider adding an explicit return type annotation to the function. This will clearly communicate the structure of the returned object and make it easier for other developers to understand and use the function.
Here's an example of how you can add the return type annotation:
interface PartyFinancialData { contributionsFromTheTreasury: number parliamentaryPartySupport: number municipalContributions: number contributionsFromLegalEntities: number contributionsFromIndividuals: number generalMembershipFees: number otherIncome: number capitalIncome: number officeOperations: number otherOperatingExpenses: number financialExpenses: number fixedAssetsTotal: number currentAssets: number longTermLiabilitiesTotal: number shortTermLiabilitiesTotal: number equityTotal: number } export const mapValuesToPartyTypes = (answers: FormValue): PartyFinancialData => { // ... }libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts (2)
1-7
: Constants look good! Consider moving hardcoded values to a configuration file.The constants are well-named, grouped together based on their purpose, and follow a consistent naming convention.
As a minor improvement, consider moving the hardcoded values (e.g.,
ELECTIONLIMIT
) to a configuration file. This will make it easier to update these values in the future without modifying the code.
66-67
: Constant looks good! Consider adding a more descriptive comment.The
VALIDATOR
constant is well-named and likely serves a clear purpose within the application.As a minor improvement, consider adding a more descriptive comment that explains how this constant is used for error handling or validation. This will make it easier for other developers to understand its purpose without having to search through the codebase.
libs/application/templates/inao/financial-statement-political-party/src/fields/KeyNumbersCapital/KeyNumbersCapital.tsx (1)
1-93
: LGTM! The component is well-structured, reusable, and adheres to best practices.The
KeyNumbersCapital
component is a great addition to the application. It effectively manages and displays key financial figures related to a political party's capital. The component is well-structured, reusable, and adheres to best practices. Here are some key observations:
- The component is located in the
libs
directory, making it reusable across different NextJS apps.- It uses TypeScript for defining props and exporting types, ensuring type safety and better developer experience.
- It effectively manages state and side effects using React hooks (
useState
,useEffect
).- It integrates well with the
react-hook-form
library for form state management and validation.- It optimizes performance by debouncing the input fields using
lodash/debounce
.- It handles errors appropriately, clearing validation issues when the user interacts with the input fields.
- The layout is responsive and well-structured using the grid system from
@island.is/island-ui/core
.- The total capital is displayed clearly in a separate
Total
component, enhancing the user interface.Overall, the component is well-designed and follows best practices for reusability, performance, and error handling.
Suggestions for improvement:
- Consider adding unit tests to ensure the component behaves as expected and to catch any potential regressions in the future.
- If the component grows in complexity, consider splitting it into smaller, more focused components to maintain readability and maintainability.
- Consider adding PropTypes or extending the TypeScript types for better documentation and type checking of the component's props.
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts (1)
36-44
: Improve type safety by explicitly defining the return type.The
getCurrentUserType
function provides a flexible way to determine the current user type. It aligns with the PR objective of improving user type handling.To improve type safety, consider explicitly defining the return type of the function. For example:
export const getCurrentUserType = (answers: any, externalData: any): string => { // ... }libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx (2)
59-59
: Consider using optional chaining forgoToScreen
calls.To improve code safety and readability, you can use optional chaining when calling the
goToScreen
function. This ensures that the function is only called if it exists, avoiding potential errors.- goToScreen && goToScreen('attachments.file') + goToScreen?.('attachments.file') - goToScreen && goToScreen('election') + goToScreen?.('election')Also applies to: 61-61
Tools
Biome
[error] 59-59: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
75-176
: The rendering logic for the overview sections is well-structured and utilizes shared UI components.The component effectively renders multiple sections for displaying financial data, ensuring a consistent design by using UI components from the
@island.is/island-ui/core
library. The custom components encapsulate specific sections, maintaining a clean and readable structure.Consider addressing the commented-out sections (income and expenses) in the future to provide a complete overview of the financial statement. If these sections are no longer needed, it's best to remove the commented code to keep the codebase clean.
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts (1)
83-83
: Ensure error messages are consistent in languageThe error message in the catch block is in Icelandic, whereas others are in English. Consistency in error message language improves clarity for developers and users.
Apply this diff to update the error message:
} catch (error) { - throw new Error('Villa kom upp við að senda umsókn') + throw new Error('An error occurred while sending the application.') }
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (71)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts (1 hunks)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/mappers/mapValuesToUserType.ts (1 hunks)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-individual-election/mappers/helpers.ts (0 hunks)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.modules.ts (1 hunks)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts (1 hunks)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/mappers/mapValuesToPartyTypes.ts (1 hunks)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/types/index.ts (1 hunks)
- libs/application/template-api-modules/src/lib/modules/templates/index.ts (3 hunks)
- libs/application/template-loader/src/lib/templateLoaders.ts (1 hunks)
- libs/application/templates/inao/README.md (1 hunks)
- libs/application/templates/inao/financial-statement-cemetery/src/fields/DelegationCheck/index.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-cemetery/src/forms/applicationForm/clientInfoSection/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/.babelrc (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/.eslintrc.json (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/README.md (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/jest.config.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/project.json (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/components/AboutOverview.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/components/AssetDebtEquityOverview.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/components/BottomBar.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/components/CapitalNumberOverview.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/components/FileValueLine.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/components/Logo.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/components/Total.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/components/ValueLine.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/components/css/overviewStyles.css.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/dataProviders/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/ElectionEquities/ElectionEquities.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/ElectionStatement/ElectionStatement.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/KeyNumbersCapital/KeyNumbersCapital.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/OperatingYear/OperatingYear.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/OperatingYear/styles.css.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOperatingIncome/PartyExpenses.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOperatingIncome/PartyIncome.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOperatingIncome/PartyOperatingIncome.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/PowerOfAttorneyFields/PowerOfAttorneyFields.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/Success/Success.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/clientInfoSection/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/capitalNumbersSubsection/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/equitiesAndLiabilitiesSubsection/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/financialStatementSection/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/operatingCostSubsection/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/overviewSection/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/overviewSection/overviewMultiField.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/done/conclusionSection/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/done/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/graphql/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/hooks/useSubmitApplication.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/hooks/useTotals.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/index.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/lib/dataSchema.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/lib/messages.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/types/types.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/tsconfig.json (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/tsconfig.lib.json (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/tsconfig.spec.json (1 hunks)
- libs/application/types/src/lib/ApplicationTypes.ts (2 hunks)
- libs/application/types/src/lib/InstitutionMapper.ts (1 hunks)
- tsconfig.base.json (2 hunks)
Files not reviewed due to no reviewable changes (1)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-individual-election/mappers/helpers.ts
Files skipped from review due to trivial changes (8)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/types/index.ts
- libs/application/templates/inao/financial-statement-cemetery/src/fields/DelegationCheck/index.tsx
- libs/application/templates/inao/financial-statement-cemetery/src/lib/financialStatementCemeteryTemplate.ts
- libs/application/templates/inao/financial-statement-political-party/.eslintrc.json
- libs/application/templates/inao/financial-statement-political-party/README.md
- libs/application/templates/inao/financial-statement-political-party/jest.config.ts
- libs/application/templates/inao/financial-statement-political-party/src/fields/index.ts
- libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/overviewSection/index.ts
Additional context used
Path-based instructions (60)
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.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/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/mappers/mapValuesToUserType.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/financial-statement-political-party/financial-statement-political-party.modules.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/financial-statement-political-party/financial-statement-political-party.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/template-api-modules/src/lib/modules/templates/financial-statement-political-party/mappers/mapValuesToPartyTypes.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/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/template-loader/src/lib/templateLoaders.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/inao/README.md (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/inao/financial-statement-cemetery/src/forms/applicationForm/clientInfoSection/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/inao/financial-statement-political-party/project.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/inao/financial-statement-political-party/src/components/AboutOverview.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/inao/financial-statement-political-party/src/components/AssetDebtEquityOverview.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/inao/financial-statement-political-party/src/components/BottomBar.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/inao/financial-statement-political-party/src/components/CapitalNumberOverview.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/inao/financial-statement-political-party/src/components/FileValueLine.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/inao/financial-statement-political-party/src/components/Logo.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/inao/financial-statement-political-party/src/components/Total.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/inao/financial-statement-political-party/src/components/ValueLine.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/inao/financial-statement-political-party/src/components/css/overviewStyles.css.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/inao/financial-statement-political-party/src/dataProviders/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/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.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/inao/financial-statement-political-party/src/fields/ElectionEquities/ElectionEquities.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/inao/financial-statement-political-party/src/fields/ElectionStatement/ElectionStatement.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/inao/financial-statement-political-party/src/fields/KeyNumbersCapital/KeyNumbersCapital.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/inao/financial-statement-political-party/src/fields/OperatingYear/OperatingYear.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/inao/financial-statement-political-party/src/fields/OperatingYear/styles.css.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/inao/financial-statement-political-party/src/fields/Overview/Overview.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/inao/financial-statement-political-party/src/fields/PartyOperatingIncome/PartyExpenses.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/inao/financial-statement-political-party/src/fields/PartyOperatingIncome/PartyIncome.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/inao/financial-statement-political-party/src/fields/PartyOperatingIncome/PartyOperatingIncome.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/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.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/inao/financial-statement-political-party/src/fields/PowerOfAttorneyFields/PowerOfAttorneyFields.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/inao/financial-statement-political-party/src/fields/Success/Success.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/inao/financial-statement-political-party/src/forms/applicationForm/clientInfoSection/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/inao/financial-statement-political-party/src/forms/applicationForm/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/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/capitalNumbersSubsection/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/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/equitiesAndLiabilitiesSubsection/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/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/financialStatementSection/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/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/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/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/operatingCostSubsection/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/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/overviewSection/overviewMultiField.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/inao/financial-statement-political-party/src/forms/done/conclusionSection/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/inao/financial-statement-political-party/src/forms/done/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/inao/financial-statement-political-party/src/forms/prerequsites/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/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.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/inao/financial-statement-political-party/src/graphql/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/inao/financial-statement-political-party/src/hooks/useSubmitApplication.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/inao/financial-statement-political-party/src/hooks/useTotals.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/inao/financial-statement-political-party/src/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/inao/financial-statement-political-party/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/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.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/inao/financial-statement-political-party/src/lib/messages.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/inao/financial-statement-political-party/src/types/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/templates/inao/financial-statement-political-party/src/utils/constants.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/inao/financial-statement-political-party/src/utils/helpers.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/inao/financial-statement-political-party/tsconfig.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/inao/financial-statement-political-party/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/inao/financial-statement-political-party/tsconfig.spec.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/types/src/lib/ApplicationTypes.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/types/src/lib/InstitutionMapper.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."
Biome
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.modules.ts
[error] 11-26: Avoid classes that contain only static members.
Prefer using simple functions instead of classes with only static members.
(lint/complexity/noStaticOnlyClass)
libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx
[error] 18-34: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 36-36: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/fields/ElectionEquities/ElectionEquities.tsx
[error] 59-76: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 202-202: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/fields/ElectionStatement/ElectionStatement.tsx
[error] 35-35: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 37-37: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx
[error] 59-59: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 61-61: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.tsx
[error] 53-53: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/lib/dataSchema.ts
[error] 32-32: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts
[error] 34-34: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
[error] 31-31: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.(lint/suspicious/noGlobalIsNan)
LanguageTool
libs/application/templates/inao/README.md
[misspelling] ~9-~9: Did you mean “be”?
Context: ...ction Financial statements that should he handed in with in three months of an el...(HE_BE)
Additional comments not posted (120)
libs/application/templates/inao/financial-statement-political-party/src/fields/OperatingYear/styles.css.ts (1)
1-5
: LGTM! The code adheres to the guidelines for reusable components in thelibs
directory.The
styles.css.ts
file defines a reusable CSS module using the@vanilla-extract/css
library, which is a CSS-in-JS solution for TypeScript. This approach ensures that the styles can be effectively tree-shaken and bundled for use across different NextJS apps.The
selectSpace
style applies a right padding of10px
to improve the spacing of elements within a user interface component, enhancing the visual layout and usability.Overall, the code follows the best practices for defining reusable styles in the
libs
directory.libs/application/templates/inao/financial-statement-political-party/.babelrc (1)
1-12
: The Babel configuration looks good!The
.babelrc
file is set up correctly for a React application:
- The
@nx/react/babel
preset is used, which is suitable for React applications.- The
runtime
option is set to "automatic", enabling the automatic runtime for JSX, which allows for more efficient handling of React components without needing to import React explicitly in every file.- The
useBuiltIns
option is set to "usage", optimizing the inclusion of polyfills based on the actual usage in the code, thereby reducing the bundle size and improving performance.- No additional plugins are specified, indicating a straightforward setup focused on the core functionality provided by the preset.
This configuration should work as expected and provide a solid foundation for the application.
libs/application/templates/inao/financial-statement-political-party/src/index.ts (3)
1-1
: LGTM!The import statement is syntactically correct and follows good practices by importing the template from a local library.
3-3
: Great use of dynamic imports!The
getDataProviders
andgetFields
functions utilize dynamic imports to modularly load their respective modules when called. This approach offers several benefits:
- Enhances maintainability and scalability by promoting a clear separation of concerns.
- Allows for easier updates and modifications to the data providers and field definitions without affecting the core template.
- Improves performance by loading modules only when needed.
Well done!
Also applies to: 4-4
6-6
: Appropriate default export!Exporting the
FinancialStatementPoliticalPartyTemplate
as the default export is suitable for thisindex.ts
file. It clearly identifies the template as the primary entity of the module, aligning with the file's purpose as the entry point for the financial statement template specific to political parties.libs/application/templates/inao/financial-statement-political-party/src/forms/done/index.ts (1)
1-10
: LGTM!The code segment follows the expected structure for defining a form using the
buildForm
function from the@island.is/application/core
package. It adheres to the reusability and modularity principles by utilizing the shared package.The form ID, title, and mode are appropriately set, indicating that this form represents the completed state of the application. The inclusion of the
conclusionSection
component as a child of the form suggests that it will contain the relevant information or actions to be presented to the user upon completion of their application.The code segment also imports and uses the necessary types from the
@island.is/application/types
package, following the TypeScript usage for defining the form object.Overall, the code segment is well-structured and aligns with the objectives of the PR.
libs/application/templates/inao/financial-statement-political-party/tsconfig.json (4)
2-8
: LGTM!The
compilerOptions
are configured correctly for a TypeScript project using React. The strict type-checking options and JSX support are enabled, which aligns with best practices.
9-10
: Emptyfiles
andinclude
arrays are acceptable.The empty
files
andinclude
arrays indicate that the module relies on the referenced configurations (tsconfig.lib.json
andtsconfig.spec.json
) for its file management. This is a valid approach to keep the configuration clean and modular.
11-18
: Referencing separate configurations is a good practice.The
references
section correctly points to two separate TypeScript configuration files:
tsconfig.lib.json
: Likely defines settings for library files.tsconfig.spec.json
: Likely defines settings for test files.This modular approach helps keep the main configuration clean and focused, while allowing for specific settings for different file types.
19-19
: Extending a base configuration ensures consistency.The
extends
property correctly points to a base TypeScript configuration file (tsconfig.base.json
) located at a higher directory level. This approach ensures consistency across the project by defining common settings shared by all modules.libs/application/templates/inao/financial-statement-political-party/tsconfig.lib.json (4)
2-2
: LGTM!Extending the base
tsconfig.json
configuration is a good practice to maintain consistency across projects.
3-6
: LGTM!The
compilerOptions
are configured correctly:
- The
outDir
option is set to a directory outside the library, which is appropriate for a compiled library.- Including
node
types is necessary for libraries that use Node.js APIs.
7-10
: LGTM!Including the type definitions for CSS modules and images from the Nx React library is necessary for libraries that use these features. This ensures that the library has access to the correct typings for these features, which enhances the library's type safety and integration with the broader application structure.
11-12
: LGTM!The
exclude
andinclude
configurations are set up correctly:
- Excluding test files is a good practice to ensure that only relevant source files are processed during compilation.
- Including all relevant file types from the
src
directory ensures that all necessary files are processed during compilation.libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/index.ts (1)
1-13
: LGTM!The code follows best practices and adheres to the guidelines for the
libs
directory:
- The form is built using the
buildForm
function from@island.is/application/core
, which promotes reusability across different NextJS apps.- The form is defined using TypeScript, which helps catch type-related errors at compile time.
- The form imports a reusable logo component.
- The form's structure is modular, with the prerequisites section imported separately.
Great job!
libs/application/templates/inao/financial-statement-political-party/src/types/types.ts (5)
1-3
: LGTM!The
Events
type is correctly defined and exported. TheDefaultEvents.SUBMIT
is a valid event type for submission, and the import statement is correct.
5-9
: LGTM!The
States
enumeration is correctly defined and exported. The enumeration values represent valid states for the application, and the naming convention is consistent and descriptive.
11-13
: LGTM!The
Roles
enumeration is correctly defined and exported. TheAPPLICANT
value represents a valid role for the user interacting with the application, and the naming convention is consistent and descriptive.
15-15
: LGTM!The
Config
type is correctly defined and exported. Thekey
andvalue
properties are of typestring
, which is appropriate for representing configuration settings, and the naming convention is consistent and descriptive.
17-20
: LGTM!The
ApiActions
enumeration is correctly defined and exported. The enumeration values represent valid actions for interacting with an API, and the naming convention is consistent and descriptive.libs/application/templates/inao/financial-statement-political-party/tsconfig.spec.json (1)
1-20
: LGTM!The
tsconfig.spec.json
file is well-structured and appropriately configured for the project's testing needs. It extends the base TypeScript configuration, sets the necessary compiler options for testing, and includes a comprehensive list of test file patterns.The configuration ensures consistency with the project's general settings while providing a tailored setup for running tests effectively.
libs/application/templates/inao/financial-statement-political-party/src/dataProviders/index.ts (4)
1-3
: Imports adhere to modular structure and reusability guidelines.The imports from
@island.is/application/types
enable the definition of reusable data providers later in the file, promoting modularity.
4-7
: Re-exports adhere to modular structure and reusability guidelines.The re-exports of
NationalRegistryUserApi
andIdentityApi
(aliased asIndentityApiProvider
) from@island.is/application/types
make these APIs available for reuse in other parts of the application, promoting modularity.
8-11
:CurrentUserTypeProvider
definition adheres to reusability guidelines and follows expected structure.The
CurrentUserTypeProvider
is defined using the reusabledefineTemplateApi
function from@island.is/application/types
. The provider configuration with thegetUserType
action andcurrentUserType
external data ID is clear and follows the expected structure.
12-16
:UserInfoApi
configuration adheres to reusability guidelines and follows expected structure.The
UserInfoApi
is configured using the reusableUserProfileApi
from@island.is/application/types
. The configuration with thecatchMock
parameter set totrue
is clear and follows the expected structure.Setting
catchMock
totrue
ensures that mock data will be used as a fallback if real user data is not available, providing a seamless experience during development and testing.libs/application/templates/inao/financial-statement-political-party/src/components/Logo.tsx (1)
5-18
: LGTM!The
Logo
component looks good:
- It correctly uses the
useLocale
hook for localization.- It correctly uses the
Text
andBox
components for rendering.- It correctly formats the localized messages.
- It is reusable across different NextJS apps as it does not contain any app-specific logic.
- It uses TypeScript for importing types from other libraries.
- It is tree-shakable as it only imports what it needs from other libraries.
libs/application/templates/inao/financial-statement-political-party/src/components/css/overviewStyles.css.ts (3)
3-12
: LGTM!The
columnStyle
object effectively uses Vanilla Extract CSS and media queries to define responsive padding for columns. The default padding of 0px and the adjusted padding of 0.5rem for screen sizes above 576px ensure a well-structured layout across different devices.
14-17
: LGTM!The
starterColumnStyle
object effectively uses Vanilla Extract CSS to define a fixed padding configuration for starter columns. The padding of 1.5rem for the top and 1rem for the bottom enhances the layout and readability of the starter columns.
19-26
: LGTM!The
sectionColumn
object effectively uses Vanilla Extract CSS and media queries to define styles specifically for print media. SettingflexBasis
andmaxWidth
to 50% ensures a well-structured and readable layout when the application is printed.libs/application/templates/inao/financial-statement-political-party/src/forms/done/conclusionSection/index.ts (1)
1-24
: Great job on structuring the conclusion section! The code looks clean and follows good practices.Some additional suggestions:
- Consider adding TypeScript types for the section configuration object to improve type safety and catch potential issues during development.
- Consider destructuring the
m
object for better readability. For example:const { received, applicationAccept } = m;Then, you can use
received
andapplicationAccept
directly in thetitle
properties.Overall, the code adheres to the reusability requirement by utilizing the
@island.is/application/core
library effectively. The section is well-structured and provides a clear success message to the user.libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/index.ts (1)
1-15
: LGTM! The code follows the required patterns for libs.The code in this file adheres to the guidelines mentioned in the additional instructions for files in the
libs
directory:
- The
keyNumbersSection
is built using reusable components (buildSection
from@island.is/application/core
) and modular subsections (operatingCostSubsection
,capitalNumbersSubsection
, andequitiesAndLiabilitiesSubsection
), which can be shared across different NextJS apps.- The file is written in TypeScript, although there are no explicit type definitions or exports in this particular file.
- The modular structure of the code facilitates effective tree-shaking and bundling practices.
Great job on structuring the code to enhance reusability and modularity!
libs/application/templates/inao/financial-statement-political-party/src/graphql/index.ts (3)
3-10
: LGTM!The
auditConfigQuery
is well-structured and follows the naming convention. It retrieves the necessary configuration settings for financial statements.
12-19
: Adheres to the additional instructions!The
IdentityQuery
is well-structured and follows the naming convention. It accepts an input of typeIdentityInput
and retrieves the necessary identity details.The query enhances reusability by allowing the retrieval of user-specific identity information based on the provided input. It also uses TypeScript for defining the input type, which aligns with the additional instructions.
21-28
: Adheres to the additional instructions!The
TaxInfoQuery
is well-structured and follows the naming convention. It accepts a year as an input parameter and retrieves the necessary tax information associated with financial statements for that specific year.The query uses TypeScript for defining the input type, which aligns with the additional instructions.
libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/operatingCostSubsection/index.ts (1)
1-17
: LGTM!The code segment 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.
The code segment is well-structured and follows a modular approach by utilizing the
buildSubSection
andbuildCustomField
functions. The usage of constants likePARTYOPERATIONIDS
ensures that the relevant data is collected efficiently.libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/equitiesAndLiabilitiesSubsection/index.ts (1)
1-17
: LGTM! The code segment adheres to the specified guidelines.The code segment demonstrates the following positive aspects:
It utilizes the
buildSubSection
andbuildCustomField
functions from the@island.is/application/core
library, promoting reusability of components across different NextJS apps.The use of TypeScript is evident in the import statements and the usage of the
buildSubSection
andbuildCustomField
functions, which likely define the expected props and export the necessary types.The modular approach of defining a subsection and a custom field within it aligns with effective tree-shaking and bundling practices, as it allows for granular inclusion of the required components.
Overall, the code segment adheres to the guidelines mentioned in the additional instructions, enhancing the modularity, reusability, and maintainability of the codebase.
libs/application/templates/inao/README.md (2)
3-5
: LGTM!The new section provides clear and concise information about the submission deadline for annual financial statements for cemeteries.
12-14
: LGTM!The new section provides clear and concise information about the submission deadline for annual financial statements for political parties.
libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/capitalNumbersSubsection/index.ts (1)
9-28
: LGTM!The
capitalNumbersSubsection
function correctly builds the subsection for capital numbers using thebuildSubSection
,buildMultiField
, andbuildCustomField
functions from the@island.is/application/core
library. The function adheres to the following principles:
- Reusability: The function utilizes the
buildSubSection
,buildMultiField
, andbuildCustomField
functions from the@island.is/application/core
library, which can be shared across different NextJS apps.- TypeScript usage: The function uses TypeScript for defining the structure of the subsection, multi-field, and custom field components, which helps catch potential type-related issues at compile time.
- Effective tree-shaking and bundling: The function effectively tree-shakes the unused properties of the
buildSubSection
,buildMultiField
, andbuildCustomField
functions, which helps reduce the bundle size.libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/index.ts (1)
10-22
: LGTM!The form configuration looks good:
- The form
id
andtitle
are appropriately set.- Setting the form
mode
toFormModes.DRAFT
allows for saving and modifying the form before final submission, providing flexibility to users.- Setting
renderLastScreenButton
tofalse
streamlines the user experience by not showing a button on the last screen.- The inclusion of a
Logo
component enhances the visual appeal and branding of the form.- The form sections (
clientInfoSection
,keyNumbersSection
,financialStatementSection
, andoverviewSection
) provide a modular structure for organizing the form content, enhancing maintainability and readability.libs/application/templates/inao/financial-statement-political-party/src/components/Total.tsx (1)
1-39
: LGTM!The
Total
component adheres to the guidelines specified in the additional instructions:
- It is reusable across different NextJS apps as it does not have any app-specific dependencies.
- It correctly uses TypeScript for defining props.
- It does not have any apparent issues with tree-shaking or bundling.
The component is well-structured and correctly utilizes the
useFormContext
hook to manage form state. It updates the form's value for the specifiedname
whenever thetotal
prop changes using theuseEffect
hook. The component also correctly renders thetitle
as a header if provided and theInputController
with the specified props.libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/financialStatementSection/index.ts (1)
9-30
: LGTM! The code is well-structured and follows best practices.The
financialStatementSection
function is implemented correctly and effectively utilizes thebuildSection
andbuildFileUploadField
functions to create a conditional section with a file upload field. The code is readable, maintainable, and promotes reusability.A few additional suggestions to further improve the code quality:
- Consider extracting the condition logic into a separate function to enhance readability and reusability. For example:
const shouldShowFinancialStatement = (answers: Answers) => { const incomeLimit = getValueViaPath(answers, 'election.incomeLimit') return incomeLimit !== LESS }Then, update the
condition
property:- condition: (answers, _externalData) => { - const incomeLimit = getValueViaPath(answers, 'election.incomeLimit') - return incomeLimit !== LESS - }, + condition: shouldShowFinancialStatement,
Consider adding type annotations to the
answers
and_externalData
parameters in the condition function to improve type safety and code comprehension.If the
LESS
constant is specific to this section, consider moving it closer to the section definition to improve code locality.Overall, great work on implementing this section! The code adheres to best practices and effectively utilizes the provided functions and constants.
libs/application/templates/inao/financial-statement-political-party/project.json (4)
1-6
: LGTM!The project metadata is defined correctly:
- The project name follows the naming convention.
- The schema is referencing a valid JSON schema file.
- The source root is set correctly.
- The project type is set to
library
.
8-10
: LGTM!The lint target is defined correctly using the
@nx/eslint:lint
executor.
11-16
: LGTM!The extract-strings target is defined correctly:
- It uses the
nx:run-commands
executor to run a custom command.- The command uses
ts-node
with a specific tsconfig file to run a script.- The script extracts localization strings from the
messages.ts
file.
17-23
: LGTM!The test target is defined correctly:
- It uses the
@nx/jest:jest
executor to run Jest.- The coverage output directory is set correctly.
- The Jest configuration file is specified.
libs/application/templates/inao/financial-statement-political-party/src/components/BottomBar.tsx (1)
1-37
: TheBottomBar
component looks great! It adheres to the specified guidelines and provides a reusable and accessible UI element.The component is well-structured and follows best practices:
- It is written in TypeScript and properly defines the props using a
Props
type, making it reusable across different NextJS apps.- It effectively uses tree-shaking by only importing what it needs from the
@island.is/island-ui/core
library.- It utilizes the
useLocale
hook for internationalization, ensuring that the button labels are properly localized.- It provides a clear and accessible layout with a divider and a flexbox container for the buttons.
- It handles user interactions through the
onBackButtonClick
andonSendButtonClick
callback props, enhancing the user experience with clear actions and loading feedback.Great job on creating a reusable and integral part of the application's user interface!
libs/application/templates/inao/financial-statement-political-party/src/hooks/useSubmitApplication.tsx (1)
1-43
: LGTM!The custom React hook
useSubmitApplication
is well-defined and 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.
The hook encapsulates the logic for submitting an application using GraphQL, which allows for a clean and reusable way to submit applications within the application's UI. It also handles errors and ensures that the
refetch
function is called upon successful completion of the mutation, which improves the user experience.libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.modules.ts (1)
12-25
: LGTM!The
register
method sets up the necessary imports, providers, and exports for the module's functionality. It promotes reusability by importing and registering theSharedTemplateAPIModule
, and integrates theConfigModule
for configuration management. The use of TypeScript for defining the configuration object type is also appreciated.The code adheres to the additional instructions by:
- Promoting reusability through the use of shared modules and configuration.
- Utilizing TypeScript for defining props and exporting types.
Overall, the module establishes a structured approach to managing financial statement templates specific to political parties, facilitating better organization and modularity within the application.
libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/keyNumbersSection/overviewSection/overviewMultiField.ts (1)
1-37
: LGTM! The code segment adheres to the specified guidelines.The implementation of the
overviewMultiField
component follows a modular and reusable approach, making it suitable for use across different NextJS apps. The code segment effectively utilizes TypeScript for defining props and exporting types, as evident from the usage ofbuildCustomField
andbuildMultiField
functions from@island.is/application/core
.The conditional rendering of custom fields based on the
election.incomeLimit
value enhances the form's interactivity and user experience. The use of constants and messages from separate modules promotes code organization and maintainability.Overall, the code segment is well-structured and adheres to the guidelines mentioned in the additional instructions.
libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx (1)
1-45
: TheDelegationCheck
component follows good practices and is reusable across different NextJS apps.The component is modular, follows the separation of concerns principle, and uses TypeScript for defining props and exporting types. It also uses reusable hooks and components from the
island-ui
library and localizes the error message usingformatMessage
.Tools
Biome
[error] 18-34: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 36-36: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts (4)
6-8
: LGTM!The function logic is correct, and the implementation is accurate.
10-24
: LGTM!The function logic is correct, and the implementation is accurate.
39-40
: LGTM!The function logic is correct, and the implementation is accurate.
42-42
: LGTM!The function logic is correct, and the implementation is accurate.
libs/application/templates/inao/financial-statement-political-party/src/components/CapitalNumberOverview.tsx (1)
1-49
: LGTM!The
CapitalNumberOverview
component is well-structured and follows best practices. It effectively utilizes the Island UI components to create a user-friendly layout and uses theuseLocale
hook for internationalization. The component is reusable and can be used across different NextJS apps. The use of TypeScript to define the prop type helps catch type-related errors at compile time.Some additional suggestions for improvement:
Consider adding PropTypes validation to the component to provide runtime type checking in addition to the TypeScript type definition.
Consider adding a loading state or placeholder for the financial data to improve the user experience while the data is being fetched.
Consider adding error handling for cases where the financial data is not available or fails to load.
Overall, the component is well-implemented and adheres to the guidelines for reusability, TypeScript usage, and effective bundling practices.
libs/application/templates/inao/financial-statement-political-party/src/fields/Success/Success.tsx (1)
1-54
: LGTM! TheSuccess
component is well-implemented and adheres to the required guidelines.The component demonstrates the following positive aspects:
- Reusability: It utilizes UI components from the
@island.is/island-ui/core
library, promoting reusability across different NextJS apps.- TypeScript usage: It defines the
PropTypes
interface for the component props and exports the component type, ensuring type safety.- Effective data handling: It extracts and uses data from the
application
object effectively.- Localization: It properly handles localization using the
useLocale
hook and theformatMessage
function.- User experience: It provides a clear success message and a call-to-action link for users to navigate to their personal pages.
- Code structure: It follows good practices for readability and maintainability.
libs/application/templates/inao/financial-statement-political-party/src/forms/prerequsites/prerequsitesSection.ts (4)
1-56
: LGTM!The imports adhere to the reusability principle by using shared libraries from
@island.is/application/core
and@island.is/application/types
. TheprerequisitesSection
constant is appropriately built using thebuildSection
function, following a common pattern of providing a title and children.
20-40
: Looks good!The external data provider is correctly configured using the
buildExternalDataProvider
function. The data providers are appropriately defined as an array of data provider items, each built usingbuildDataProviderItem
and a specific data provider. The inclusion of relevant titles and subtitles enhances user understanding of the data being collected.
41-53
: Submit field configuration looks good!The submit field is correctly built using the
buildSubmitField
function, with necessary options such as ID, placement, and title. SettingrefetchApplicationAfterSubmit
totrue
ensures that the application data is refreshed after submission. The action triggering theDefaultEvents.SUBMIT
event is appropriately configured with a name and type.
1-56
: Overall assessment: Excellent code quality and adherence to best practices!The code in this file demonstrates excellent adherence to the reusability principle by utilizing shared libraries and functions from
@island.is/application/core
and@island.is/application/types
. The section, external data provider, and submit field are correctly configured using the appropriate functions and following common patterns.The code is well-structured, and no major issues or concerns were identified during the review. It meets the requirements specified in the additional instructions, ensuring reusability, proper TypeScript usage, and effective bundling practices.
Great job on this implementation!
libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOperatingIncome/PartyExpenses.tsx (5)
1-15
: LGTM!The imports are properly organized and the
PropTypes
interface correctly defines the expected props for the component.
17-24
: LGTM!The component declaration and the
onInputChange
function are properly defined. Debouncing theonInputChange
function is a good practice to limit the frequency of calls togetSum
andclearErrors
.
28-41
: LGTM!The "Election Office" input field is properly configured using the
InputController
component. The use of constants for theid
,name
, and error path ensures consistency and maintainability. TheonChange
anderror
props are correctly set, and the additional props for styling and currency formatting are appropriate.
42-53
: LGTM!The "Other Operational Cost" input field is properly configured using the
InputController
component, similar to the "Election Office" input field. The use of constants for theid
,name
, and error path ensures consistency and maintainability. TheonChange
anderror
props are correctly set, and the additional props for styling and currency formatting are appropriate.
1-56
: Excellent work!The
PartyExpenses
component is a well-structured and properly implemented component that follows best practices and adheres to the guidelines. It is modular, reusable, and correctly uses TypeScript for defining props and types. The component is properly integrated with thereact-hook-form
library for form state management, and error handling is done correctly using thegetErrorViaPath
function.Great job on creating a clean and maintainable component!
libs/application/templates/inao/financial-statement-political-party/src/components/AboutOverview.tsx (1)
1-62
: LGTM!The
AboutOverview
component is well-structured and follows best practices:
- It uses TypeScript to define the prop type, which ensures type safety and improves code readability.
- It uses external utility functions to format the data, which keeps the component focused on rendering and improves code reusability.
- It uses conditional rendering to handle optional data, which makes the component more flexible and adaptable to different scenarios.
- It is reusable as it accepts data through props and does not have any hard-coded values, which makes it easy to use in different parts of the application.
- It does not have any state or side effects, which makes it easy to test and maintain.
- It does not have any performance issues as it only renders a small amount of data.
The component also adheres to the additional instructions:
- It is reusable across different NextJS apps as it does not depend on any app-specific logic or data.
- It uses TypeScript to define the prop type and exports the prop type, which makes it easy to use in other parts of the application.
- It does not have any unnecessary dependencies or imports, which ensures effective tree-shaking and bundling.
libs/application/templates/inao/financial-statement-political-party/src/fields/OperatingYear/OperatingYear.tsx (1)
25-82
: LGTM!The
OperatingYear
component is well-structured and follows best practices:
- It is reusable across different NextJS apps as it doesn't depend on any app-specific logic.
- It uses TypeScript for defining props and exporting types, which helps catch type-related bugs early and improves code maintainability.
- It imports only the necessary dependencies, which helps with effective tree-shaking and bundling.
The component handles different states (loading, error, data) effectively and provides clear user feedback in each case. The use of GraphQL for fetching configuration data and the
SelectController
for rendering the select field is a good architectural choice.Overall, the component is a great addition to the codebase and aligns well with the PR objectives.
libs/application/templates/inao/financial-statement-political-party/src/components/AssetDebtEquityOverview.tsx (3)
1-11
: LGTM!The imports and type definitions are properly organized and follow a consistent pattern. The
Props
type correctly defines the expected prop for the component.
18-37
: LGTM!The assets section is well-structured and easy to understand. The use of the
GridColumn
component ensures a responsive layout, and theValueLine
component is used consistently to display the asset values. TheformatCurrency
function is used correctly to format the currency values.
39-69
: LGTM!The debts and equity section is well-structured and easy to understand. The use of the
GridColumn
component ensures a responsive layout, and theValueLine
component is used consistently to display the liability and equity values. TheformatCurrency
function is used correctly to format the currency values.libs/application/templates/inao/financial-statement-political-party/src/utils/constants.ts (3)
9-18
: LGTM!The
ABOUTIDS
object is well-structured and follows good naming conventions. Grouping related IDs together in an object improves code organization and readability.
20-40
: Looks good!The
PARTYOPERATIONIDS
andOPERATINGCOST
objects are well-structured and follow good naming conventions. Grouping related IDs together in objects improves code organization and readability.
42-64
: LGTM!The
CAPITALNUMBERS
andEQUITIESANDLIABILITIESIDS
objects are well-structured and follow good naming conventions. Grouping related IDs together in objects improves code organization and readability.libs/application/templates/inao/financial-statement-cemetery/src/forms/applicationForm/clientInfoSection/index.ts (1)
20-20
: Simplification of description logic is acceptable, but consider the impact on user experience.The change to statically set the description to
m.reviewContact
for all users simplifies the code by removing the conditional logic based on user type. This reduction in complexity is a positive change from a maintainability perspective.However, it's important to consider the potential impact on the user experience. By providing a uniform description for all users, the application form may lose the personalized touch that was previously available for individual users. This could potentially lead to a less tailored experience for certain user segments.
If the personalization is not a critical requirement and the simplified description adequately serves the needs of all users, then this change is acceptable. Otherwise, consider whether the trade-off between code simplicity and user experience is justified.
libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOperatingIncome/PartyOperatingIncome.tsx (1)
23-89
: LGTM! The component is well-structured, modular, and enhances the application's functionality.The
PartyOperatingIncome
component is well-designed and effectively displays a political party's income and expenses for a specified operating year. The use of separate components for income and expenses, custom hooks likeuseTotals
, and theuseLocale
hook for localization promotes code reusability, maintainability, and a better user experience.The component correctly utilizes the Apollo Client to fetch tax information based on the operating year and accesses form state and validation errors using the
useFormContext
hook. The calculated totals for income, expenses, and operating costs provide a clear financial overview.To further enhance reusability and maintainability, consider the following suggestions:
- Extract the
GridRow
andGridColumn
components that wrap the income and expenses sections into separate components to reduce duplication and improve readability.- Consider creating a custom hook to encapsulate the logic for fetching tax information based on the operating year to promote reusability across other components that may require similar data.
Overall, the component is a valuable addition to the application and effectively meets the PR objectives.
libs/application/templates/inao/financial-statement-political-party/src/fields/ElectionStatement/ElectionStatement.tsx (1)
14-84
: Excellent work on theElectionStatement
component!The component is well-structured, follows a logical flow, and effectively handles the display and submission of an election statement for a political party application. The use of hooks and components from the
@island.is
library promotes code reusability and maintainability.Some key highlights:
- The component retrieves and formats the necessary application data for display.
- The navigation logic based on the income limit value is clear and concise.
- The submission process is handled using a custom hook, which is a good practice for separating concerns.
- The UI elements are organized and provide relevant information to the user.
- Error handling is implemented to display input errors related to application approval.
- The
BottomBar
component is used to provide a consistent and user-friendly interface for navigation and submission.Overall, this component is a crucial part of the political party application and contributes to the overall functionality and user experience. Keep up the great work!
Tools
Biome
[error] 35-35: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 37-37: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/forms/applicationForm/clientInfoSection/index.ts (2)
1-12
: LGTM!The imports adhere to the TypeScript usage guideline for defining props and exporting types. The imported utility functions and types are used effectively to construct the form section and fields.
13-94
: Excellent work on the client info section!The
clientInfoSection
is well-structured and adheres to the reusability guidelines for components across different NextJS apps. The section effectively utilizes various utility functions to construct the form fields, enhancing code reusability and maintainability.The inclusion of read-only fields with default values derived from the application context is a great way to enhance the user experience and ensure data accuracy. The custom field for managing power of attorney details is a valuable addition to support the application's functionality.
Overall, the section is designed to facilitate the collection of comprehensive client information while ensuring a smooth user experience. Great job!
libs/application/templates/inao/financial-statement-political-party/src/fields/PowerOfAttorneyFields/PowerOfAttorneyFields.tsx (1)
21-97
: LGTM!The
PowerOfAttorneyFields
component is well-structured, reusable, and properly typed. It adheres to the following:
- Reusability: The component takes
application
as a prop and uses it to fetch the current actor's national ID, making it reusable across different NextJS apps.- TypeScript usage: The component uses TypeScript for defining the prop type
FieldBaseProps
and the query result typeQuery
, ensuring type safety.- Bundling practices: The component imports necessary dependencies from shared libraries, indicating proper tree-shaking and bundling practices.
Additionally, the component follows best practices such as using
useEffect
for side effects, handling loading and error states, and using responsiveisland-ui
components for styling.Great job!
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/mappers/mapValuesToUserType.ts (1)
10-14
: LGTM!The introduction of the
BoardMember
type enhances type safety and clarity regarding the structure of board member data. The localized definition within the current file improves modularity and reduces external dependencies. The type definition follows the TypeScript syntax and naming conventions.libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts (2)
31-34
: LGTM!The
DataResponse
interface provides a clear and standardized structure for data responses. It enhances the clarity of the code by explicitly defining the shape of the response object.
36-44
: Verify the assumptions about the data structures and consider using constants for the paths.The
getCurrentUserType
function assumes a specific structure for theanswers
andexternalData
objects. It uses hardcoded string literals to access the nested properties.Please verify that the assumptions about the data structures are correct and will hold true in all scenarios.
To improve maintainability and readability, consider extracting the hardcoded paths into constants. For example:
const FAKE_USER_TYPE_PATH = 'fakeData.options'; const USER_TYPE_PATH = 'getUserType.data.value'; export const getCurrentUserType = (answers: any, externalData: any) => { const fakeUserType: any = getValueViaPath(answers, FAKE_USER_TYPE_PATH); const currentUserType: any = getValueViaPath(externalData, USER_TYPE_PATH); // ... }libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts (4)
1-30
: LGTM!The imports and the
configuration
constant are correctly defined. The code segment looks good.
32-151
: The template definition looks good!The
FinancialStatementPoliticalPartyTemplate
is well-structured and follows the expected format for anApplicationTemplate
. The state machine configuration is clearly defined with appropriate metadata and transitions.Additionally, please ensure the following:
- The components and hooks used in the template are reusable across different NextJS apps.
- TypeScript is properly used for defining props and exporting types.
- The template is optimized for effective tree-shaking and bundling.
142-150
: LGTM!The
mapUserToRole
function is correctly implemented. It properly maps the user to theAPPLICANT
role based on the provided condition. The code segment looks good.
153-153
: LGTM!The default export of the
FinancialStatementPoliticalPartyTemplate
is correctly defined. The code segment looks good.libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOperatingIncome/PartyIncome.tsx (4)
1-11
: LGTM!The imports are well-organized, follow a consistent pattern, and cover all the necessary dependencies. There are no unused imports.
13-20
: LGTM!The
PropTypes
interface correctly defines the expected props and their types. The props are named appropriately and cover all the necessary data and functions required by the component. The usage ofRecordObject
andFinancialStatementsInaoTaxInfo
types ensures type safety.
30-67
: LGTM!The
useEffect
hook correctly initializes the form values based on the provided data. It checks if the values are already set before populating them to avoid overwriting user input. It usesgetValueViaPath
andsetValue
functions from the form context to retrieve and set form values. It calls thegetSum
function to recalculate the total income whenever the form values change. The dependencies array includes all the necessary dependencies.
69-205
: LGTM!The
onInputChange
function correctly debounces the input changes to optimize performance and avoid unnecessary recalculations. It calls the necessary functions to recalculate the total income and clear the field-specific errors.The
InputController
components are properly configured with the required properties. The usage offormatMessage
ensures localization of the field labels. TheonChange
prop correctly calls theonInputChange
function with the corresponding field ID. Theerror
prop is correctly set by retrieving the error message usinggetErrorViaPath
. The consistent styling properties likerightAlign
,backgroundColor
, andcurrency
ensure a uniform appearance of the input fields.libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx (7)
1-29
: Imports look good!The imports are well-organized, relevant, and cover all the necessary dependencies for the component. Great job!
31-47
: Component props and state are properly defined.The component receives the necessary props and uses the
useState
hook appropriately to manage the local state. The type assertions ensure type safety and access to the required properties.
37-53
: Form handling and submission logic is implemented correctly.The component utilizes
react-hook-form
and custom hooks effectively for form handling and submission. TheonSendButtonClick
function properly checks theapproveOverview
state and either submits the application or sets an error. Well done!Also applies to: 65-73
55-63
: TheonBackButtonClick
function correctly navigates based on theincomeLimit
value.The function properly extracts the
incomeLimit
value using thegetValueViaPath
utility and navigates to the appropriate screen based on its value. The conditional calling ofgoToScreen
ensures safe navigation.Tools
Biome
[error] 59-59: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 61-61: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
178-208
: The checkbox for approving the overview is implemented correctly usingreact-hook-form
.The component utilizes the
Controller
component fromreact-hook-form
to manage the checkbox state and validation effectively. TheonChange
handler ensures that the checkbox state is synced with theapproveOverview
state and the form value. The error message is conditionally rendered based on the presence of theapplicationApprove
error, providing clear feedback to the user.
209-223
: Error handling and submission feedback are implemented effectively.The component displays a clear error message using the
AlertBanner
component in case of a submission error. The conditional rendering based on thesubmitError
state ensures that the error is only shown when necessary. TheBottomBar
component encapsulates the rendering of the send and back buttons, along with the loading state, keeping the main component focused and maintainable.
1-226
: Overall assessment: TheOverview
component is a well-implemented and comprehensive solution for displaying the financial statement overview.The component follows best practices for React development, utilizing hooks, libraries, and shared UI components effectively. The form handling and submission logic is implemented correctly, with proper error handling and user feedback. The component is structured into clear sections, each responsible for displaying specific financial data, making it maintainable and readable.
Some areas for improvement:
- Consider addressing the commented-out sections (income and expenses) to provide a complete overview or remove the commented code if no longer needed.
- Use optional chaining for
goToScreen
calls to improve code safety and readability.Overall, the
Overview
component is a solid implementation that effectively fulfills its purpose within the application.Tools
Biome
[error] 59-59: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 61-61: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.tsx (5)
1-29
: Imports look good!The imports are well-organized, follow a consistent naming convention, and cover all the necessary dependencies for the component. There are no unused imports or missing dependencies based on the code provided.
31-50
: Component props and state management look good!
- The component accepts relevant props and manages the local state properly.
- Using
useFormContext
is a good practice for accessing form-related values and methods.- Extracting
answers
and assigning a specific type helps with type safety and code readability.- The
useSubmitApplication
custom hook encapsulates the submission logic, which is a good separation of concerns.
52-64
: Button click handlers are implemented correctly!
- The
onBackButtonClick
handler navigates to the previous screen using thegoToScreen
prop, which is a common pattern in multi-step forms.- The
onSendButtonClick
handler checks theapproveOverview
state before submitting the form, which is a good validation practice.- Setting an error when
approveOverview
is false provides user feedback and prevents invalid form submission.Tools
Biome
[error] 53-53: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
66-221
: JSX structure and component usage look great!
- The JSX is well-structured and uses semantic components to separate different sections of the overview.
- Using custom components for specific sections improves code readability and reusability.
- Conditional rendering of the
FileValueLine
component based on the presence of a file is a good practice.- Using the
Controller
component for the checkbox ensures that the form state is managed properly.- Rendering an
InputError
component for theapplicationApprove
field provides user feedback for validation errors.- Rendering an
AlertBanner
component for submission errors keeps the user informed about the submission status.- The
BottomBar
component provides a consistent navigation experience.
1-222
: Component meets the additional requirements!
- The component uses reusable UI components from the
@island.is/island-ui/core
library and custom reusable components, which can be used across different NextJS apps.- The component uses TypeScript for defining props and importing types, ensuring type safety.
- The component imports only the necessary dependencies and doesn't have any unused imports, which helps with tree-shaking and bundling.
Regarding the static analysis hint:
The suggestion to use an optional chain on line 53 is a false positive because
goToScreen
is an optional prop and the code already handles it correctly using the&&
operator.Tools
Biome
[error] 53-53: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/fields/ElectionEquities/ElectionEquities.tsx (5)
1-213
: The component is designed to be reusable and modular.The component is located in the
libs
folder, indicating it is intended for reuse across different NextJS apps. It uses generic props (FieldBaseProps
) and integrates with thereact-hook-form
library using theuseFormContext
hook, allowing it to be used in different form contexts. The component also uses reusable UI components from the@island.is/island-ui/core
library, promoting consistency and modularity. By encapsulating the logic for managing financial statements, the component is self-contained and modular.Tools
Biome
[error] 59-76: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 202-202: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
4-4
: The component properly uses TypeScript for type safety and consistency.The component imports and uses the
FieldBaseProps
type from@island.is/application/types
for its props, ensuring type safety and consistency with other form fields. It also exports a typed constantElectionEquities
with theFieldBaseProps
type, making it easy to integrate with other TypeScript code.Also applies to: 26-28
2-2
: The component optimizes performance using debounce and does not have any obvious performance bottlenecks.The component uses the
debounce
function from thelodash
library to optimize the performance of input field updates by reducing the frequency of updates as users type. TheINPUTCHANGEINTERVAL
constant provides a centralized way to configure the debounce interval, making it easy to adjust if needed. The component does not have any obvious performance bottlenecks or unnecessary re-renders, indicating that it should have good performance characteristics.Also applies to: 21-21, 98-101, 115-118, 139-142, 157-160, 180-183
59-76
: The validation logic correctly ensures that the financial data is consistent.The component performs validation in the
setBeforeSubmitCallback
function to ensure that the sum of liabilities and equity equals the total assets. The validation logic calculates the total assets, liabilities, and equities using thegetTotal
helper function. If the validation fails, the component sets an error using thesetError
function from thereact-hook-form
library. The component also clears any existing errors whenever the totals change using theuseEffect
hook and theclearErrors
function, ensuring that the validation state is always up to date.Tools
Biome
[error] 59-76: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
86-104
: The component provides a user-friendly interface and clear error handling.The component displays input fields for fixed and current assets, long-term and short-term liabilities, and total equity using the
InputController
component, providing a consistent and user-friendly interface for entering financial data. It also displays the total assets, total liabilities, and the sum of equity and liabilities using theTotal
component, helping users quickly understand the overall financial picture. When the validation fails, the component displays an error message using theAlertBanner
component, providing clear feedback to the user about any inconsistencies in the financial data. The component clears the error message whenever the totals change using theuseEffect
hook and theclearErrors
function, ensuring that the user is not confused by stale error messages.Also applies to: 107-122, 135-150, 153-168, 176-191, 202-210
libs/application/template-loader/src/lib/templateLoaders.ts (1)
74-77
: LGTM!The code segment adheres to the following guidelines:
- Reusability: The
financial-statement-political-party
template can be loaded based on theApplicationTypes.FINANCIAL_STATEMENT_POLITICAL_PARTY
type, promoting reusability across different NextJS apps.- TypeScript usage: The code follows the TypeScript pattern for defining the record type, ensuring type safety.
- Effective tree-shaking and bundling: The dynamic import ensures that the template module is loaded only when needed, aligning with the lazy-loading strategy employed in this file.
The code segment enhances the functionality of the template loader by supporting a new application type while promoting modularity and maintainability.
libs/application/types/src/lib/ApplicationTypes.ts (2)
36-36
: LGTM!The new enum value
FINANCIAL_STATEMENT_POLITICAL_PARTY
is correctly added to theApplicationTypes
enum.
223-226
: Looks good!The configuration for
FINANCIAL_STATEMENT_POLITICAL_PARTY
is correctly added to theApplicationConfigurations
object, including the appropriateslug
andtranslation
values.libs/application/types/src/lib/InstitutionMapper.ts (1)
172-176
: LGTM!The new mapping entry for
ApplicationTypes.FINANCIAL_STATEMENT_POLITICAL_PARTY
is consistent with the existing structure and uses the correct values fornationalId
,slug
, andcontentfulId
.This addition enhances the reusability of the
institutionMapper
object by allowing it to handle a new application type.The usage of TypeScript for defining the
ApplicationTypes
enum and other related types ensures type safety and improves the maintainability of the codebase.libs/application/template-api-modules/src/lib/modules/templates/index.ts (2)
33-34
: LGTM!The new imports for the
financial-statement-political-party
feature adhere to the existing naming conventions and file structure. They correctly reference the module and service files, enabling reusability across NextJS apps. The imports also follow TypeScript best practices for defining and exporting types.
176-176
: LGTM!The
FinancialStatementPoliticalPartyTemplateModule
andFinancialStatementPoliticalPartyTemplateService
are correctly added to themodules
andservices
arrays, respectively. The additions maintain the alphabetical ordering of the arrays, enhancing readability and maintainability. Exporting the module and service in these arrays enables them to be easily imported and utilized by other parts of the application.Also applies to: 249-249
libs/application/templates/inao/financial-statement-political-party/src/lib/messages.ts (2)
1-2
: LGTM!The import statement for the
defineMessages
function from thereact-intl
library is correctly structured.
3-561
: Great job with the internationalized messages!The message definitions are well-structured and follow best practices for using
react-intl
. The consistent naming convention for message identifiers enhances maintainability and readability. The default messages being in Icelandic aligns with the intended localization of the application, and the descriptions in English provide helpful context for developers.A few minor suggestions for further improvement:
- Consider organizing the messages into logical groups or categories to enhance readability and maintainability as the number of messages grows.
- Ensure that the descriptions accurately reflect the purpose and context of each message.
Overall, the internationalized messages are set up effectively to support the localization of the application.
tsconfig.base.json (2)
387-389
: LGTM!The new path mapping for the
@island.is/application/templates/financial-statement-political-party
module is set up correctly, pointing to the appropriate source file. This will help maintain a consistent import structure across the codebase.
1118-1120
: Looks good!The additional path mapping for the
financial-statement-political-party
module is set up correctly, pointing to the same source file as the previous mapping. This provides an alternative, shorter path for importing the module, which can be useful in different parts of the codebase.libs/application/templates/inao/financial-statement-political-party/src/lib/dataSchema.ts (1)
145-145
: Confirm necessity of 'election' field indataSchema
There is a comment questioning whether the 'election' field is needed in the
dataSchema
. Please verify if this field is required. If it is unnecessary, consider removing it to simplify the schema.libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts (1)
1-181
: Adhere to additional instructions for library filesAs this file is within the
libs/**/*
path, please ensure:
- Reusability: Check if any methods or interfaces can be abstracted for reuse across different NextJS apps.
- TypeScript Best Practices: Ensure all props and types are well-defined and exported where necessary.
- Tree-Shaking and Bundling: Verify that imports are optimized and only necessary code is included to promote effective tree-shaking.
Consider reviewing the imports and exports to ensure they align with best practices for library code.
...templates/financial-statement-political-party/financial-statement-political-party.modules.ts
Outdated
Show resolved
Hide resolved
...ates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx
Outdated
Show resolved
Hide resolved
libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts
Outdated
Show resolved
Hide resolved
libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
Datadog ReportAll test runs ✅ 69 Total Test Services: 0 Failed, 67 Passed Test ServicesThis report shows up to 10 services
🔻 Code Coverage Decreases vs Default Branch (1)
|
There was a problem hiding this 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
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (5)
- libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/ElectionStatement/ElectionStatement.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- libs/application/templates/inao/financial-statement-political-party/src/fields/ElectionStatement/ElectionStatement.tsx
Additional context used
Path-based instructions (4)
libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.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/inao/financial-statement-political-party/src/fields/Overview/Overview.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/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.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/inao/financial-statement-political-party/src/utils/helpers.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."
Biome
libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx
[error] 18-32: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 34-34: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx
[error] 59-59: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 61-61: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.tsx
[error] 53-53: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts
[error] 34-34: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
[error] 31-31: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.(lint/suspicious/noGlobalIsNan)
Additional comments not posted (15)
libs/application/templates/inao/financial-statement-political-party/src/fields/DelegationCheck/DelegationCheck.tsx (1)
1-43
: LGTM!The
DelegationCheck
component follows the coding guidelines by being reusable, using TypeScript for defining props and exporting types, and enabling effective tree-shaking and bundling. The component logic is correct, and the implementation is accurate.Tools
Biome
[error] 18-32: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 34-34: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
libs/application/templates/inao/financial-statement-political-party/src/utils/helpers.ts (6)
6-8
: LGTM!The function logic is correct, and the implementation is accurate.
10-24
: LGTM!The function logic is correct, and the implementation is accurate. The use of the
date-fns
library for date manipulation is a good practice.
39-40
: LGTM!The function logic is correct, and the implementation is accurate. The use of a regular expression for formatting is a good practice.
42-42
: LGTM!The function logic is correct, and the implementation is accurate. The use of
toLocaleString
for formatting is a good practice.
44-44
: LGTM!The function has been simplified based on the previous suggestion, and the implementation is now accurate.
26-37
: Fix the assignment in the expression and useNumber.isNaN
.The function has the following issues:
- The assignment in the expression at line 34 is confusing and should be avoided.
- The use of
isNaN
at line 31 is unsafe and should be replaced withNumber.isNaN
.Apply this diff to fix the issues:
- .reduce((prev, current) => { - return (prev += current) - }, 0) + .reduce((prev, current) => prev + current, 0) - .filter(([k, v]) => k !== TOTAL && !isNaN(Number(v))) + .filter(([k, v]) => k !== TOTAL && !Number.isNaN(Number(v)))Tools
Biome
[error] 34-34: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
[error] 31-31: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.(lint/suspicious/noGlobalIsNan)
libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx (4)
1-30
: Imports look good!The component imports necessary dependencies and follows a modular structure by importing custom modules from the application's folders.
31-53
: Props and hooks usage looks good!The component receives properly typed props and uses hooks appropriately. The
useSubmitApplication
hook is called with the correct arguments to submit the application.
65-73
:onSendButtonClick
function looks good!The function correctly submits the application only if the user has approved the overview. It also sets an error on the
applicationApprove
field if not approved, which is a good validation practice.
75-226
: Component's JSX looks good!The component's JSX is well-structured and uses semantic HTML elements. The commented-out sections are not causing any issues and can be left as is. The checkbox for approving the overview is controlled correctly by the
applicationApprove
field. Error handling for theapplicationApprove
field and submit errors is implemented properly. TheBottomBar
component is used correctly with the necessary props.libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.tsx (4)
1-29
: Imports follow recommended practices.The import statements adhere to the guidelines for libs:
- Named imports are used for better tree-shaking.
- There are no unused imports.
- The imports are organized and readable.
31-35
: Component props are correctly typed and used.The
PartyOverview
component receives props that are:
- Correctly typed using
FieldBaseProps
.- Effectively used within the component's logic.
- Not unused or redundant.
36-50
: Hooks are used appropriately and follow best practices.The component demonstrates effective usage of hooks:
- The
useLocale
hook is used for localization.- The
useFormContext
hook is used to access form state and methods.- The
useSubmitApplication
custom hook encapsulates the submission logic, promoting reusability.- The
useState
hook is used for local state management of the approval checkbox.The hooks are used in accordance with the rules of hooks and follow best practices.
66-221
: JSX structure and rendering logic are well-implemented.The JSX in the component follows best practices and demonstrates effective rendering:
- The structure is well-organized and readable, with clear sections for each part of the financial statement overview.
- UI components from the
@island.is/island-ui/core
library are used to ensure consistency and accessibility.- Conditional rendering is used appropriately to handle optional data, such as the attachment file.
- The
Controller
component is utilized correctly to manage the approval checkbox state and validation.- Error handling and user feedback are implemented using
InputError
andAlertBanner
components, providing a good user experience.Overall, the JSX structure and rendering logic are solid and follow best practices.
...lication/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx
Outdated
Show resolved
Hide resolved
...emplates/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
Outside diff range and nitpick comments (4)
libs/feature-flags/src/lib/features.ts (1)
Line range hint
1-42
: Consider improving enum organization and performance.While the code is functional, here are some suggestions for improvement:
Organization: Consider grouping related feature flags and adding more comments for clarity. This would improve readability and maintainability as the enum grows.
Performance: If this enum is not used across module boundaries, consider using a
const enum
for better performance. This would cause the enum to be inlined at compile-time.Example of grouping and additional comments:
export const enum Features { // Testing testing = 'do-not-remove-for-testing-only', // User Profile and Authentication userProfileClaims = 'shouldAuthApiReturnUserProfileClaims', shouldAuthIdsApiUseNationalRegistryV3 = 'shouldAuthIdsApiUseNationalRegistryV3', // Application Visibility exampleApplication = 'isExampleApplicationEnabled', accidentNotification = 'isAccidentNotificationEnabled', // ... other application visibility flags ... // Financial Statements financialStatementInao = 'financialStatementInao', FinancialStatementCemetery = 'isFinancialStatementCemeteryEnabled', FinancialStatementIndividualElectionEnabled = 'isFinancialStatementIndividualElectionEnabled', FinancialStatementPoliticalPartyEnabled = 'isFinancialStatementPoliticalPartyEnabled', // ... other grouped flags ... }libs/application/templates/financial-statements-inao/src/lib/utils/dataSchema.ts (1)
55-55
: LGTM: Simplified phone number validationThe phone number validation logic has been improved by removing the environment-specific check and simplifying the validation process. This change ensures consistent validation across all environments and makes the code more straightforward.
Consider adding a null check to handle cases where the input might be null or undefined:
-return phoneNumber?.isValid() +return phoneNumber?.isValid() ?? falseThis change ensures that the function always returns a boolean value, even if
phoneNumber
is null or undefined.libs/application/templates/inao/financial-statement-political-party/src/lib/dataSchema.ts (2)
103-103
: Clarify the necessity of theelection
field indataSchema
The comment
// Needed??
suggests uncertainty about includingelection
in thedataSchema
. To maintain code clarity and avoid confusion, please confirm whetherelection
is required and remove the comment or the field accordingly.Do you need assistance in determining the necessity of the
election
field? I can help analyze its usage and impact in the application, or open a GitHub issue to track this task.
113-113
: Rename 'file' to 'files' in 'attachments' schema for clarityIn the
attachments
schema, the field is namedfile
but contains an array of files. For clarity and consistency, consider renaming the field tofiles
.Apply the following change:
attachments: z.object({ - file: z.array(FileSchema).nonempty(), + files: z.array(FileSchema).nonempty(), }),And update any references accordingly.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (8)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts (1 hunks)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts (1 hunks)
- libs/application/templates/financial-statements-inao/src/lib/utils/dataSchema.ts (3 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.tsx (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/lib/dataSchema.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts (1 hunks)
- libs/feature-flags/src/lib/features.ts (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-cemetery/financial-statement-cemetery.service.ts
- libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx
- libs/application/templates/inao/financial-statement-political-party/src/fields/PartyOverview/PartyOverview.tsx
- libs/application/templates/inao/financial-statement-political-party/src/lib/financialStatementPoliticalPartyTemplate.ts
Additional context used
Path-based instructions (4)
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.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/financial-statements-inao/src/lib/utils/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/templates/inao/financial-statement-political-party/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/feature-flags/src/lib/features.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."
Biome
libs/application/templates/inao/financial-statement-political-party/src/lib/dataSchema.ts
[error] 39-39: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Additional comments not posted (8)
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts (4)
1-20
: LGTM: Imports are appropriate and well-organized.The imports cover all necessary dependencies for the service, including AWS SDK, logging, application types, and custom clients. The use of specific imports from '@island.is' namespaces indicates good modularization practices.
22-30
: LGTM: Well-defined interfaces for improved type safety.The
AttachmentData
andDataResponse
interfaces are concise and clearly define the structure of the data they represent. Exporting these interfaces allows for their reuse, promoting consistency across the application.
48-56
: LGTM: Constructor is well-implemented with proper dependency injection.The constructor correctly uses dependency injection for the logger and client service. It properly calls the super constructor with the specific application type and initializes the S3 instance.
94-101
: LGTM: getUserType method is well-implemented.The method correctly determines the user type based on the national ID. It uses the kennitala library to distinguish between individuals and organizations, and calls the appropriate client service method for each case.
libs/feature-flags/src/lib/features.ts (2)
Line range hint
1-42
: Compliance with coding guidelines confirmed.The code in this file adheres to the coding guidelines for the
libs
directory:
- The
Features
enum is exported, ensuring reusability across different NextJS apps.- TypeScript is used effectively to define the enum structure.
- The use of an enum supports effective tree-shaking and bundling practices.
42-42
: LGTM: New feature flag added correctly.The new feature flag
FinancialStatementPoliticalPartyEnabled
has been added correctly and follows the existing naming conventions. This addition aligns with the PR objective of creating a new application for financial statements for political parties.To ensure consistency, let's verify if this feature flag is used elsewhere in the codebase:
libs/application/templates/financial-statements-inao/src/lib/utils/dataSchema.ts (2)
4-4
: LGTM: Optimized import for better performanceThe change to import
parsePhoneNumberFromString
from 'libphonenumber-js/min' is a good optimization. It helps reduce the bundle size by using a minimized version of the library, which can lead to improved application performance.
344-344
: LGTM: Stricter type forapproveExternalData
The change from
z.boolean().refine((v) => v)
toz.literal(true)
for theapproveExternalData
field is a good improvement. It makes the schema more explicit about the required value and simplifies the schema definition.Please verify that this change doesn't break any existing code that interacts with this schema. Run the following script to check for any usage of
approveExternalData
that might be affected:If any occurrences are found where
approveExternalData
is not explicitly set totrue
, they may need to be updated to comply with this stricter type definition.
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
libs/application/templates/inao/financial-statement-political-party/src/lib/dataSchema.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts (1 hunks)
- libs/application/templates/inao/financial-statement-political-party/src/lib/dataSchema.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- libs/application/templates/inao/financial-statement-political-party/src/lib/dataSchema.ts
Additional context used
Path-based instructions (1)
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.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."
Additional comments not posted (5)
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts (5)
1-31
: LGTM: Imports and interfaces are well-definedThe imports cover all necessary dependencies and types for the service. The
AttachmentData
andDataResponse
interfaces are clearly defined and serve specific purposes within the service.
51-60
: LGTM: Service class initializationThe service class is properly initialized with dependency injection and extends the BaseTemplateApiService. The S3 client is correctly instantiated in the constructor.
99-106
: LGTM: getUserType method implementationThe getUserType method correctly differentiates between individual and organizational national IDs using the kennitala library. The implementation looks good.
151-155
: LGTM: prepareValues methodThe prepareValues method correctly uses the mapValuesToPartyTypes function to prepare the values. The implementation looks good.
164-172
: LGTM: validateUserType methodThe validateUserType method correctly checks the user type against the PARTY_USER_TYPE constant. The implementation looks good.
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Outdated
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Show resolved
Hide resolved
There was a problem hiding this 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
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts (1 hunks)
Additional context used
Path-based instructions (1)
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.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."
Additional comments not posted (7)
libs/application/template-api-modules/src/lib/modules/templates/financial-statement-political-party/financial-statement-political-party.service.ts (7)
1-31
: Import statements and interface definitions look goodThe import statements are appropriate for the service's functionality, and the interfaces are well-defined, providing good type safety for the application.
51-60
: Class definition and constructor look goodThe class structure, dependency injection, and S3 initialization are implemented correctly. The use of the @Injectable() decorator and extending BaseTemplateApiService are appropriate for this service.
62-97
: getAttachment method implementation looks goodThe method effectively retrieves attachments from S3 with proper error handling and logging. The improvements made, such as throwing meaningful errors and adding null checks, enhance the robustness of the code.
99-106
: getUserType method implementation is correctThe method effectively determines the user type based on the national ID, using the kennitala library for validation. The logic is straightforward and appropriate for the task.
151-155
: prepareValues method looks goodThe method effectively prepares the financial statement values using the mapValuesToPartyTypes function. It's concise and follows the single responsibility principle.
157-166
: getOperatingYear method implementation is correctThe method effectively retrieves the operating year from the application answers. The added type check ensures that the method always returns a string or throws a meaningful error, improving the robustness of the code.
168-176
: validateUserType method implementation looks goodThe method effectively validates the user type against the PARTY_USER_TYPE constant. It correctly throws an error if the user type is invalid, ensuring that only authorized users can submit applications.
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Show resolved
Hide resolved
...templates/financial-statement-political-party/financial-statement-political-party.service.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor things
...application/templates/inao/financial-statement-cemetery/src/fields/DelegationCheck/index.tsx
Outdated
Show resolved
Hide resolved
...lication/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (1)
libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx (1)
138-138
: Remove unnecessary type assertionThe type assertion
'applicationApprove' as string
is unnecessary because'applicationApprove'
is already of type string. Removing the type assertion simplifies the code.Apply this diff:
- setValue('applicationApprove' as string, e.target.checked) + setValue('applicationApprove', e.target.checked)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.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."
🔇 Additional comments (1)
libs/application/templates/inao/financial-statement-political-party/src/fields/Overview/Overview.tsx (1)
31-170
: Code adheres to the project's coding guidelinesThe
Overview
component effectively utilizes TypeScript for defining props and exporting types. The component and its constituent hooks are reusable across different NextJS applications. Additionally, the import statements suggest that tree-shaking and bundling practices are followed appropriately.
What
Make
financial-statement-political-party
into it's own applicationWhy
Last step in splitting
financial-statements-inao
into three seperate applications, grouped together in theinao
folderChecklist:
Summary by CodeRabbit
New Features
Documentation
Bug Fixes