Skip to content

Commit

Permalink
Add GDPR risk to the risk table
Browse files Browse the repository at this point in the history
  • Loading branch information
erikao1998 committed Jan 7, 2024
1 parent 621e8fd commit b54a13c
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 6 deletions.
43 changes: 39 additions & 4 deletions src/client/components/ResultPage/CountryResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { Locales, Result } from '@backend/types'

import { CountryData, FormValues } from '../../types'
import RiskElement from './RiskElement'
import {
eeaCountries,
adequateProtectionCountries,
} from '../../util/gdprCountries'

const CountryResults = ({
country,
Expand All @@ -22,6 +26,32 @@ const CountryResults = ({

const { language } = i18n

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

const gdprRisk = () => {
if (resultData['17'] === 'noTransferPersonalData') return 1
if (
resultData['17'] === 'transferPersonalData' &&
eeaCountries.includes(country.code)
)
return 1
if (
resultData['17'] === 'transferPersonalData' &&
!eeaCountries.includes(country.code) &&
adequateProtectionCountries.includes(country.code)
)
return 2
if (
resultData['17'] === 'transferPersonalData' &&
!eeaCountries.includes(country.code) &&
!adequateProtectionCountries.includes(country.code)
)
return 3
return null
}

const corruptionText = results.find(
(r) => r.optionLabel === `corruptionLevel${country.corruption}`
)?.isSelected[language as keyof Locales]
Expand All @@ -37,10 +67,9 @@ const CountryResults = ({
const humanDevelopmentText = results.find(
(r) => r.optionLabel === `developmentLevel${country.hci}`
)?.isSelected[language as keyof Locales]

const sanctionsRisk = country.sanctions ? 2 : 1
const sanctionsMultiplier =
sanctionsRisk === 2 && resultData['11'].research ? 1.5 : 1
const gdprText = results.find(
(r) => r.optionLabel === `gdprRiskLevel${gdprRisk()}`
)?.isSelected[language as keyof Locales]

return (
<>
Expand Down Expand Up @@ -80,6 +109,12 @@ const CountryResults = ({
resultText={t('results:academicFreedom')}
style={{ paddingLeft: '30px' }}
/>
<RiskElement
infoText={gdprText}
risk={gdprRisk()}
resultText="GDPR"
style={{ paddingLeft: '30px' }}
/>
</>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/ResultPage/RiskElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { resultStyles, riskColors } = styles
export interface RiskElementProps {
infoText?: string | null
resultText: string
risk: number
risk: number | null
style?: any
}

Expand Down
47 changes: 47 additions & 0 deletions src/client/util/gdprCountries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export const eeaCountries = [
'AT',
'BE',
'BG',
'HR',
'CY',
'CZ',
'DK',
'EE',
'FI',
'FR',
'DE',
'GR',
'HU',
'IS',
'IE',
'IT',
'LV',
'LI',
'LT',
'LU',
'MT',
'NL',
'NO',
'PL',
'PT',
'RO',
'SK',
'SI',
'ES',
'SE',
]

export const adequateProtectionCountries = [
'AD',
'AR',
'CA',
'FO',
'IM',
'IL',
'NZ',
'KR',
'CH',
'GB',
'UY',
'US',
]
29 changes: 28 additions & 1 deletion src/client/util/risks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CountryData, FormValues } from '@frontend/types'
import { eeaCountries, adequateProtectionCountries } from './gdprCountries'

export const countryRisk = ({
country,
Expand All @@ -23,11 +24,37 @@ export const countryRisk = ({
const sanctionsMultiplier =
sanctionsRisk === 2 && resultData['11'].research ? 1.5 : 1

const gdprRisk = () => {
if (resultData['17'] === 'noTransferPersonalData') return 1
if (
resultData['17'] === 'transferPersonalData' &&
eeaCountries.includes(country.code)
)
return 1
if (
resultData['17'] === 'transferPersonalData' &&
!eeaCountries.includes(country.code) &&
adequateProtectionCountries.includes(country.code)
)
return 2
if (
resultData['17'] === 'transferPersonalData' &&
!eeaCountries.includes(country.code) &&
!adequateProtectionCountries.includes(country.code)
)
return 3
return null
}

const safetyLevelRisk =
safetyLevels.find((level) => level[0] === safetyLevel)?.[1] || null

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

const totalCountryRiskLevel = Math.round(
Expand Down
51 changes: 51 additions & 0 deletions src/server/data/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,57 @@ const getResultData = (): Result[] => [
},
},
},
{
id: 19,
surveyId: 1,
optionLabel: 'gdprRiskLevel1',
isSelected: {
fi: '*Tietosuojamielessä yhteistyöhön ei kohdistu erityisiä vaatimuksia.*',
sv: '*GDPR is not applicable*',
en: '*GDPR is not applicable*',
},
data: {
allDimensions: {
fi: '',
sv: '',
en: '',
},
},
},
{
id: 20,
surveyId: 1,
optionLabel: 'gdprRiskLevel2',
isSelected: {
fi: '*Henkilötietojen luovuttamista koskee EU:n GDPR-sääntely. Yhteistyökumppanisi sijaintimaa kuuluu helpotetun menettelyn mukaisiin maihin, mutta tutustu tarkempiin ohjeisiin Flammassa.*',
sv: '*Handing over personal data requires GDPR compliance. Your partner is located in a country with limited compliance requirements, but please review instructions at Flamma.*',
en: '*Handing over personal data requires GDPR compliance. Your partner is located in a country with limited compliance requirements, but please review instructions at Flamma.*',
},
data: {
allDimensions: {
fi: '',
sv: '',
en: '',
},
},
},
{
id: 21,
surveyId: 1,
optionLabel: 'gdprRiskLevel3',
isSelected: {
fi: '*Henkilötietojen luovuttamista koskee EU:n GDPR-sääntely. Tutustu tarkempiin ohjeisiin Flammassa.*',
sv: '*Handing over personal data requires GDPR compliance. Please review instructions at Flamma.*',
en: '*Handing over personal data requires GDPR compliance. Please review instructions at Flamma.*',
},
data: {
allDimensions: {
fi: '',
sv: '',
en: '',
},
},
},
]

export default getResultData

0 comments on commit b54a13c

Please sign in to comment.