@lysaab/lysa-pep 0.13.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,14 +2,14 @@ import React, {
2
2
  FunctionComponent,
3
3
  useRef,
4
4
  useCallback,
5
- useContext
5
+ useContext,
6
6
  } from "react";
7
7
  import {
8
8
  Form,
9
9
  RadioGroup,
10
10
  RequiredValidator,
11
11
  PrimaryButton,
12
- LysaFormRef
12
+ LysaFormRef,
13
13
  } from "@lysaab/ui-2";
14
14
  import { PepType, PepContext, EntityType } from "./PepContext";
15
15
  import { LABELS } from "../model/PepTexts";
@@ -26,17 +26,17 @@ export const PepIsPepPage: FunctionComponent<Props> = ({ next }) => {
26
26
  const IsPepAlternatives = [
27
27
  {
28
28
  text: labels[entityType].GENERIC.IS_PEP[PepType.NOT_PEP],
29
- value: PepType.NOT_PEP
29
+ value: PepType.NOT_PEP,
30
30
  },
31
31
  { text: labels[entityType].GENERIC.IS_PEP[PepType.ME], value: PepType.ME },
32
32
  {
33
33
  text: labels[entityType].GENERIC.IS_PEP[PepType.RELATIVE],
34
- value: PepType.RELATIVE
34
+ value: PepType.RELATIVE,
35
35
  },
36
36
  {
37
37
  text: labels[entityType].GENERIC.IS_PEP[PepType.COLLEAGUE],
38
- value: PepType.COLLEAGUE
39
- }
38
+ value: PepType.COLLEAGUE,
39
+ },
40
40
  ];
41
41
 
42
42
  const nextPage = useCallback(() => {
@@ -61,7 +61,7 @@ export const PepIsPepPage: FunctionComponent<Props> = ({ next }) => {
61
61
  militaryRank: undefined,
62
62
  nameOfPEP: undefined,
63
63
  relationToPEP: undefined,
64
- role: undefined
64
+ role: undefined,
65
65
  });
66
66
  }, [pepContext]);
67
67
 
