@lysaab/lysa-pep 0.7.0 → 0.8.0
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.
- package/lib/Exports.d.ts +1 -1
- package/lib/Exports.js +1 -1
- package/lib/model/PepTexts.js +1 -1
- package/lib/pages/PepRolePage.d.ts +3 -0
- package/lib/pages/PepRolePage.js +2 -2
- package/package.json +1 -1
- package/src/Exports.ts +1 -1
- package/src/demo/Done.tsx +2 -2
- package/src/model/PepTexts.ts +1 -1
- package/src/pages/PepRolePage.tsx +2 -2
- package/src/pages/PepStatusPage.tsx +142 -142
package/lib/Exports.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export * from './model/PepModel';
|
|
|
3
3
|
export * from './model/PepTexts';
|
|
4
4
|
export { PepIsPepPage } from './pages/PepIsPepPage';
|
|
5
5
|
export { PepRelationPage } from './pages/PepRelationPage';
|
|
6
|
-
export { PepRolePage } from './pages/PepRolePage';
|
|
6
|
+
export { PepRolePage, militaryAlternatives, roleAlternatives } from './pages/PepRolePage';
|
|
7
7
|
export { PepStatusPage } from './pages/PepStatusPage';
|
package/lib/Exports.js
CHANGED
|
@@ -3,5 +3,5 @@ export * from './model/PepModel';
|
|
|
3
3
|
export * from './model/PepTexts';
|
|
4
4
|
export { PepIsPepPage } from './pages/PepIsPepPage';
|
|
5
5
|
export { PepRelationPage } from './pages/PepRelationPage';
|
|
6
|
-
export { PepRolePage } from './pages/PepRolePage';
|
|
6
|
+
export { PepRolePage, militaryAlternatives, roleAlternatives } from './pages/PepRolePage';
|
|
7
7
|
export { PepStatusPage } from './pages/PepStatusPage';
|
package/lib/model/PepTexts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PepType, EntityType, BusinessRelation, Relation } from "../pages/PepContext";
|
|
2
2
|
export const LABELS = (name) => {
|
|
3
3
|
let possessiveName = name;
|
|
4
|
-
if (possessiveName && possessiveName[possessiveName.length - 1] !== "s") {
|
|
4
|
+
if (possessiveName && possessiveName[possessiveName.length - 1] !== "s" && possessiveName[possessiveName.length - 1] !== "z" && possessiveName[possessiveName.length - 1] !== "x") {
|
|
5
5
|
possessiveName += "s";
|
|
6
6
|
}
|
|
7
7
|
return {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { FunctionComponent } from "react";
|
|
2
|
+
import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
|
|
2
3
|
interface Props {
|
|
3
4
|
next: () => void;
|
|
4
5
|
}
|
|
6
|
+
export declare const roleAlternatives: Alternative[];
|
|
7
|
+
export declare const militaryAlternatives: Alternative[];
|
|
5
8
|
export declare const PepRolePage: FunctionComponent<Props>;
|
|
6
9
|
export {};
|
package/lib/pages/PepRolePage.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Form, PrimaryButton, RequiredValidator, TextInput, Select } from "@lysa
|
|
|
3
3
|
import { PepContext, Role, MilitaryRank, EntityType, PepType, } from "./PepContext";
|
|
4
4
|
import { CountrySelect } from "../components/CountrySelect";
|
|
5
5
|
import { getGovernmentCompanyNameLabel, getGovernmentCompanyRoleLabel, getHighRankingPositionIntCorpNameLabel, getHighRankingPositionIntCorpRoleLabel, getMilitaryRankLabel, getRoleLabel, getAmbassadorLabel } from "../model/PepTexts";
|
|
6
|
-
const roleAlternatives = [
|
|
6
|
+
export const roleAlternatives = [
|
|
7
7
|
{ text: "Stats eller regeringschef", value: Role.HEAD_OF_GOVERNMENT },
|
|
8
8
|
{ text: "Minister eller Vice/Biträdande minister", value: Role.MINISTER },
|
|
9
9
|
{ text: "Ledamot i parlament eller riksdag", value: Role.PARLIMENT_MEMBER },
|
|
@@ -39,7 +39,7 @@ const roleAlternatives = [
|
|
|
39
39
|
value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP
|
|
40
40
|
}
|
|
41
41
|
];
|
|
42
|
-
const militaryAlternatives = [
|
|
42
|
+
export const militaryAlternatives = [
|
|
43
43
|
{
|
|
44
44
|
text: "General",
|
|
45
45
|
value: MilitaryRank.GENERAL
|
package/package.json
CHANGED
package/src/Exports.ts
CHANGED
|
@@ -4,5 +4,5 @@ export * from './model/PepTexts';
|
|
|
4
4
|
|
|
5
5
|
export { PepIsPepPage } from './pages/PepIsPepPage';
|
|
6
6
|
export { PepRelationPage } from './pages/PepRelationPage';
|
|
7
|
-
export { PepRolePage } from './pages/PepRolePage';
|
|
7
|
+
export { PepRolePage, militaryAlternatives, roleAlternatives } from './pages/PepRolePage';
|
|
8
8
|
export { PepStatusPage } from './pages/PepStatusPage';
|
package/src/demo/Done.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
2
|
import { PepContext } from "../pages/PepContext";
|
|
3
|
-
import {
|
|
3
|
+
import { stateToRequest } from "../model/PepModel";
|
|
4
4
|
|
|
5
5
|
export function Done() {
|
|
6
6
|
const pepContext = useContext(PepContext);
|
|
@@ -8,7 +8,7 @@ export function Done() {
|
|
|
8
8
|
<div>
|
|
9
9
|
<h2>Taco hej!</h2>
|
|
10
10
|
<p>Leverpastej!</p>
|
|
11
|
-
<pre>{JSON.stringify(
|
|
11
|
+
<pre>{JSON.stringify(stateToRequest(pepContext.state), null, 2)}</pre>
|
|
12
12
|
</div>
|
|
13
13
|
);
|
|
14
14
|
}
|
package/src/model/PepTexts.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
|
|
8
8
|
export const LABELS = (name?: string) => {
|
|
9
9
|
let possessiveName = name;
|
|
10
|
-
if (possessiveName && possessiveName[possessiveName.length - 1] !== "s") {
|
|
10
|
+
if (possessiveName && possessiveName[possessiveName.length - 1] !== "s" && possessiveName[possessiveName.length - 1] !== "z" && possessiveName[possessiveName.length - 1] !== "x") {
|
|
11
11
|
possessiveName += "s";
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -27,7 +27,7 @@ interface Props {
|
|
|
27
27
|
next: () => void;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const roleAlternatives: Alternative[] = [
|
|
30
|
+
export const roleAlternatives: Alternative[] = [
|
|
31
31
|
{ text: "Stats eller regeringschef", value: Role.HEAD_OF_GOVERNMENT },
|
|
32
32
|
{ text: "Minister eller Vice/Biträdande minister", value: Role.MINISTER },
|
|
33
33
|
{ text: "Ledamot i parlament eller riksdag", value: Role.PARLIMENT_MEMBER },
|
|
@@ -66,7 +66,7 @@ const roleAlternatives: Alternative[] = [
|
|
|
66
66
|
}
|
|
67
67
|
];
|
|
68
68
|
|
|
69
|
-
const militaryAlternatives: Alternative[] = [
|
|
69
|
+
export const militaryAlternatives: Alternative[] = [
|
|
70
70
|
{
|
|
71
71
|
text: "General",
|
|
72
72
|
value: MilitaryRank.GENERAL
|
|
@@ -1,142 +1,142 @@
|
|
|
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
|
-
/>
|
|
136
|
-
) : null}
|
|
137
|
-
|
|
138
|
-
<PrimaryButton type="submit">Nästa</PrimaryButton>
|
|
139
|
-
</Form>
|
|
140
|
-
</div>
|
|
141
|
-
);
|
|
142
|
-
};
|
|
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
|
+
/>
|
|
136
|
+
) : null}
|
|
137
|
+
|
|
138
|
+
<PrimaryButton type="submit">Nästa</PrimaryButton>
|
|
139
|
+
</Form>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
};
|