back-testing-react 2.1.9 → 2.1.11
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/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/back-testing-hub/back-testing-hub.tsx +60 -37
- package/src/components/back-testing-map/back-testing-map.tsx +56 -1
- package/src/components/back-testing-quake-legend/back-testing-quake-legend.tsx +8 -3
- package/src/components/back-testing-quake-legend/back-testing-quake-legend.types.ts +0 -1
- package/src/components/back-testing-sidebar/back-testing-sidebar.tsx +14 -3
- package/src/components/back-testing-stepper/inputs/number-input/number-input.tsx +1 -1
- package/src/components/back-testing-stepper/inputs/number-input/number-input.types.ts +1 -1
- package/src/components/back-testing-stepper/steps/input-anemometer/input-anemometer.tsx +1 -1
- package/src/components/back-testing-stepper/steps/input-cias/input-cias.tsx +14 -10
- package/src/components/back-testing-stepper/steps/input-location/input-location.tsx +4 -3
- package/src/components/back-testing-stepper/steps/input-pga/input-pga.tsx +17 -13
- package/src/components/back-testing-stepper/steps/input-pga/input-pga.types.ts +1 -1
- package/src/components/back-testing-stepper/steps/input-proxy/input-proxy.tsx +11 -7
- package/src/lib/features/back-testing/backTestingSlice.ts +7 -1
- package/src/lib/features/wizard/wizardSlice.ts +4 -6
package/package.json
CHANGED
|
@@ -40,8 +40,6 @@ function BackTestingHub(props: BackTestingHubProps){
|
|
|
40
40
|
const eqPayoutResponse = useAppSelector(selectEQPayoutResponse);
|
|
41
41
|
const [mapInstanceRef, setMapInstanceRef] = React.useState<React.MutableRefObject<mapboxgl.Map | undefined>>();
|
|
42
42
|
|
|
43
|
-
const [wizardPgas, updatePgas] = React.useState<PGA[]>([]);
|
|
44
|
-
|
|
45
43
|
useEffect(() => {
|
|
46
44
|
// initialize payout options
|
|
47
45
|
let proxyPayouts = props.proxyPayoutOptions != undefined ? props.proxyPayoutOptions.map((option) => {return {key:option.key,value:option.value,refId:uuidv4()}}) : [];
|
|
@@ -71,48 +69,73 @@ function BackTestingHub(props: BackTestingHubProps){
|
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
71
|
})
|
|
74
|
-
updatePgas(pgas);
|
|
75
72
|
}, (err) => {
|
|
76
73
|
console.error(err);
|
|
77
74
|
throw Error(err);
|
|
75
|
+
}).finally(() => {
|
|
76
|
+
dispatch(setAPIAccessToken(props.apiAccessToken));
|
|
77
|
+
dispatch(setAutoCalculatePayoutsEnabled(props.calculatePayouts));
|
|
78
|
+
dispatch(setInitialState({
|
|
79
|
+
currentStep:props.currentStep,
|
|
80
|
+
selectedWeatherEvent: props.weatherEvent,
|
|
81
|
+
env: props.env,
|
|
82
|
+
mapAccessToken: props.mapAccessToken,
|
|
83
|
+
isSidebarDisplayed: props.displaySidebar,
|
|
84
|
+
isSidePanelDisplayed: props.displaySidepanel,
|
|
85
|
+
limit: props.limit,
|
|
86
|
+
locations:locations,
|
|
87
|
+
proxies:proxies,
|
|
88
|
+
anemometers:anemometers,
|
|
89
|
+
ciass:ciass,
|
|
90
|
+
pgas:pgas,
|
|
91
|
+
proxyPayoutOptions:proxyPayouts,
|
|
92
|
+
anemometerPayoutOptions:anemometerPayouts,
|
|
93
|
+
ciasPayoutOptions:ciasPayouts,
|
|
94
|
+
pgaPayoutOptions:pgaPayouts,
|
|
95
|
+
defaultProxyPayoutIndex:props.selectedProxyPayoutOptionIndex,
|
|
96
|
+
defaultAnemometerPayoutIndex:props.selectedAnemometerPayoutOptionIndex,
|
|
97
|
+
defaultCIASPayoutIndex:props.selectedCiacPayoutOptionIndex,
|
|
98
|
+
defaultPGAPayoutIndex:props.selectedPgaPayoutOptionIndex,
|
|
99
|
+
windstormEnabled:props.windstormEnabled,
|
|
100
|
+
earthquakeEnabled:props.earthquakeEnabled,
|
|
101
|
+
floodEnabled:props.floodEnabled,
|
|
102
|
+
fireEnabled:props.fireEnabled,
|
|
103
|
+
snowstormEnabled:props.snowstormEnabled
|
|
104
|
+
}))
|
|
78
105
|
})
|
|
106
|
+
} else {
|
|
107
|
+
dispatch(setAPIAccessToken(props.apiAccessToken));
|
|
108
|
+
dispatch(setAutoCalculatePayoutsEnabled(props.calculatePayouts));
|
|
109
|
+
dispatch(setInitialState({
|
|
110
|
+
currentStep:props.currentStep,
|
|
111
|
+
selectedWeatherEvent: props.weatherEvent,
|
|
112
|
+
env: props.env,
|
|
113
|
+
mapAccessToken: props.mapAccessToken,
|
|
114
|
+
isSidebarDisplayed: props.displaySidebar,
|
|
115
|
+
isSidePanelDisplayed: props.displaySidepanel,
|
|
116
|
+
limit: props.limit,
|
|
117
|
+
locations:locations,
|
|
118
|
+
proxies:proxies,
|
|
119
|
+
anemometers:anemometers,
|
|
120
|
+
ciass:ciass,
|
|
121
|
+
pgas:pgas,
|
|
122
|
+
proxyPayoutOptions:proxyPayouts,
|
|
123
|
+
anemometerPayoutOptions:anemometerPayouts,
|
|
124
|
+
ciasPayoutOptions:ciasPayouts,
|
|
125
|
+
pgaPayoutOptions:pgaPayouts,
|
|
126
|
+
defaultProxyPayoutIndex:props.selectedProxyPayoutOptionIndex,
|
|
127
|
+
defaultAnemometerPayoutIndex:props.selectedAnemometerPayoutOptionIndex,
|
|
128
|
+
defaultCIASPayoutIndex:props.selectedCiacPayoutOptionIndex,
|
|
129
|
+
defaultPGAPayoutIndex:props.selectedPgaPayoutOptionIndex,
|
|
130
|
+
windstormEnabled:props.windstormEnabled,
|
|
131
|
+
earthquakeEnabled:props.earthquakeEnabled,
|
|
132
|
+
floodEnabled:props.floodEnabled,
|
|
133
|
+
fireEnabled:props.fireEnabled,
|
|
134
|
+
snowstormEnabled:props.snowstormEnabled
|
|
135
|
+
}))
|
|
79
136
|
}
|
|
80
|
-
|
|
81
|
-
dispatch(setAPIAccessToken(props.apiAccessToken));
|
|
82
|
-
dispatch(setAutoCalculatePayoutsEnabled(props.calculatePayouts));
|
|
83
|
-
dispatch(setInitialState({
|
|
84
|
-
currentStep:props.currentStep,
|
|
85
|
-
selectedWeatherEvent: props.weatherEvent,
|
|
86
|
-
env: props.env,
|
|
87
|
-
mapAccessToken: props.mapAccessToken,
|
|
88
|
-
isSidebarDisplayed: props.displaySidebar,
|
|
89
|
-
isSidePanelDisplayed: props.displaySidepanel,
|
|
90
|
-
limit: props.limit,
|
|
91
|
-
locations:locations,
|
|
92
|
-
proxies:proxies,
|
|
93
|
-
anemometers:anemometers,
|
|
94
|
-
ciass:ciass,
|
|
95
|
-
pgas:undefined,
|
|
96
|
-
proxyPayoutOptions:proxyPayouts,
|
|
97
|
-
anemometerPayoutOptions:anemometerPayouts,
|
|
98
|
-
ciasPayoutOptions:ciasPayouts,
|
|
99
|
-
pgaPayoutOptions:pgaPayouts,
|
|
100
|
-
defaultProxyPayoutIndex:props.selectedProxyPayoutOptionIndex,
|
|
101
|
-
defaultAnemometerPayoutIndex:props.selectedAnemometerPayoutOptionIndex,
|
|
102
|
-
defaultCIASPayoutIndex:props.selectedCiacPayoutOptionIndex,
|
|
103
|
-
defaultPGAPayoutIndex:props.selectedPgaPayoutOptionIndex,
|
|
104
|
-
windstormEnabled:props.windstormEnabled,
|
|
105
|
-
earthquakeEnabled:props.earthquakeEnabled,
|
|
106
|
-
floodEnabled:props.floodEnabled,
|
|
107
|
-
fireEnabled:props.fireEnabled,
|
|
108
|
-
snowstormEnabled:props.snowstormEnabled
|
|
109
|
-
}))
|
|
110
137
|
},[])
|
|
111
138
|
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
dispatch(setPgas(wizardPgas))
|
|
114
|
-
}, [wizardPgas])
|
|
115
|
-
|
|
116
139
|
useEffect(() => {
|
|
117
140
|
if(mapInstanceRef != undefined && mapInstanceRef?.current != undefined && wsPayoutResponse != undefined && wsPayoutResponse.payouts != undefined){
|
|
118
141
|
dispatch(setPDFOutput(undefined));
|
|
@@ -131,6 +131,57 @@ const BackTestingMap = forwardRef<BackTestingActions, BackTestingMapProps>((prop
|
|
|
131
131
|
return true;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
function validatePGAs(pgas: PGA[]) : boolean {
|
|
135
|
+
for(var i = 0; i < pgas.length; i++){
|
|
136
|
+
const pga = pgas[i];
|
|
137
|
+
switch(pga.shapeType){
|
|
138
|
+
case CATShapeType.CIRCLE:
|
|
139
|
+
if(pga.circle.latitude == undefined || pga.circle.longitude == undefined || pga.circle.radius){
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
if(pga.circle.ciasChoice == RadioChoice.CUSTOM && pga.circle.customPayouts == undefined){
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
if(pga.circle.ciasChoice == RadioChoice.DEFAULT && (pga.circle.payoutTableRefId == undefined || pgaPayoutOption == undefined)){
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if(pga.circle.ciasChoice == RadioChoice.DEFAULT && pgaPayoutOption?.find((option) => { return option.refId == pga.circle.payoutTableRefId}) == undefined){
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case CATShapeType.POLYGON:
|
|
153
|
+
if(pga.polygon.coords.length < 3 || pga.polygon.coords.find((coord) => {return coord.latitude == undefined}) != undefined || pga.polygon.coords.find((coord) => {return coord.longitude == undefined}) != undefined){
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if(pga.polygon.ciasChoice == RadioChoice.CUSTOM && pga.polygon.customPayouts == undefined){
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
if(pga.polygon.ciasChoice == RadioChoice.DEFAULT && (pga.polygon.payoutTableRefId == undefined || pgaPayoutOption == undefined)){
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
if(pga.polygon.ciasChoice == RadioChoice.DEFAULT && pgaPayoutOption?.find((option) => { return option.refId == pga.polygon.payoutTableRefId}) == undefined){
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
case CATShapeType.COUNTY:
|
|
167
|
+
if(pga.county.geometry == undefined){
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if(pga.county.ciasChoice == RadioChoice.CUSTOM && pga.county.customPayouts == undefined){
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
if(pga.county.ciasChoice == RadioChoice.DEFAULT && (pga.county.payoutTableRefId == undefined || pgaPayoutOption == undefined)){
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
if(pga.county.ciasChoice == RadioChoice.DEFAULT && pgaPayoutOption?.find((option) => { return option.refId == pga.county.payoutTableRefId}) == undefined){
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
|
|
134
185
|
function generateCATRequest(shapes:CIAS[]) : CIASRequest[]{
|
|
135
186
|
let retVal : CIASRequest[] = []
|
|
136
187
|
for(var i = 0; i < shapes.length; i++){
|
|
@@ -256,6 +307,10 @@ const BackTestingMap = forwardRef<BackTestingActions, BackTestingMapProps>((prop
|
|
|
256
307
|
}
|
|
257
308
|
|
|
258
309
|
function fetchEQPayouts(){
|
|
310
|
+
if(!validatePGAs(pgas)){
|
|
311
|
+
console.log("PGAs failed validation checks")
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
259
314
|
const request : EQPayoutsRequest = {
|
|
260
315
|
type:'EQ',
|
|
261
316
|
limit: insuranceLimit,
|
|
@@ -1023,7 +1078,7 @@ const BackTestingMap = forwardRef<BackTestingActions, BackTestingMapProps>((prop
|
|
|
1023
1078
|
</ToggleButtonGroup>
|
|
1024
1079
|
{selectedMapView == MapView.STORMS && <BackTestingStormLegend stormTracks={wsPayoutResponse?.payouts || []} mapInstanceRef={mapInstanceRef}/>}
|
|
1025
1080
|
</>}
|
|
1026
|
-
{selectedWeatherEvent == WeatherEventOption.EARTHQUAKE && <BackTestingQuakeLegend
|
|
1081
|
+
{selectedWeatherEvent == WeatherEventOption.EARTHQUAKE && <BackTestingQuakeLegend mapInstanceRef={mapInstanceRef}/>}
|
|
1027
1082
|
<BackTestingTag tagline={tagline} taglineColor="rgb(30, 39, 88)" opacity={0.7}></BackTestingTag>
|
|
1028
1083
|
<div ref={mapContainerRef} className="map__container" />
|
|
1029
1084
|
</div>
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
import { BackTestingQuakeLegendProps } from "./back-testing-quake-legend.types";
|
|
2
2
|
import './back-testing-quake-legend.css'
|
|
3
3
|
import { EQPayoutDTO } from "../../lib/features/back-testing/backTestingAPISlice";
|
|
4
|
+
import { useAppSelector } from "../../lib/hooks";
|
|
5
|
+
import { selectEQPayoutResponse } from "../../lib/features/back-testing/backTestingSlice";
|
|
4
6
|
|
|
5
7
|
const BackTestingQuakeLegend = (props: BackTestingQuakeLegendProps,) => {
|
|
8
|
+
|
|
9
|
+
const eqPayoutResponse = useAppSelector(selectEQPayoutResponse);
|
|
10
|
+
|
|
6
11
|
return (
|
|
7
12
|
<div>
|
|
8
|
-
{
|
|
13
|
+
{eqPayoutResponse?.payouts &&
|
|
9
14
|
<div className={props.className + " storm-legend"} style={{overflow:'auto',borderRadius:'3px',paddingLeft:'16px',paddingRight:'16px',paddingBottom:'16px',position:'absolute',zIndex:10,right:20,backgroundColor:'rgba(255,255,255,0.6)',maxHeight:'calc(100% - 80px)'}}>
|
|
10
15
|
<div style={{padding:'0'}}>
|
|
11
16
|
<div style={{ color: 'gray', fontSize:'16px', fontWeight:700, paddingBottom:'16px',paddingTop:'16px', textAlign:'center' }}>
|
|
12
17
|
Earthquake Legend
|
|
13
18
|
</div>
|
|
14
19
|
<div>
|
|
15
|
-
{
|
|
20
|
+
{eqPayoutResponse.payouts && eqPayoutResponse.payouts.map((quake: EQPayoutDTO) => (
|
|
16
21
|
<div key={quake.evid}>
|
|
17
22
|
<span style={{ width:'20px', height:'20px', backgroundColor:quake.color, display:'inline-block', marginRight:'10px',marginLeft:'10px' }}></span>
|
|
18
23
|
<span style={{ position:'relative', height:'25px', top:-5, display:'inline-block' }}>{quake.place}</span>
|
|
19
24
|
</div>
|
|
20
25
|
))}
|
|
21
|
-
{
|
|
26
|
+
{eqPayoutResponse.payouts.length == 0 &&
|
|
22
27
|
<div style={{ fontSize:'11px' }}>
|
|
23
28
|
<em>...no earthquake events found</em>
|
|
24
29
|
</div>
|
|
@@ -8,8 +8,8 @@ import React, { useEffect } from "react";
|
|
|
8
8
|
import * as XLSX from 'xlsx';
|
|
9
9
|
import { PayoutWizardStepType } from "../back-testing-stepper/steps/step.types";
|
|
10
10
|
import { useAppDispatch, useAppSelector } from "../../lib/hooks";
|
|
11
|
-
import { isEarthquakeEnabled, isFireEnabled, isFloodEnabled, isSnowstormEnabled, isWindstormEnabled, selectProxyPayoutOptions, selectWeatherEvent, selectWizardStep, setWeatherEvent } from "../../lib/features/wizard/wizardSlice";
|
|
12
|
-
import { isAppLoading, selectPDFOutput, selectWSPayoutRequest, selectWSPayoutResponse } from "../../lib/features/back-testing/backTestingSlice";
|
|
11
|
+
import { isEarthquakeEnabled, isFireEnabled, isFloodEnabled, isSnowstormEnabled, isWindstormEnabled, selectProxyPayoutOptions, selectWeatherEvent, selectWizardStep, setWeatherEvent, updateWeatherEvent } from "../../lib/features/wizard/wizardSlice";
|
|
12
|
+
import { isAppLoading, resetPayouts, selectPDFOutput, selectWSPayoutRequest, selectWSPayoutResponse, setEQPayoutResponse, setPDFOutput } from "../../lib/features/back-testing/backTestingSlice";
|
|
13
13
|
|
|
14
14
|
const BackTestingSidebar = (props:BackTestingSidebarProps) => {
|
|
15
15
|
|
|
@@ -48,12 +48,23 @@ const BackTestingSidebar = (props:BackTestingSidebarProps) => {
|
|
|
48
48
|
setAppActions(actions);
|
|
49
49
|
},[pdfOutput,selectedWeatherEventOption])
|
|
50
50
|
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
switch(selectedWeatherEventOption){
|
|
53
|
+
case WeatherEventOption.WINDSTORM:
|
|
54
|
+
dispatch(setEQPayoutResponse(undefined))
|
|
55
|
+
dispatch(setPDFOutput())
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
51
59
|
function isWeatherEventOptionSelected(option: WeatherOption) : boolean {
|
|
52
60
|
return selectedWeatherEventOption == (option.action);
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
const selectWeatherEventOption = (option: WeatherOption) => {
|
|
56
|
-
|
|
64
|
+
if(option.action != selectedWeatherEventOption){
|
|
65
|
+
dispatch(updateWeatherEvent(option.action));
|
|
66
|
+
dispatch(resetPayouts())
|
|
67
|
+
}
|
|
57
68
|
}
|
|
58
69
|
|
|
59
70
|
const HtmlTooltip = styled(({ className, ...props }: TooltipProps) => (
|
|
@@ -9,7 +9,7 @@ export interface NumberInputProps{
|
|
|
9
9
|
step?: number,
|
|
10
10
|
value?: number | string,
|
|
11
11
|
readOnly?: boolean,
|
|
12
|
-
onChange?: (e: number) => void
|
|
12
|
+
onChange?: (e: number|undefined) => void
|
|
13
13
|
placeholder?: string
|
|
14
14
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
15
15
|
className?: string
|
|
@@ -187,13 +187,13 @@ const InputAnemometerStep = forwardRef<WizardStep, InputAnemometerStepProps>((pr
|
|
|
187
187
|
const anemometer = cloneDeep(wizardAnemometers[i]);
|
|
188
188
|
let isAnemometerChoiceError = (anemometer.anemometerChoice == RadioChoice.CUSTOM && anemometer.customPayouts == undefined)
|
|
189
189
|
if(isAnemometerChoiceError){
|
|
190
|
-
fileError = true;
|
|
191
190
|
anemometer.fileError = true
|
|
192
191
|
anemometer.fileErrorMsg = FILE_ERROR;
|
|
193
192
|
if(!fileError){
|
|
194
193
|
setExpanded('panel'+(anemometer.refId));
|
|
195
194
|
setSelectedAnemometer(anemometer);
|
|
196
195
|
}
|
|
196
|
+
fileError = true;
|
|
197
197
|
} else{
|
|
198
198
|
anemometer.fileError = false
|
|
199
199
|
anemometer.fileErrorMsg = "";
|
|
@@ -206,7 +206,11 @@ const InputCIASStep = forwardRef<WizardStep, InputCIASStepProps>((props,ref) =>
|
|
|
206
206
|
let location = locations.find((location) => location.refId == id)
|
|
207
207
|
if(location){
|
|
208
208
|
clonedCircle.latitude = location.latitude;
|
|
209
|
+
clonedCircle.latError = false;
|
|
210
|
+
clonedCircle.latErrorMsg = "";
|
|
209
211
|
clonedCircle.longitude = location.longitude;
|
|
212
|
+
clonedCircle.lngError = false;
|
|
213
|
+
clonedCircle.lngErrorMsg = "";
|
|
210
214
|
}
|
|
211
215
|
clonedCIAS.circle = clonedCircle;
|
|
212
216
|
updateCIAS(clonedCIAS,onLoad);
|
|
@@ -252,14 +256,14 @@ const InputCIASStep = forwardRef<WizardStep, InputCIASStepProps>((props,ref) =>
|
|
|
252
256
|
updateShape(clonedCIAS,clonedPolygon);
|
|
253
257
|
}
|
|
254
258
|
|
|
255
|
-
function updatePolygonCoordinateLat(cias: CIAS, polygon:CATPolygon,index:number,value:number){
|
|
259
|
+
function updatePolygonCoordinateLat(cias: CIAS, polygon:CATPolygon,index:number,value:number|undefined){
|
|
256
260
|
let clonedCIAS = cloneDeep(cias);
|
|
257
261
|
let clonedPolygon = cloneDeep(polygon);
|
|
258
262
|
clonedPolygon.coords[index].latitude = value;
|
|
259
263
|
updateShape(clonedCIAS,clonedPolygon);
|
|
260
264
|
}
|
|
261
265
|
|
|
262
|
-
function updatePolygonCoordinateLng(cias: CIAS, polygon:CATPolygon,index:number,value:number){
|
|
266
|
+
function updatePolygonCoordinateLng(cias: CIAS, polygon:CATPolygon,index:number,value:number|undefined){
|
|
263
267
|
let clonedCIAS = cloneDeep(cias);
|
|
264
268
|
let clonedPolygon = cloneDeep(polygon);
|
|
265
269
|
clonedPolygon.coords[index].longitude = value;
|
|
@@ -308,13 +312,13 @@ const InputCIASStep = forwardRef<WizardStep, InputCIASStepProps>((props,ref) =>
|
|
|
308
312
|
let circle = cias.circle;
|
|
309
313
|
let latError = circle.latitude == undefined || Number.isNaN(circle.latitude) || circle.latitude < -90;
|
|
310
314
|
if(latError){
|
|
311
|
-
latitudeError = true;
|
|
312
315
|
circle.latError = true
|
|
313
316
|
circle.latErrorMsg = LAT_ERROR;
|
|
314
317
|
if(!fileError && !latitudeError && !longitudeError){
|
|
315
318
|
setExpanded('panel'+(cias.refId));
|
|
316
319
|
setSelectedCIAS(cias);
|
|
317
320
|
}
|
|
321
|
+
latitudeError = true;
|
|
318
322
|
} else{
|
|
319
323
|
circle.latError = false
|
|
320
324
|
circle.latErrorMsg = "";
|
|
@@ -325,18 +329,18 @@ const InputCIASStep = forwardRef<WizardStep, InputCIASStepProps>((props,ref) =>
|
|
|
325
329
|
|
|
326
330
|
// perform circle longitude validations
|
|
327
331
|
for(var i = 0; i < ciasList.length; i++){
|
|
328
|
-
const cias =
|
|
332
|
+
const cias = ciasList[i];
|
|
329
333
|
if(cias.shapeType == CATShapeType.CIRCLE){
|
|
330
334
|
let circle = cias.circle;
|
|
331
335
|
let lngError = circle.longitude == undefined || Number.isNaN(circle.longitude) || circle.longitude < -180;
|
|
332
336
|
if(lngError){
|
|
333
|
-
longitudeError = true;
|
|
334
337
|
circle.lngError = true
|
|
335
338
|
circle.lngErrorMsg = LNG_ERROR;
|
|
336
339
|
if(!fileError && !latitudeError && !longitudeError){
|
|
337
340
|
setExpanded('panel'+(cias.refId));
|
|
338
341
|
setSelectedCIAS(cias);
|
|
339
342
|
}
|
|
343
|
+
longitudeError = true;
|
|
340
344
|
} else{
|
|
341
345
|
circle.lngError = false
|
|
342
346
|
circle.lngErrorMsg = "";
|
|
@@ -346,18 +350,18 @@ const InputCIASStep = forwardRef<WizardStep, InputCIASStepProps>((props,ref) =>
|
|
|
346
350
|
|
|
347
351
|
// perform circle longitude validations
|
|
348
352
|
for(var i = 0; i < ciasList.length; i++){
|
|
349
|
-
const cias =
|
|
353
|
+
const cias = ciasList[i];
|
|
350
354
|
if(cias.shapeType == CATShapeType.CIRCLE){
|
|
351
355
|
let circle = cias.circle;
|
|
352
356
|
let lngError = circle.longitude == undefined || Number.isNaN(circle.longitude) || circle.longitude < -180;
|
|
353
357
|
if(lngError){
|
|
354
|
-
longitudeError = true;
|
|
355
358
|
circle.lngError = true
|
|
356
359
|
circle.lngErrorMsg = LNG_ERROR;
|
|
357
360
|
if(!fileError && !latitudeError && !longitudeError){
|
|
358
361
|
setExpanded('panel'+(cias.refId));
|
|
359
362
|
setSelectedCIAS(cias);
|
|
360
363
|
}
|
|
364
|
+
longitudeError = true;
|
|
361
365
|
} else{
|
|
362
366
|
circle.lngError = false
|
|
363
367
|
circle.lngErrorMsg = "";
|
|
@@ -367,18 +371,18 @@ const InputCIASStep = forwardRef<WizardStep, InputCIASStepProps>((props,ref) =>
|
|
|
367
371
|
|
|
368
372
|
// perform payout file validations
|
|
369
373
|
for(var i = 0; i < ciasList.length; i++){
|
|
370
|
-
const cias =
|
|
374
|
+
const cias = ciasList[i];
|
|
371
375
|
if(cias.shapeType == CATShapeType.CIRCLE){
|
|
372
376
|
let circle = cias.circle;
|
|
373
377
|
let isCIACChoiceError = (circle.ciasChoice == RadioChoice.CUSTOM && circle.customPayouts == undefined)
|
|
374
378
|
if(isCIACChoiceError){
|
|
375
|
-
fileError = true;
|
|
376
379
|
circle.fileError = true
|
|
377
380
|
circle.fileErrorMsg = FILE_ERROR;
|
|
378
381
|
if(!fileError && !latitudeError && !longitudeError){
|
|
379
382
|
setExpanded('panel'+(cias.refId));
|
|
380
383
|
setSelectedCIAS(cias);
|
|
381
384
|
}
|
|
385
|
+
fileError = true;
|
|
382
386
|
} else {
|
|
383
387
|
circle.fileError = false
|
|
384
388
|
circle.fileErrorMsg = "";
|
|
@@ -387,13 +391,13 @@ const InputCIASStep = forwardRef<WizardStep, InputCIASStepProps>((props,ref) =>
|
|
|
387
391
|
let polygon = cias.polygon;
|
|
388
392
|
let isCIACChoiceError = (polygon.ciasChoice == RadioChoice.CUSTOM && polygon.customPayouts == undefined)
|
|
389
393
|
if(isCIACChoiceError){
|
|
390
|
-
fileError = true;
|
|
391
394
|
polygon.fileError = true
|
|
392
395
|
polygon.fileErrorMsg = FILE_ERROR;
|
|
393
396
|
if(!fileError && !latitudeError && !longitudeError){
|
|
394
397
|
setExpanded('panel'+(cias.refId));
|
|
395
398
|
setSelectedCIAS(cias);
|
|
396
399
|
}
|
|
400
|
+
fileError = true;
|
|
397
401
|
} else {
|
|
398
402
|
polygon.fileError = false
|
|
399
403
|
polygon.fileErrorMsg = "";
|
|
@@ -212,13 +212,14 @@ const InputLocationStep = forwardRef<WizardStep, InputLocationStepProps>((props,
|
|
|
212
212
|
let location = cloneDeep(wizardLocations[i]);
|
|
213
213
|
let latError = location.latitude == undefined || Number.isNaN(location.latitude) || location.latitude < -90;
|
|
214
214
|
if(latError){
|
|
215
|
-
latitudeError = true;
|
|
216
215
|
location.latError = true
|
|
217
216
|
location.latErrorMsg = LAT_ERROR;
|
|
218
217
|
if(!latitudeError && !longitudeError){
|
|
219
218
|
setExpanded('panel'+(location.refId));
|
|
220
219
|
setSelectedLocation(location);
|
|
221
220
|
}
|
|
221
|
+
latitudeError = true;
|
|
222
|
+
|
|
222
223
|
} else{
|
|
223
224
|
location.latError = false
|
|
224
225
|
location.latErrorMsg = "";
|
|
@@ -227,16 +228,16 @@ const InputLocationStep = forwardRef<WizardStep, InputLocationStepProps>((props,
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
for(var i = 0; i < locationsList.length; i++){
|
|
230
|
-
let location =
|
|
231
|
+
let location = locationsList[i];
|
|
231
232
|
let lngError = location.longitude == undefined || Number.isNaN(location.longitude) || location.longitude < -180;
|
|
232
233
|
if(lngError){
|
|
233
|
-
longitudeError = true;
|
|
234
234
|
location.lngError = true
|
|
235
235
|
location.lngErrorMsg = LNG_ERROR;
|
|
236
236
|
if(!latitudeError && !longitudeError){
|
|
237
237
|
setExpanded('panel'+(location.refId));
|
|
238
238
|
setSelectedLocation(location);
|
|
239
239
|
}
|
|
240
|
+
longitudeError = true;
|
|
240
241
|
} else{
|
|
241
242
|
location.lngError = false
|
|
242
243
|
location.lngErrorMsg = "";
|
|
@@ -269,7 +269,11 @@ const InputPGAStep = forwardRef<WizardStep, InputPGAStepProps>((props,ref) => {
|
|
|
269
269
|
let location = locations.find((location) => location.refId == id)
|
|
270
270
|
if(location){
|
|
271
271
|
clonedCircle.latitude = location.latitude;
|
|
272
|
+
clonedCircle.latError = false;
|
|
273
|
+
clonedCircle.latErrorMsg = "";
|
|
272
274
|
clonedCircle.longitude = location.longitude;
|
|
275
|
+
clonedCircle.lngError = false;
|
|
276
|
+
clonedCircle.lngErrorMsg = "";
|
|
273
277
|
}
|
|
274
278
|
clonedPGA.circle = clonedCircle;
|
|
275
279
|
updatePGA(clonedPGA,onLoad);
|
|
@@ -311,13 +315,13 @@ const InputPGAStep = forwardRef<WizardStep, InputPGAStepProps>((props,ref) => {
|
|
|
311
315
|
updateShape(pga,clonedPolygon);
|
|
312
316
|
}
|
|
313
317
|
|
|
314
|
-
function updatePolygonCoordinateLat(pga: PGA, polygon:CATPolygon,index:number,value:number){
|
|
318
|
+
function updatePolygonCoordinateLat(pga: PGA, polygon:CATPolygon,index:number,value:number|undefined){
|
|
315
319
|
const clonedPolygon = cloneDeep(polygon);
|
|
316
320
|
clonedPolygon.coords[index].latitude = value;
|
|
317
321
|
updateShape(pga,clonedPolygon);
|
|
318
322
|
}
|
|
319
323
|
|
|
320
|
-
function updatePolygonCoordinateLng(pga: PGA, polygon:CATPolygon,index:number,value:number){
|
|
324
|
+
function updatePolygonCoordinateLng(pga: PGA, polygon:CATPolygon,index:number,value:number|undefined){
|
|
321
325
|
const clonedPolygon = cloneDeep(polygon);
|
|
322
326
|
clonedPolygon.coords[index].longitude = value;
|
|
323
327
|
updateShape(pga,clonedPolygon);
|
|
@@ -404,13 +408,13 @@ const InputPGAStep = forwardRef<WizardStep, InputPGAStepProps>((props,ref) => {
|
|
|
404
408
|
let county = pga.county;
|
|
405
409
|
let countyError = county.countyFIPSCode == undefined || county.geometry == undefined;
|
|
406
410
|
if(countyError){
|
|
407
|
-
usCountyError = true;
|
|
408
411
|
county.countyError = true
|
|
409
412
|
county.countyErrorMsg = COUNTY_ERROR;
|
|
410
413
|
if(!fileError && !latitudeError && !longitudeError && !usCountyError){
|
|
411
414
|
setExpanded('panel'+(pga.refId));
|
|
412
415
|
setSelectedPGA(pga);
|
|
413
416
|
}
|
|
417
|
+
usCountyError = true;
|
|
414
418
|
} else{
|
|
415
419
|
county.countyError = false
|
|
416
420
|
county.countyErrorMsg = "";
|
|
@@ -422,18 +426,18 @@ const InputPGAStep = forwardRef<WizardStep, InputPGAStepProps>((props,ref) => {
|
|
|
422
426
|
|
|
423
427
|
// perform circle latitude validations
|
|
424
428
|
for(var i = 0; i < pgaList.length; i++){
|
|
425
|
-
const pga =
|
|
429
|
+
const pga = pgaList[i];
|
|
426
430
|
if(pga.shapeType == CATShapeType.CIRCLE){
|
|
427
431
|
let circle = pga.circle;
|
|
428
432
|
let latError = circle.latitude == undefined || Number.isNaN(circle.latitude) || circle.latitude < -90;
|
|
429
433
|
if(latError){
|
|
430
|
-
latitudeError = true;
|
|
431
434
|
circle.latError = true
|
|
432
435
|
circle.latErrorMsg = LAT_ERROR;
|
|
433
436
|
if(!fileError && !latitudeError && !longitudeError && !usCountyError){
|
|
434
437
|
setExpanded('panel'+(pga.refId));
|
|
435
438
|
setSelectedPGA(pga);
|
|
436
439
|
}
|
|
440
|
+
latitudeError = true;
|
|
437
441
|
} else{
|
|
438
442
|
circle.latError = false
|
|
439
443
|
circle.latErrorMsg = "";
|
|
@@ -443,18 +447,18 @@ const InputPGAStep = forwardRef<WizardStep, InputPGAStepProps>((props,ref) => {
|
|
|
443
447
|
|
|
444
448
|
// perform circle longitude validations
|
|
445
449
|
for(var i = 0; i < pgaList.length; i++){
|
|
446
|
-
const pga =
|
|
450
|
+
const pga = pgaList[i];
|
|
447
451
|
if(pga.shapeType == CATShapeType.CIRCLE){
|
|
448
452
|
let circle = pga.circle;
|
|
449
453
|
let lngError = circle.longitude == undefined || Number.isNaN(circle.longitude) || circle.longitude < -180;
|
|
450
454
|
if(lngError){
|
|
451
|
-
longitudeError = true;
|
|
452
455
|
circle.lngError = true
|
|
453
456
|
circle.lngErrorMsg = LNG_ERROR;
|
|
454
457
|
if(!fileError && !latitudeError && !longitudeError && !usCountyError){
|
|
455
458
|
setExpanded('panel'+(pga.refId));
|
|
456
459
|
setSelectedPGA(pga);
|
|
457
460
|
}
|
|
461
|
+
longitudeError = true;
|
|
458
462
|
} else{
|
|
459
463
|
circle.lngError = false
|
|
460
464
|
circle.lngErrorMsg = "";
|
|
@@ -464,18 +468,18 @@ const InputPGAStep = forwardRef<WizardStep, InputPGAStepProps>((props,ref) => {
|
|
|
464
468
|
|
|
465
469
|
// perform circle longitude validations
|
|
466
470
|
for(var i = 0; i < pgaList.length; i++){
|
|
467
|
-
const pga =
|
|
471
|
+
const pga = pgaList[i];
|
|
468
472
|
if(pga.shapeType == CATShapeType.CIRCLE){
|
|
469
473
|
let circle = pga.circle;
|
|
470
474
|
let lngError = circle.longitude == undefined || Number.isNaN(circle.longitude) || circle.longitude < -180;
|
|
471
475
|
if(lngError){
|
|
472
|
-
longitudeError = true;
|
|
473
476
|
circle.lngError = true
|
|
474
477
|
circle.lngErrorMsg = LNG_ERROR;
|
|
475
478
|
if(!fileError && !latitudeError && !longitudeError && !usCountyError){
|
|
476
479
|
setExpanded('panel'+(pga.refId));
|
|
477
480
|
setSelectedPGA(pga);
|
|
478
481
|
}
|
|
482
|
+
longitudeError = true;
|
|
479
483
|
} else{
|
|
480
484
|
circle.lngError = false
|
|
481
485
|
circle.lngErrorMsg = "";
|
|
@@ -486,18 +490,18 @@ const InputPGAStep = forwardRef<WizardStep, InputPGAStepProps>((props,ref) => {
|
|
|
486
490
|
|
|
487
491
|
// perform payout file validations
|
|
488
492
|
for(var i = 0; i < pgaList.length; i++){
|
|
489
|
-
const pga =
|
|
493
|
+
const pga = pgaList[i];
|
|
490
494
|
if(pga.shapeType == CATShapeType.CIRCLE){
|
|
491
495
|
let circle = pga.circle;
|
|
492
496
|
let isCIACChoiceError = (circle.ciasChoice == RadioChoice.CUSTOM && circle.customPayouts == undefined)
|
|
493
497
|
if(isCIACChoiceError){
|
|
494
|
-
fileError = true;
|
|
495
498
|
circle.fileError = true
|
|
496
499
|
circle.fileErrorMsg = FILE_ERROR;
|
|
497
500
|
if(!fileError && !latitudeError && !longitudeError && !usCountyError){
|
|
498
501
|
setExpanded('panel'+(pga.refId));
|
|
499
502
|
setSelectedPGA(pga);
|
|
500
503
|
}
|
|
504
|
+
fileError = true;
|
|
501
505
|
} else {
|
|
502
506
|
circle.fileError = false
|
|
503
507
|
circle.fileErrorMsg = "";
|
|
@@ -506,13 +510,13 @@ const InputPGAStep = forwardRef<WizardStep, InputPGAStepProps>((props,ref) => {
|
|
|
506
510
|
let polygon = pga.polygon;
|
|
507
511
|
let isCIACChoiceError = (polygon.ciasChoice == RadioChoice.CUSTOM && polygon.customPayouts == undefined)
|
|
508
512
|
if(isCIACChoiceError){
|
|
509
|
-
fileError = true;
|
|
510
513
|
polygon.fileError = true
|
|
511
514
|
polygon.fileErrorMsg = FILE_ERROR;
|
|
512
515
|
if(!fileError && !latitudeError && !longitudeError && !usCountyError){
|
|
513
516
|
setExpanded('panel'+(pga.refId));
|
|
514
517
|
setSelectedPGA(pga);
|
|
515
518
|
}
|
|
519
|
+
fileError = true;
|
|
516
520
|
} else {
|
|
517
521
|
polygon.fileError = false
|
|
518
522
|
polygon.fileErrorMsg = "";
|
|
@@ -521,13 +525,13 @@ const InputPGAStep = forwardRef<WizardStep, InputPGAStepProps>((props,ref) => {
|
|
|
521
525
|
let county = pga.county;
|
|
522
526
|
let isCIACChoiceError = (county.ciasChoice == RadioChoice.CUSTOM && county.customPayouts == undefined)
|
|
523
527
|
if(isCIACChoiceError){
|
|
524
|
-
fileError = true;
|
|
525
528
|
county.fileError = true
|
|
526
529
|
county.fileErrorMsg = FILE_ERROR;
|
|
527
530
|
if(!fileError && !latitudeError && !longitudeError && !usCountyError){
|
|
528
531
|
setExpanded('panel'+(pga.refId));
|
|
529
532
|
setSelectedPGA(pga);
|
|
530
533
|
}
|
|
534
|
+
fileError = true;
|
|
531
535
|
} else {
|
|
532
536
|
county.fileError = false
|
|
533
537
|
county.fileErrorMsg = "";
|
|
@@ -15,7 +15,7 @@ export interface PGA {
|
|
|
15
15
|
export function generateNewPGA(shapeType:CATShapeType|undefined, latitude: number|undefined, longitude: number|undefined, radius:number|undefined, coords: Coordinate[]|undefined, fipsCode:string|undefined, payoutOption:string | undefined) : PGA {
|
|
16
16
|
const pga : PGA = {
|
|
17
17
|
refId: uuidv4(),
|
|
18
|
-
shapeType: shapeType || CATShapeType.
|
|
18
|
+
shapeType: shapeType || CATShapeType.COUNTY,
|
|
19
19
|
circle: generateNewCATCircle(latitude,longitude,radius,payoutOption),
|
|
20
20
|
polygon: generateNewCATPolygon(coords,payoutOption),
|
|
21
21
|
county: generateNewCATCounty(fipsCode,payoutOption)
|