@@ -69,15 +69,13 @@ export const PepIsPepPage: FunctionComponent<Props> = ({ next }) => {
69
69
  <Form onSubmit={() => nextPage()} lysaFormRef={formRef}>
70
70
  <RadioGroup
71
71
  alternatives={IsPepAlternatives}
72
- onChange={event => {
73
- pepContext.setState({
74
- type: event.value ? (event.value.value as PepType) : undefined
75
- });
72
+ onChange={alternative => {
73
+ pepContext.setState({ type: alternative.value });
76
74
  resetValues();
77
75
  }}
78
- value={
79
- IsPepAlternatives.find(alt => alt.value === pepContext.state.type)
80
- }
76
+ value={IsPepAlternatives.find(
77
+ alt => alt.value === pepContext.state.type
78
+ )}
81
79
  header={labels[entityType].GENERIC.IS_PEP_HEADER}
82
80
  validators={[RequiredValidator("Du måste välja ett alternativ")]}
83
81
  />
@@ -2,14 +2,14 @@ import React, {
2
2
  useContext,
3
3
  useRef,
4
4
  useCallback,
5
- FunctionComponent
5
+ FunctionComponent,
6
6
  } from "react";
7
7
  import {
8
8
  PepContext,
9
9
  PepType,
10
10
  BusinessRelation,
11
11
  Relation,
12
- EntityType
12
+ EntityType,
13
13
  } from "./PepContext";
14
14
  import {
15
15
  LysaFormRef,
@@ -19,7 +19,7 @@ import {
19
19
  RequiredValidator,
20
20
  TextInput,
21
21
  Datepicker,
22
- PrimaryButton
22
+ PrimaryButton,
23
23
  } from "@lysaab/ui-2";
24
24
  import { LABELS } from "../model/PepTexts";
25
25
  import { DateTime } from "luxon";
@@ -37,65 +37,65 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
37
37
  const type = pepContext.state.type;
38
38
  const labels = LABELS(pepContext.state.ownerName);
39
39
 
40
- const businessRelationAlternatives: Alternative[] = [
40
+ const businessRelationAlternatives: Alternative<BusinessRelation>[] = [
41
41
  {
42
42
  text:
43
43
  labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
44
44
  BusinessRelation.CO_OWNERSHIP
45
45
  ],
46
- value: BusinessRelation.CO_OWNERSHIP
46
+ value: BusinessRelation.CO_OWNERSHIP,
47
47
  },
48
48
  {
49
49
  text:
50
50
  labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
51
51
  BusinessRelation.CLOSE_CONNECTION
52
52
  ],
53
- value: BusinessRelation.CLOSE_CONNECTION
53
+ value: BusinessRelation.CLOSE_CONNECTION,
54
54
  },
55
55
  {
56
56
  text:
57
57
  labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
58
58
  BusinessRelation.COMPANY_FOR_PEP
59
59
  ],
60
- value: BusinessRelation.COMPANY_FOR_PEP
61
- }
60
+ value: BusinessRelation.COMPANY_FOR_PEP,
61
+ },
62
62
  ];
63
63
 
64
- const relationAlternatives: Alternative[] = [
64
+ const relationAlternatives: Alternative<Relation>[] = [
65
65
  {
66
66
  text:
67
67
  labels[entityType][PepType.RELATIVE].RELATION[Relation.MARRIED_PARTNER],
68
- value: Relation.MARRIED_PARTNER
68
+ value: Relation.MARRIED_PARTNER,
69
69
  },
70
70
  {
71
71
  text:
72
72
  labels[entityType][PepType.RELATIVE].RELATION[
73
73
  Relation.COLIVING_PARTNER
74
74
  ],
75
- value: Relation.COLIVING_PARTNER
75
+ value: Relation.COLIVING_PARTNER,
76
76
  },
77
77
  {
78
78
  text: labels[entityType][PepType.RELATIVE].RELATION[Relation.CHILD],
79
- value: Relation.CHILD
79
+ value: Relation.CHILD,
80
80
  },
81
81
  {
82
82
  text: labels[entityType][PepType.RELATIVE].RELATION[Relation.PARENT],
83
- value: Relation.PARENT
83
+ value: Relation.PARENT,
84
84
  },
85
85
  {
86
86
  text:
87
87
  labels[entityType][PepType.RELATIVE].RELATION[
88
88
  Relation.CHILD_MARRIED_PARTNER
89
89
  ],
90
- value: Relation.CHILD_MARRIED_PARTNER
90
+ value: Relation.CHILD_MARRIED_PARTNER,
91
91
  },
92
92
  {
93
93
  text:
94
94
  labels[entityType][PepType.RELATIVE].RELATION[
95
95
  Relation.CHILD_COLIVING_PARTNER
96
96
  ],
97
- value: Relation.CHILD_COLIVING_PARTNER
98
- }
97
+ value: Relation.CHILD_COLIVING_PARTNER,
98
+ },
99
99
  ];
100
100
 
101
101
  const nextPage = useCallback(() => {
@@ -108,11 +108,9 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
108
108
  {type === PepType.RELATIVE ? (
109
109
  <RadioGroup
110
110
  alternatives={relationAlternatives}
111
- onChange={event => {
111
+ onChange={alternative => {
112
112
  pepContext.setState({
113
- relationToPEP: event.value
114
- ? (event.value.value as Relation)
115
- : undefined
113
+ relationToPEP: alternative.value,
116
114
  });
117
115
  }}
118
116
  value={relationAlternatives.find(
@@ -125,11 +123,9 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
125
123
  {type === PepType.COLLEAGUE ? (
126
124
  <RadioGroup
127
125
  alternatives={businessRelationAlternatives}
128
- onChange={event => {
126
+ onChange={alternative => {
129
127
  pepContext.setState({
130
- businessRelation: event.value
131
- ? (event.value.value as BusinessRelation)
132
- : undefined
128
+ businessRelation: alternative.value,
133
129
  });
134
130
  }}
135
131
  value={businessRelationAlternatives.find(
@@ -148,8 +144,8 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
148
144
  ]
149
145
  }
150
146
  value={pepContext.state.nameOfPEP || ""}
151
- onChange={event => {
152
- pepContext.setState({ nameOfPEP: event.value });
147
+ onChange={value => {
148
+ pepContext.setState({ nameOfPEP: value });
153
149
  }}
154
150
  validators={[RequiredValidator("Du måste ange namn")]}
155
151
  />
@@ -179,8 +175,8 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
179
175
  ]
180
176
  }
181
177
  value={pepContext.state.nameOfPEP || ""}
182
- onChange={event => {
183
- pepContext.setState({ nameOfPEP: event.value });
178
+ onChange={value => {
179
+ pepContext.setState({ nameOfPEP: value });
184
180
  }}
185
181
  validators={[RequiredValidator("Du måste ange namn")]}
186
182
  />
@@ -2,7 +2,7 @@ import React, {
2
2
  FunctionComponent,
3
3
  useRef,
4
4
  useCallback,
5
- useContext
5
+ useContext,
6
6
  } from "react";
7
7
  import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
8
8
  import {
@@ -11,7 +11,7 @@ import {
11
11
  PrimaryButton,
12
12
  RequiredValidator,
13
13
  TextInput,
14
- Select
14
+ Select,
15
15
  } from "@lysaab/ui-2";
16
16
  import {
17
17
  PepContext,
@@ -21,76 +21,84 @@ import {
21
21
  PepType,
22
22
  } from "./PepContext";
23
23
  import { CountrySelect } from "../components/CountrySelect";
24
- import { getGovernmentCompanyNameLabel, getGovernmentCompanyRoleLabel, getHighRankingPositionIntCorpNameLabel, getHighRankingPositionIntCorpRoleLabel, getMilitaryRankLabel, getRoleLabel, getAmbassadorLabel } from "../model/PepTexts";
24
+ import {
25
+ getGovernmentCompanyNameLabel,
26
+ getGovernmentCompanyRoleLabel,
27
+ getHighRankingPositionIntCorpNameLabel,
28
+ getHighRankingPositionIntCorpRoleLabel,
29
+ getMilitaryRankLabel,
30
+ getRoleLabel,
31
+ getAmbassadorLabel,
32
+ } from "../model/PepTexts";
25
33
 
26
34
  interface Props {
27
35
  next: () => void;
28
36
  }
29
37
 
30
- export const roleAlternatives: Alternative[] = [
38
+ export const roleAlternatives: Alternative<Role>[] = [
31
39
  { text: "Stats eller regeringschef", value: Role.HEAD_OF_GOVERNMENT },
32
40
  { text: "Minister eller Vice/Biträdande minister", value: Role.MINISTER },
33
41
  { text: "Ledamot i parlament eller riksdag", value: Role.PARLIMENT_MEMBER },
34
42
  {
35
43
  text: "Ledamot i centralbanks styrande organ",
36
- value: Role.CENTRAL_BANK_MEMBER
44
+ value: Role.CENTRAL_BANK_MEMBER,
37
45
  },
38
46
  {
39
47
  text: "Ledamot för styrelsen i politiskt parti representerade i riksdagen",
40
- value: Role.BOARD_MEMBER_POLITICAL_PARTY
48
+ value: Role.BOARD_MEMBER_POLITICAL_PARTY,
41
49
  },
42
50
  { text: "Domare i högsta domstolen", value: Role.JUDGE_SUPREME_COURT },
43
51
  {
44
52
  text:
45
53
  "Domare i konstitutionell domstol eller annat rättsligt organ på hög nivå vars beslut endast undantagsvis kan överklagas",
46
- value: Role.JUDGE_OTHER_HIGH_COURT
54
+ value: Role.JUDGE_OTHER_HIGH_COURT,
47
55
  },
48
56
  {
49
57
  text: "Högre tjänsteman vid revisionsmyndighet",
50
- value: Role.REVISION_INSTITUTE
58
+ value: Role.REVISION_INSTITUTE,
51
59
  },
52
60
  { text: "Ambassadör eller bestickningschef", value: Role.AMBASSADOR },
53
61
  { text: "Högre officer i försvarsmakt", value: Role.MILITARY_OFFICER },
54
62
  {
55
63
  text:
56
64
  "Person som ingår i statsägt företags förvaltnings-, lednings eller kontrollorgan",
57
- value: Role.GOVERNMENT_COMPANY
65
+ value: Role.GOVERNMENT_COMPANY,
58
66
  },
59
67
  {
60
68
  text: "EU-parlamentariker",
61
- value: Role.EU_HIGH_RANKING_POSITION
69
+ value: Role.EU_HIGH_RANKING_POSITION,
62
70
  },
63
71
  {
64
72
  text: "Befattning på hög nivå i en internationell organisation",
65
- value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP
66
- }
73
+ value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP,
74
+ },
67
75
  ];
68
76
 
69
- export const militaryAlternatives: Alternative[] = [
77
+ export const militaryAlternatives: Alternative<MilitaryRank>[] = [
70
78
  {
71
79
  text: "General",
72
- value: MilitaryRank.GENERAL
80
+ value: MilitaryRank.GENERAL,
73
81
  },
74
82
  {
75
83
  text: "Generallöjtnant",
76
- value: MilitaryRank.LIEUTENANT_GENERAL
84
+ value: MilitaryRank.LIEUTENANT_GENERAL,
77
85
  },
78
86
  {
79
87
  text: "Generalmajor",
80
- value: MilitaryRank.MAJOR_GENERAL
88
+ value: MilitaryRank.MAJOR_GENERAL,
81
89
  },
82
90
  {
83
91
  text: "Amiral",
84
- value: MilitaryRank.ADMIRAL
92
+ value: MilitaryRank.ADMIRAL,
85
93
  },
86
94
  {
87
95
  text: "Viceamiral",
88
- value: MilitaryRank.VICE_ADMIRAL
96
+ value: MilitaryRank.VICE_ADMIRAL,
89
97
  },
90
98
  {
91
99
  text: "Konteramiral",
92
- value: MilitaryRank.REAR_ADMIRAL
93
- }
100
+ value: MilitaryRank.REAR_ADMIRAL,
101
+ },
94
102
  ];
95
103
 
96
104
  export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
@@ -112,7 +120,7 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
112
120
  governmentCompanyRole: undefined,
113
121
  internationalOrganisation: undefined,
114
122
  internationalOrganisationRole: undefined,
115
- militaryRank: undefined
123
+ militaryRank: undefined,
116
124
  });
117
125
  }, [pepContext]);
118
126
 
@@ -155,7 +163,7 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
155
163
  pepContext.setState({
156
164
  ambassadorCountry: event.value
157
165
  ? event.value.toString()
158
- : undefined
166
+ : undefined,
159
167
  })
160
168
  }
161
169
  value={pepContext.state.ambassadorCountry}
@@ -175,8 +183,8 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
175
183
  pepContext.state.ownerName
176
184
  )}
177
185
  value={pepContext.state.governmentCompany || ""}
178
- onChange={event => {
179
- pepContext.setState({ governmentCompany: event.value });
186
+ onChange={value => {
187
+ pepContext.setState({ governmentCompany: value });
180
188
  }}
181
189
  validators={[RequiredValidator("Du måste ange ett namn")]}
182
190
  />
@@ -189,9 +197,9 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
189
197
  pepContext.state.ownerName
190
198
  )}
191
199
  value={pepContext.state.governmentCompanyRole || ""}
192
- onChange={event => {
200
+ onChange={value => {
193
201
  pepContext.setState({
194
- governmentCompanyRole: event.value
202
+ governmentCompanyRole: value,
195
203
  });
196
204
  }}
197
205
  validators={[RequiredValidator("Du måste ange roll")]}
@@ -212,8 +220,8 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
212
220
  pepContext.state.ownerName
213
221
  )}
214
222
  value={pepContext.state.internationalOrganisation || ""}
215
- onChange={event => {
216
- pepContext.setState({ internationalOrganisation: event.value });
223
+ onChange={value => {
224
+ pepContext.setState({ internationalOrganisation: value });
217
225
  }}
218
226
  validators={[RequiredValidator("Du måste ange ett namn")]}
219
227
  />
@@ -226,9 +234,9 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
226
234
  pepContext.state.ownerName
227
235
  )}
228
236
  value={pepContext.state.internationalOrganisationRole || ""}
229
- onChange={event => {
237
+ onChange={value => {
230
238
  pepContext.setState({
231
- internationalOrganisationRole: event.value
239
+ internationalOrganisationRole: value,
232
240
  });
233
241
  }}
234
242
  validators={[RequiredValidator("Du måste ange roll")]}
@@ -1,143 +1,132 @@
1
- import React, {
2
- FunctionComponent,
3
- useRef,
4
- useCallback,
5
- useContext
6
- } from "react";
7
- import {
8
- Form,
9
- RadioGroup,
10
- RequiredValidator,
11
- PrimaryButton,
12
- LysaFormRef,
13
- Datepicker
14
- } from "@lysaab/ui-2";
15
- import {
16
- Alternative,
17
- InputEvent
18
- } from "@lysaab/ui-2/components/input/InputAPI";
19
- import { PepContext, PepStatus } from "./PepContext";
20
- import { CountrySelect } from "../components/CountrySelect";
21
-
22
- const stateAlternatives: Alternative[] = [
23
- {
24
- text: "Pågående",
25
- value: PepStatus.ONGOING
26
- },
27
- {
28
- text: "Avslutad",
29
- value: PepStatus.ENDED
30
- }
31
- ];
32
-
33
- const isSwedenAlternatives: Alternative[] = [
34
- { text: "Sverige", value: "sweden" },
35
- { text: "Annat", value: "other" }
36
- ];
37
-
38
- interface Props {
39
- next: () => void;
40
- }
41
-
42
- export const PepStatusPage: FunctionComponent<Props> = ({ next }) => {
43
- const pepContext = useContext(PepContext);
44
- const formRef = useRef<LysaFormRef>();
45
-
46
- const nextPage = useCallback(() => {
47
- if (formRef.current && formRef.current.isValid) {
48
- next();
49
- }
50
- }, [formRef, next]);
51
-
52
- const updateIsSweden = useCallback(
53
- (event: InputEvent<Alternative>) => {
54
- pepContext.setState({
55
- isSweden:
56
- event.value && event.value.value
57
- ? event.value.value.toString()
58
- : undefined
59
- });
60
- if (event.value && event.value.value === "other") {
61
- pepContext.setState({ country: undefined });
62
- }
63
- },
64
- [pepContext]
65
- );
66
-
67
- const updateIsOngoing = useCallback(
68
- (event: InputEvent<Alternative>) => {
69
- pepContext.setState({
70
- isOngoing:
71
- event.value && event.value.value
72
- ? (event.value.value as PepStatus)
73
- : undefined
74
- });
75
- if (event.value && event.value.value === PepStatus.ONGOING) {
76
- pepContext.setState({ ended: undefined });
77
- }
78
- },
79
- [pepContext]
80
- );
81
-
82
- return (
83
- <div>
84
- <Form
85
- lysaFormRef={formRef}
86
- onSubmit={() => {
87
- nextPage();
88
- }}
89
- >
90
- <RadioGroup
91
- alternatives={stateAlternatives}
92
- header="Är befattningen pågående eller avslutad?"
93
- onChange={updateIsOngoing}
94
- value={
95
- stateAlternatives.find(
96
- alt => alt.value === pepContext.state.isOngoing
97
- )
98
- }
99
- validators={[RequiredValidator("Du måste välja ett alternativ")]}
100
- />
101
-
102
- {pepContext.state.isOngoing &&
103
- pepContext.state.isOngoing === PepStatus.ENDED ? (
104
- <Datepicker
105
- label="När avslutades uppdraget?"
106
- selected={pepContext.state.ended}
107
- onChange={event =>
108
- pepContext.setState({ ended: event || undefined })
109
- }
110
- validators={[RequiredValidator("Du måste ange fördelsedag")]}
111
- showMonthYearPicker
112
- dateFormat="yyyy-MM"
113
- maxDate={new Date()}
114
- />
115
- ) : null}
116
-
117
- <RadioGroup
118
- alternatives={isSwedenAlternatives}
119
- header="I vilket land är befattningen"
120
- onChange={updateIsSweden}
121
- value={
122
- isSwedenAlternatives.find(
123
- alt => alt.value === pepContext.state.isSweden
124
- )
125
- }
126
- validators={[RequiredValidator("Du måste välja ett alternativ")]}
127
- />
128
-
129
- {pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (
130
- <CountrySelect
131
- label="Välj i vilket land befattningen är"
132
- onChange={event => pepContext.setState({ country: event.value ? event.value.toString() : undefined })}
133
- validators={[RequiredValidator("Du måste välja land")]}
134
- value={pepContext.state.country}
135
- removeSweden={true}
136
- />
137
- ) : null}
138
-
139
- <PrimaryButton type="submit">Nästa</PrimaryButton>
140
- </Form>
141
- </div>
142
- );
143
- };
1
+ import React, {
2
+ FunctionComponent,
3
+ useRef,
4
+ useCallback,
5
+ useContext,
6
+ } from "react";
7
+ import {
8
+ Form,
9
+ RadioGroup,
10
+ RequiredValidator,
11
+ PrimaryButton,
12
+ LysaFormRef,
13
+ Datepicker,
14
+ } from "@lysaab/ui-2";
15
+ import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
16
+ import { PepContext, PepStatus } from "./PepContext";
17
+ import { CountrySelect } from "../components/CountrySelect";
18
+
19
+ const stateAlternatives: Alternative<PepStatus>[] = [
20
+ {
21
+ text: "Pågående",
22
+ value: PepStatus.ONGOING,
23
+ },
24
+ {
25
+ text: "Avslutad",
26
+ value: PepStatus.ENDED,
27
+ },
28
+ ];
29
+
30
+ const isSwedenAlternatives: Alternative<string>[] = [
31
+ { text: "Sverige", value: "sweden" },
32
+ { text: "Annat", value: "other" },
33
+ ];
34
+
35
+ interface Props {
36
+ next: () => void;
37
+ }
38
+
39
+ export const PepStatusPage: FunctionComponent<Props> = ({ next }) => {
40
+ const pepContext = useContext(PepContext);
41
+ const formRef = useRef<LysaFormRef>();
42
+
43
+ const nextPage = useCallback(() => {
44
+ if (formRef.current && formRef.current.isValid) {
45
+ next();
46
+ }
47
+ }, [formRef, next]);
48
+
49
+ const updateIsSweden = useCallback(
50
+ (alternative: Alternative<string>) => {
51
+ pepContext.setState({ isSweden: alternative.value });
52
+
53
+ if (alternative.value === "other") {
54
+ pepContext.setState({ country: undefined });
55
+ }
56
+ },
57
+ [pepContext]
58
+ );
59
+
60
+ const updateIsOngoing = useCallback(
61
+ (alternative: Alternative<PepStatus>) => {
62
+ pepContext.setState({ isOngoing: alternative.value });
63
+
64
+ if (alternative.value === PepStatus.ONGOING) {
65
+ pepContext.setState({ ended: undefined });
66
+ }
67
+ },
68
+ [pepContext]
69
+ );
70
+
71
+ return (
72
+ <div>
73
+ <Form
74
+ lysaFormRef={formRef}
75
+ onSubmit={() => {
76
+ nextPage();
77
+ }}
78
+ >
79
+ <RadioGroup
80
+ alternatives={stateAlternatives}
81
+ header="Är befattningen pågående eller avslutad?"
82
+ onChange={updateIsOngoing}
83
+ value={stateAlternatives.find(
84
+ alt => alt.value === pepContext.state.isOngoing
85
+ )}
86
+ validators={[RequiredValidator("Du måste välja ett alternativ")]}
87
+ />
88
+
89
+ {pepContext.state.isOngoing &&
90
+ pepContext.state.isOngoing === PepStatus.ENDED ? (
91
+ <Datepicker
92
+ label="När avslutades uppdraget?"
93
+ selected={pepContext.state.ended}
94
+ onChange={event =>
95
+ pepContext.setState({ ended: event || undefined })
96
+ }
97
+ validators={[RequiredValidator("Du måste ange fördelsedag")]}
98
+ showMonthYearPicker
99
+ dateFormat="yyyy-MM"
100
+ maxDate={new Date()}
101
+ />
102
+ ) : null}
103
+
104
+ <RadioGroup
105
+ alternatives={isSwedenAlternatives}
106
+ header="I vilket land är befattningen"
107
+ onChange={updateIsSweden}
108
+ value={isSwedenAlternatives.find(
109
+ alt => alt.value === pepContext.state.isSweden
110
+ )}
111
+ validators={[RequiredValidator("Du måste välja ett alternativ")]}
112
+ />
113
+
114
+ {pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (
115
+ <CountrySelect
116
+ label="Välj i vilket land befattningen är"
117
+ onChange={event =>
118
+ pepContext.setState({
119
+ country: event.value ? event.value.toString() : undefined,
120
+ })
121
+ }
122
+ validators={[RequiredValidator("Du måste välja land")]}
123
+ value={pepContext.state.country}
124
+ removeSweden={true}
125
+ />
126
+ ) : null}
127
+
128
+ <PrimaryButton type="submit">Nästa</PrimaryButton>
129
+ </Form>
130
+ </div>
131
+ );
132
+ };