back-testing-react 2.1.10 → 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 +2 -2
- 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/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>
|