Skip to content

Commit

Permalink
Merge branch 'main' into feat/update-income-type
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Sep 13, 2024
2 parents dbb11ca + 8b22584 commit 6946dfb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export const IncomePlanForm: Form = buildForm({
width: 'half',
type: 'number',
currency: true,
readonly: (_, activeField) => {
disabled: (_, activeField) => {
return activeField?.income === RatioType.MONTHLY
},
updateValueObj: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const IncomePlanTemplate: ApplicationTemplate<
featureFlag: Features.IncomePlanEnabled,
translationNamespaces: ApplicationConfigurations.IncomePlan.translation,
dataSchema,
allowMultipleApplicationsInDraft: false,
newApplicationButtonLabel: historyMessages.newIncomePlanButtonLabel,
applicationText: historyMessages.incomePlanPageTitle,
stateMachineConfig: {
Expand Down
6 changes: 6 additions & 0 deletions libs/application/types/src/lib/Fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export type TableRepeaterItem = {
application: Application,
activeField?: Record<string, string>,
) => boolean)
disabled?:
| boolean
| ((
application: Application,
activeField?: Record<string, string>,
) => boolean)
updateValueObj?: {
valueModifier: (
application: Application,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const Item = ({
width = 'full',
condition,
readonly = false,
disabled = false,
updateValueObj,
defaultValue,
...props
Expand Down Expand Up @@ -151,6 +152,13 @@ export const Item = ({
Readonly = readonly
}

let Disabled: boolean | undefined
if (typeof disabled === 'function') {
Disabled = disabled(application, activeValues)
} else {
Disabled = disabled
}

let DefaultValue: any
if (component === 'input') {
DefaultValue = getDefaultValue(item, application, activeValues)
Expand Down Expand Up @@ -197,6 +205,7 @@ export const Item = ({
error={getFieldError(itemId)}
control={control}
readOnly={Readonly}
disabled={Disabled}
backgroundColor={backgroundColor}
onChange={() => {
if (error) {
Expand Down

0 comments on commit 6946dfb

Please sign in to comment.