Skip to content

Commit

Permalink
fix(j-s): small fixes when feature flag is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
thorhildurt committed Feb 11, 2025
1 parent e082b9c commit 7b6bb20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

import { getRelevantSubstances } from '../IndictmentCount'
import { indictmentCount as strings } from '../IndictmentCount.strings'
import { substanceEnum } from '../Substances/SubstancesEnum.strings'
import { indictmentCountSubstanceEnum as substanceStrings } from '../IndictmentCountSubstanceEnum.strings'

export const getDeprecatedIncidentDescriptionReason = (
deprecatedOffenses: IndictmentCountOffense[],
Expand Down Expand Up @@ -77,7 +77,7 @@ export const getDeprecatedIncidentDescriptionReason = (
} else {
acc += ', '
}
acc += formatMessage(substanceEnum[substance[0] as Substance], {
acc += formatMessage(substanceStrings[substance[0] as Substance], {
amount: substance[1],
})
if (index === relevantSubstances.length - 1) {
Expand Down
10 changes: 9 additions & 1 deletion apps/judicial-system/web/src/utils/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ export const isProcessingStepValidIndictments = (
)
}

export const isIndictmentStepValid = (workingCase: Case): boolean => {
export const isIndictmentStepValid = (
workingCase: Case,
isOffenseEndpointEnabled: boolean,
): boolean => {
const hasValidDemands = Boolean(
workingCase.demands &&
(!workingCase.hasCivilClaims || workingCase.civilDemands),
Expand Down Expand Up @@ -318,6 +321,10 @@ export const isIndictmentStepValid = (workingCase: Case): boolean => {
}

const hasOffenses = (indictmentCount: IndictmentCount) => {
if (!isOffenseEndpointEnabled) {
return true
}

if (indictmentCount.offenses) {
return Boolean(
indictmentCount.offenses && indictmentCount.offenses?.length > 0,
Expand All @@ -328,6 +335,7 @@ export const isIndictmentStepValid = (workingCase: Case): boolean => {
indictmentCount.deprecatedOffenses?.length > 0,
)
}

const isValidTrafficViolation = (indictmentCount: IndictmentCount) =>
Boolean(indictmentCount.policeCaseNumber) &&
hasOffenses(indictmentCount) &&
Expand Down

0 comments on commit 7b6bb20

Please sign in to comment.