Skip to content

Commit

Permalink
Getting rid of the annoying typescript error in the countryrisk function
Browse files Browse the repository at this point in the history
  • Loading branch information
erikao1998 committed Jan 4, 2024
1 parent 3d6ac69 commit a9e6c41
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/client/util/risks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const countryRisk = ({
}) => {
if (!country) return null

const { code, universities, safetyLevel, ...riskValues } = country
const { code, universities, safetyLevel, sanctions, ...riskValues } = country

const safetyLevels = [
['Noudata tavanomaista varovaisuutta', 1],
Expand All @@ -19,7 +19,7 @@ export const countryRisk = ({
['Poistu välittömästi maasta', 3],
]

const sanctionsRisk = country.sanctions ? 2 : 1
const sanctionsRisk = sanctions ? 2 : 1
const sanctionsMultiplier =
sanctionsRisk === 2 && resultData['11'].research ? 1.5 : 1

Expand All @@ -28,7 +28,7 @@ export const countryRisk = ({

const filteredRiskValues = Object.values(riskValues)
.concat(safetyLevelRisk as number, sanctionsRisk * sanctionsMultiplier)
.filter((value) => value != null && typeof value === 'number')
.filter((value) => value != null)

const totalCountryRiskLevel = Math.round(
filteredRiskValues.reduce((a, b) => a + b, 0) / filteredRiskValues.length
Expand Down

0 comments on commit a9e6c41

Please sign in to comment.