@star-insure/sdk 3.0.0 → 3.0.2
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/dist/sdk.cjs.development.js +1 -0
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +1 -0
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/api/auth.d.ts +1 -1
- package/dist/types/models/quotes/QuoteRequestVehicle.d.ts +3 -2
- package/package.json +1 -1
- package/src/components/forms/FormTester.tsx +188 -144
- package/src/types/api/auth.ts +1 -0
- package/src/types/models/quotes/QuoteRequestVehicle.ts +21 -20
|
@@ -3,168 +3,212 @@ import { Button } from '../common';
|
|
|
3
3
|
import { useQuoteRequestForm } from '../../lib';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
|
-
|
|
6
|
+
populatePurchaseOptions: boolean;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export default function FormTester({ populatePurchaseOptions = false }: Props) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const { form } = useQuoteRequestForm();
|
|
11
|
+
const [keys, setKeys] = React.useState<string[]>([]);
|
|
12
|
+
const [isDev, setDev] = React.useState<boolean>(false);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
function handlePopulate() {
|
|
15
|
+
form?.setData(prevData => ({
|
|
16
|
+
...prevData,
|
|
17
|
+
first_name: 'TEST',
|
|
18
|
+
last_name: 'TEST',
|
|
19
|
+
email: 'dev@sual.co.nz',
|
|
20
|
+
phone: '021 234 5678',
|
|
21
|
+
mobile: '021 234 5678',
|
|
22
|
+
dob: '1990-01-01',
|
|
23
|
+
licence: 'Other',
|
|
24
|
+
licence_other: 'Test',
|
|
25
|
+
club_id: 50,
|
|
26
|
+
club_membership_number: '12345',
|
|
27
|
+
street_address: {
|
|
28
|
+
address: '123 Street Name',
|
|
29
|
+
unit: 'Level 1',
|
|
30
|
+
suburb: 'Suburb',
|
|
31
|
+
city: 'Auckland',
|
|
32
|
+
post_code: '1234',
|
|
33
|
+
},
|
|
34
|
+
promo_code: 'TEST',
|
|
35
|
+
declaration: {
|
|
36
|
+
had_incident: true,
|
|
37
|
+
incidents: [
|
|
38
|
+
{
|
|
39
|
+
description: 'Lorem ipsum dolor sit amet.',
|
|
40
|
+
month: 'January',
|
|
41
|
+
year: '2020',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
has_demerit_points: true,
|
|
45
|
+
demerit_points: '1-24',
|
|
46
|
+
has_lost_licence: true,
|
|
47
|
+
lost_licence_details: 'Lorem ipsum dolor sit amet.',
|
|
48
|
+
was_refused_insurance: true,
|
|
49
|
+
refused_insurance_details: 'Lorem ipsum dolor sit amet.',
|
|
50
|
+
has_criminal_conviction: true,
|
|
51
|
+
criminal_conviction_details: 'Lorem ipsum dolor sit amet.',
|
|
52
|
+
has_vehicle_modifications: true,
|
|
53
|
+
vehicle_modifications_details: 'Lorem ipsum dolor sit amet.',
|
|
54
|
+
has_previous_insurer: true,
|
|
55
|
+
previous_insurer_details: 'AA',
|
|
56
|
+
previous_insurer_expires_at: '2020-01-01',
|
|
57
|
+
additional_details:
|
|
58
|
+
'I am a robot, beep boop. Please ignore this submission.',
|
|
59
|
+
},
|
|
60
|
+
vehicles: [
|
|
61
|
+
{
|
|
62
|
+
make: 'Tesla',
|
|
63
|
+
model: 'Cybertruck',
|
|
64
|
+
year: '2023',
|
|
65
|
+
registration: 'ELMUSK',
|
|
66
|
+
vehicle_type: 'car',
|
|
67
|
+
product: 'star-enthusiast-prestige-everyday-plus',
|
|
68
|
+
value: 100000,
|
|
69
|
+
is_heavy: false,
|
|
70
|
+
usage: 'Childrens car',
|
|
71
|
+
storage_location: 'Carport',
|
|
72
|
+
has_financially_interested_party: true,
|
|
73
|
+
financially_interested_party_detail: 'MTA',
|
|
74
|
+
owned_duration: 'Less than 12 months',
|
|
75
|
+
main_driver: 'TEST TEST',
|
|
76
|
+
drivers: [
|
|
77
|
+
{
|
|
78
|
+
first_name: 'X Æ',
|
|
79
|
+
last_name: 'A-12',
|
|
80
|
+
dob: '2000-05-04',
|
|
81
|
+
licence: 'Other',
|
|
82
|
+
licence_other: 'None',
|
|
83
|
+
relationship: 'Child',
|
|
84
|
+
key: 'driver-test-key',
|
|
33
85
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
previous_insurer_details: 'AA',
|
|
54
|
-
previous_insurer_expires_at: '2020-01-01',
|
|
55
|
-
additional_details: 'I am a robot, beep boop. Please ignore this submission.',
|
|
56
|
-
},
|
|
57
|
-
vehicles: [
|
|
86
|
+
],
|
|
87
|
+
key: 'vehicle-test-key',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
purchase_options: populatePurchaseOptions
|
|
91
|
+
? [
|
|
92
|
+
{
|
|
93
|
+
premium_type: 'annual',
|
|
94
|
+
level_of_insurance_id: 12,
|
|
95
|
+
authorised_drivers: 'TEST',
|
|
96
|
+
excess_details: 'TEST',
|
|
97
|
+
terms: 'TEST',
|
|
98
|
+
description: 'This is a test purchase option',
|
|
99
|
+
premium: 100000,
|
|
100
|
+
monthly_premium: 8500,
|
|
101
|
+
show_monthly: true,
|
|
102
|
+
fsl: 100,
|
|
103
|
+
sort_order: 1,
|
|
104
|
+
enhancements: [
|
|
58
105
|
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
value: 100000,
|
|
66
|
-
is_heavy: false,
|
|
67
|
-
usage: 'Childrens car',
|
|
68
|
-
storage_location: 'Carport',
|
|
69
|
-
has_financially_interested_party: true,
|
|
70
|
-
financially_interested_party_detail: 'MTA',
|
|
71
|
-
owned_duration: 'Less than 12 months',
|
|
72
|
-
drivers: [
|
|
73
|
-
{
|
|
74
|
-
first_name: 'X Æ',
|
|
75
|
-
last_name: 'A-12',
|
|
76
|
-
dob: '2000-05-04',
|
|
77
|
-
licence: 'Other',
|
|
78
|
-
licence_other: 'None',
|
|
79
|
-
relationship: 'Child',
|
|
80
|
-
key: 'driver-test-key',
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
key: 'vehicle-test-key',
|
|
106
|
+
name: 'Test enhancement',
|
|
107
|
+
premium: 2500,
|
|
108
|
+
disable_rounding: false,
|
|
109
|
+
description: 'Test enhancement',
|
|
110
|
+
auto_select: true,
|
|
111
|
+
key: 'enhancement-test-key-1',
|
|
84
112
|
},
|
|
85
|
-
],
|
|
86
|
-
purchase_options: populatePurchaseOptions ? [
|
|
87
113
|
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
premium: 100000,
|
|
95
|
-
monthly_premium: 8500,
|
|
96
|
-
show_monthly: true,
|
|
97
|
-
fsl: 100,
|
|
98
|
-
sort_order: 1,
|
|
99
|
-
enhancements: [
|
|
100
|
-
{ name: 'Test enhancement', premium: 2500, disable_rounding: false, description: 'Test enhancement', auto_select: true, key: 'enhancement-test-key-1' },
|
|
101
|
-
{ name: 'Test enhancement', premium: 5000, disable_rounding: false, description: 'Test enhancement', auto_select: false, key: 'enhancement-test-key-2' }
|
|
102
|
-
],
|
|
103
|
-
key: 'purchase-option-test-key-annual'
|
|
114
|
+
name: 'Test enhancement',
|
|
115
|
+
premium: 5000,
|
|
116
|
+
disable_rounding: false,
|
|
117
|
+
description: 'Test enhancement',
|
|
118
|
+
auto_select: false,
|
|
119
|
+
key: 'enhancement-test-key-2',
|
|
104
120
|
},
|
|
121
|
+
],
|
|
122
|
+
key: 'purchase-option-test-key-annual',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
premium_type: 'total-due',
|
|
126
|
+
level_of_insurance_id: 13,
|
|
127
|
+
authorised_drivers: 'TEST',
|
|
128
|
+
excess_details: 'TEST',
|
|
129
|
+
terms: 'TEST',
|
|
130
|
+
description: 'This is a test purchase option',
|
|
131
|
+
premium: 100000,
|
|
132
|
+
show_monthly: false,
|
|
133
|
+
fsl: 100,
|
|
134
|
+
sort_order: 2,
|
|
135
|
+
enhancements: [
|
|
105
136
|
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
137
|
+
name: 'Test enhancement',
|
|
138
|
+
premium: 2500,
|
|
139
|
+
disable_rounding: false,
|
|
140
|
+
description: 'Test enhancement',
|
|
141
|
+
auto_select: true,
|
|
142
|
+
key: 'enhancement-test-key-3',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'Test enhancement',
|
|
146
|
+
premium: 5000,
|
|
147
|
+
disable_rounding: false,
|
|
148
|
+
description: 'Test enhancement',
|
|
149
|
+
auto_select: false,
|
|
150
|
+
key: 'enhancement-test-key-4',
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
key: 'purchase-option-test-key-total-due',
|
|
154
|
+
},
|
|
155
|
+
]
|
|
156
|
+
: [],
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function handleKeydown(e: KeyboardEvent) {
|
|
161
|
+
if (e.key === 'Escape') {
|
|
162
|
+
return setKeys([]);
|
|
124
163
|
}
|
|
125
164
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return setKeys([]);
|
|
129
|
-
}
|
|
165
|
+
setKeys(prevKeys => [...prevKeys, e.key]);
|
|
166
|
+
}
|
|
130
167
|
|
|
131
|
-
|
|
168
|
+
React.useEffect(() => {
|
|
169
|
+
// Detect when the user has typed the word "debug"
|
|
170
|
+
if (keys.join('') === 'debug') {
|
|
171
|
+
handlePopulate();
|
|
132
172
|
}
|
|
173
|
+
}, [keys]);
|
|
133
174
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|| window.location.href.includes('localhost')
|
|
145
|
-
|| window.location.href.includes('test')
|
|
146
|
-
|| window.location.href.includes('local')
|
|
147
|
-
) {
|
|
148
|
-
setDev(true);
|
|
149
|
-
}
|
|
175
|
+
React.useEffect(() => {
|
|
176
|
+
if (typeof window !== 'undefined') {
|
|
177
|
+
if (
|
|
178
|
+
window.location.href.includes('dev') ||
|
|
179
|
+
window.location.href.includes('localhost') ||
|
|
180
|
+
window.location.href.includes('test') ||
|
|
181
|
+
window.location.href.includes('local')
|
|
182
|
+
) {
|
|
183
|
+
setDev(true);
|
|
184
|
+
}
|
|
150
185
|
|
|
151
|
-
|
|
186
|
+
window.addEventListener('keydown', (e: KeyboardEvent) =>
|
|
187
|
+
handleKeydown(e)
|
|
188
|
+
);
|
|
152
189
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
190
|
+
return () => {
|
|
191
|
+
window.removeEventListener('keydown', (e: KeyboardEvent) =>
|
|
192
|
+
handleKeydown(e)
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
}
|
|
157
196
|
|
|
158
|
-
|
|
159
|
-
|
|
197
|
+
return;
|
|
198
|
+
}, []);
|
|
160
199
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
200
|
+
if (isDev) {
|
|
201
|
+
return (
|
|
202
|
+
<Button
|
|
203
|
+
onClick={handlePopulate}
|
|
204
|
+
type="button"
|
|
205
|
+
status="primary"
|
|
206
|
+
className="fixed bottom-4 right-4"
|
|
207
|
+
>
|
|
208
|
+
Populate data
|
|
209
|
+
</Button>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
168
212
|
|
|
169
|
-
|
|
213
|
+
return <></>;
|
|
170
214
|
}
|
package/src/types/api/auth.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { Product, VehicleType } from
|
|
2
|
-
import { QuoteRequestVehicleDriver } from
|
|
1
|
+
import { Product, VehicleType } from '../../api';
|
|
2
|
+
import { QuoteRequestVehicleDriver } from './QuoteRequestVehicleDriver';
|
|
3
3
|
|
|
4
4
|
export interface QuoteRequestVehicle {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
id?: number;
|
|
6
|
+
vehicle_type?: VehicleType;
|
|
7
|
+
registration?: string;
|
|
8
|
+
make?: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
year?: string;
|
|
11
|
+
usage?: string;
|
|
12
|
+
product?: Product;
|
|
13
|
+
has_financially_interested_party?: boolean;
|
|
14
|
+
financially_interested_party_detail?: string;
|
|
15
|
+
owned_duration?: string;
|
|
16
|
+
value?: number;
|
|
17
|
+
storage_location?: string;
|
|
18
|
+
storage_location_other?: string;
|
|
19
|
+
is_heavy?: boolean;
|
|
20
|
+
quote_request_id?: string;
|
|
21
|
+
drivers?: QuoteRequestVehicleDriver[];
|
|
22
|
+
key?: string;
|
|
23
|
+
main_driver?: string;
|
|
23
24
|
}
|