@opengeoweb/taf 2.4.0 → 2.6.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.
Files changed (41) hide show
  1. package/index.d.ts +2 -0
  2. package/index.esm.js +1945 -415
  3. package/index.umd.js +1962 -433
  4. package/lib/components/ComponentsLookUp/ComponentsLookUp.d.ts +34 -0
  5. package/lib/components/{TafForm/TafFormWrapper.spec.d.ts → ComponentsLookUp/ComponentsLookUp.spec.d.ts} +0 -0
  6. package/lib/components/ComponentsLookUp/index.d.ts +1 -0
  7. package/lib/components/IssuesPane/IssuesButton.d.ts +3 -6
  8. package/lib/components/IssuesPane/IssuesPane.d.ts +7 -9
  9. package/lib/components/IssuesPane/IssuesPaneWrapper.d.ts +4 -0
  10. package/lib/components/IssuesPane/IssuesPaneWrapper.spec.d.ts +1 -0
  11. package/lib/components/IssuesPane/types.d.ts +11 -0
  12. package/lib/components/IssuesPane/utils.d.ts +10 -0
  13. package/lib/components/IssuesPane/utils.spec.d.ts +1 -0
  14. package/lib/components/TafForm/TafForm.d.ts +5 -3
  15. package/lib/components/TafForm/TafForm.spec.d.ts +1 -0
  16. package/lib/components/TafForm/TafForm.statusChanges.spec.d.ts +1 -0
  17. package/lib/components/TafForm/{TafFormWrapper.stories.d.ts → TafForm.stories.d.ts} +0 -0
  18. package/lib/components/TafForm/TafFormButtons/TafFormButtons.d.ts +1 -0
  19. package/lib/components/TafForm/index.d.ts +1 -1
  20. package/lib/components/TafForm/utils.d.ts +20 -1
  21. package/lib/components/TafLayout/TacOverview/ExportButton.d.ts +7 -0
  22. package/lib/components/TafLayout/TacOverview/ExportButton.spec.d.ts +1 -0
  23. package/lib/components/TafLayout/TacOverview/TacContainer.d.ts +1 -0
  24. package/lib/components/TafLayout/TacOverview/TacOverview.d.ts +1 -0
  25. package/lib/components/TafLayout/TafLayout.d.ts +5 -0
  26. package/lib/components/TafLayout/TafLayout.stories.d.ts +10 -2
  27. package/lib/components/TafLayout/TafPanel/TafPanel.d.ts +23 -2
  28. package/lib/components/TafLayout/TopTabs/TopTabs.d.ts +0 -2
  29. package/lib/components/TafLayout/utils.d.ts +2 -1
  30. package/lib/components/TafModule/TafModule.d.ts +2 -1
  31. package/lib/components/TafModule/TafModule.stories.d.ts +1 -0
  32. package/lib/components/TafModule/TafModuleProvider.d.ts +29 -0
  33. package/lib/components/TafWrapper/TafWrapper.d.ts +4 -0
  34. package/lib/components/TafWrapper/TafWrapper.spec.d.ts +1 -0
  35. package/lib/components/TafWrapper/index.d.ts +1 -0
  36. package/lib/types.d.ts +0 -1
  37. package/lib/utils/mockdata/fakeTafList.d.ts +8 -3
  38. package/lib/utils/testUtils.d.ts +6 -0
  39. package/package.json +7 -7
  40. package/lib/components/Providers/Providers.d.ts +0 -11
  41. package/lib/components/TafForm/TafFormWrapper.d.ts +0 -11
package/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@opengeoweb/form-fields'), require('@mui/material'), require('react-hook-form'), require('react-sortablejs'), require('@opengeoweb/api'), require('@opengeoweb/shared'), require('moment'), require('lodash'), require('@mui/styles/makeStyles'), require('@mui/icons-material'), require('react-dom'), require('@mui/material/LinearProgress'), require('@mui/icons-material/DoDisturb'), require('@mui/material/Box')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@opengeoweb/form-fields', '@mui/material', 'react-hook-form', 'react-sortablejs', '@opengeoweb/api', '@opengeoweb/shared', 'moment', 'lodash', '@mui/styles/makeStyles', '@mui/icons-material', 'react-dom', '@mui/material/LinearProgress', '@mui/icons-material/DoDisturb', '@mui/material/Box'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.formFields, global.material, global.reactHookForm, global.reactSortablejs, global.api, global.shared, global.moment, global.lodash, global.makeStyles, global.iconsMaterial, global.ReactDOM, global.LinearProgress, global.DoDisturbIcon, global.Box));
5
- })(this, (function (exports, React, formFields, material, reactHookForm, reactSortablejs, api, shared, moment, lodash, makeStyles, iconsMaterial, ReactDOM, LinearProgress, DoDisturbIcon, Box) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('react-hook-form'), require('react-sortablejs'), require('@opengeoweb/form-fields'), require('@opengeoweb/api'), require('@opengeoweb/shared'), require('moment'), require('lodash'), require('@mui/styles/makeStyles'), require('@mui/icons-material'), require('react-dom'), require('@mui/material/LinearProgress'), require('@mui/icons-material/DoDisturb'), require('@mui/material/Box')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', 'react-hook-form', 'react-sortablejs', '@opengeoweb/form-fields', '@opengeoweb/api', '@opengeoweb/shared', 'moment', 'lodash', '@mui/styles/makeStyles', '@mui/icons-material', 'react-dom', '@mui/material/LinearProgress', '@mui/icons-material/DoDisturb', '@mui/material/Box'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.material, global.reactHookForm, global.reactSortablejs, global.formFields, global.api, global.shared, global.moment, global.lodash, global.makeStyles, global.iconsMaterial, global.ReactDOM, global.LinearProgress, global.DoDisturbIcon, global.Box));
5
+ })(this, (function (exports, React, material, reactHookForm, reactSortablejs, formFields, api, shared, moment, lodash, makeStyles, iconsMaterial, ReactDOM, LinearProgress, DoDisturbIcon, Box) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -1994,6 +1994,22 @@
1994
1994
  return true;
1995
1995
  };
1996
1996
 
1997
+ var emptyBaseForecast = {
1998
+ wind: '',
1999
+ visibility: '',
2000
+ weather: {
2001
+ weather1: '',
2002
+ weather2: '',
2003
+ weather3: ''
2004
+ },
2005
+ cloud: {
2006
+ cloud1: '',
2007
+ cloud2: '',
2008
+ cloud3: '',
2009
+ cloud4: ''
2010
+ }
2011
+ }; // formatters
2012
+
1997
2013
  var formatIssueTime = function formatIssueTime(issueDate) {
1998
2014
  return issueDate ? moment__default["default"](issueDate).utc().format('DDHHmm') + "Z" : 'Not issued';
1999
2015
  };
@@ -2218,9 +2234,10 @@
2218
2234
  .filter(function (value) {
2219
2235
  return Object.keys(value).length;
2220
2236
  });
2237
+ var parsedBaseForecast = productToPost.baseForecast && parseFormValues(productToPost.baseForecast, tafStart, tafEnd);
2221
2238
 
2222
2239
  var parsedFormValues = __assign(__assign({}, productToPost), {
2223
- baseForecast: parseFormValues(productToPost.baseForecast, tafStart, tafEnd),
2240
+ baseForecast: parsedBaseForecast,
2224
2241
  changeGroups: parsedChangeGroups
2225
2242
  });
2226
2243
 
@@ -2297,18 +2314,17 @@
2297
2314
  var TAC_MISSING_DATA = 'Missing data: no TAC can be generated';
2298
2315
  var TAC_NOT_AVAILABLE = 'No TAC available';
2299
2316
  var TAC_RETRIEVING_DATA = 'Retrieving TAC';
2300
- var useTACGenerator = function useTACGenerator(taf, requestTAC, standardTAC) {
2301
- if (standardTAC === void 0) {
2302
- standardTAC = '';
2303
- }
2304
-
2317
+ var TAC_FAILED = 'Failed to retrieve TAC';
2318
+ var tacHasError = function tacHasError(tac) {
2319
+ return tac === TAC_MISSING_DATA || tac === TAC_NOT_AVAILABLE || tac === TAC_RETRIEVING_DATA || tac === TAC_FAILED;
2320
+ };
2321
+ var useTACGenerator = function useTACGenerator(taf, requestTAC) {
2305
2322
  var _a = __read(React__default["default"].useState(taf.status === 'NEW' ? TAC_NOT_AVAILABLE : TAC_RETRIEVING_DATA), 2),
2306
2323
  TAC = _a[0],
2307
2324
  setTAC = _a[1];
2308
2325
 
2309
2326
  var isMounted = shared.useIsMounted().isMounted;
2310
-
2311
- var retrieveTAC = function retrieveTAC(tafToPost) {
2327
+ var retrieveTAC = React__default["default"].useCallback(function (tafToPost) {
2312
2328
  if (shouldRetrieveTAC(tafToPost)) {
2313
2329
  requestTAC(tafToPost).then(function (result) {
2314
2330
  if (isMounted.current) {
@@ -2316,25 +2332,19 @@
2316
2332
  }
2317
2333
  })["catch"](function () {
2318
2334
  if (isMounted.current) {
2319
- setTAC('Failed to retrieve TAC');
2335
+ setTAC(TAC_FAILED);
2320
2336
  }
2321
2337
  });
2322
2338
  } else {
2323
2339
  setTAC(TAC_MISSING_DATA);
2324
2340
  }
2325
- };
2326
-
2341
+ }, [isMounted, requestTAC]);
2327
2342
  React__default["default"].useEffect(function () {
2328
- if (taf.status !== 'NEW' && !standardTAC) {
2343
+ if (taf.status !== 'NEW') {
2329
2344
  retrieveTAC(taf);
2330
2345
  } // eslint-disable-next-line react-hooks/exhaustive-deps
2331
2346
 
2332
2347
  }, []);
2333
- React__default["default"].useEffect(function () {
2334
- if (standardTAC !== '') {
2335
- setTAC(standardTAC);
2336
- }
2337
- }, [standardTAC]);
2338
2348
  return [TAC, retrieveTAC];
2339
2349
  };
2340
2350
  var useDragOrder = function useDragOrder(trigger, move, onFormBlur) {
@@ -2484,6 +2494,10 @@
2484
2494
  return 'AMD';
2485
2495
  }
2486
2496
 
2497
+ if (tafAction === 'CANCEL') {
2498
+ return 'CNL';
2499
+ }
2500
+
2487
2501
  return taf.messageType;
2488
2502
  }; // For corrections and amendment we need to add the previousValidStart and End for the TAC converter
2489
2503
 
@@ -2523,13 +2537,43 @@
2523
2537
  var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
2524
2538
  return __assign(__assign(__assign(__assign({}, taf), {
2525
2539
  messageType: getMessageType(taf, tafAction),
2526
- baseForecast: formatFormValues(taf.baseForecast)
2540
+ baseForecast: __assign(__assign({}, emptyBaseForecast), formatFormValues(taf.baseForecast))
2527
2541
  }), taf.changeGroups && {
2528
2542
  changeGroups: taf.changeGroups.map(formatFormValues)
2529
2543
  }), addEmptyChangeGroup && {
2530
2544
  changeGroups: [emptyChangegroup]
2531
2545
  });
2532
2546
  };
2547
+ var getIsFormDefaultDisabled = function getIsFormDefaultDisabled(status) {
2548
+ return !(status === 'NEW' || status === 'DRAFT' || status === 'DRAFT_AMENDED' || status === 'DRAFT_CORRECTED');
2549
+ };
2550
+ var fromStatusToAction = function fromStatusToAction(tafStatus) {
2551
+ switch (tafStatus) {
2552
+ case 'DRAFT':
2553
+ return 'DRAFT';
2554
+
2555
+ case 'DRAFT_AMENDED':
2556
+ return 'DRAFT_AMEND';
2557
+
2558
+ case 'DRAFT_CORRECTED':
2559
+ return 'DRAFT_CORRECT';
2560
+
2561
+ case 'PUBLISHED':
2562
+ return 'PUBLISH';
2563
+
2564
+ case 'AMENDED':
2565
+ return 'AMEND';
2566
+
2567
+ case 'CORRECTED':
2568
+ return 'CORRECT';
2569
+
2570
+ case 'CANCELLED':
2571
+ return 'CANCEL';
2572
+
2573
+ default:
2574
+ return 'NEW';
2575
+ }
2576
+ };
2533
2577
 
2534
2578
  var textFieldStyle = function textFieldStyle(theme) {
2535
2579
  return {
@@ -2879,7 +2923,7 @@
2879
2923
  getValues = _g.getValues,
2880
2924
  trigger = _g.trigger;
2881
2925
 
2882
- var isNotRequiredForAction = shared.useDraftFormHelpers().isRequired; // cross-field required validation
2926
+ var isNotRequiredForAction = shared.useDraftFormHelpers(true).isRequired; // cross-field required validation
2883
2927
 
2884
2928
  var _h = __read(getRequiredCrossFields(fieldNames), 3),
2885
2929
  mainFields = _h[0],
@@ -3308,6 +3352,36 @@
3308
3352
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3309
3353
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
3310
3354
  * */
3355
+ var tafActionToDraftAction = function tafActionToDraftAction(tafAction) {
3356
+ switch (tafAction) {
3357
+ case 'AMEND':
3358
+ case 'DRAFT_AMEND':
3359
+ return 'DRAFT_AMEND';
3360
+
3361
+ case 'CORRECT':
3362
+ case 'DRAFT_CORRECT':
3363
+ return 'DRAFT_CORRECT';
3364
+
3365
+ default:
3366
+ return 'DRAFT';
3367
+ }
3368
+ };
3369
+
3370
+ var tafActionToPublishAction = function tafActionToPublishAction(tafAction) {
3371
+ switch (tafAction) {
3372
+ case 'AMEND':
3373
+ case 'DRAFT_AMEND':
3374
+ return 'AMEND';
3375
+
3376
+ case 'CORRECT':
3377
+ case 'DRAFT_CORRECT':
3378
+ return 'CORRECT';
3379
+
3380
+ default:
3381
+ return 'PUBLISH';
3382
+ }
3383
+ };
3384
+
3311
3385
  var buttonsStyle = {
3312
3386
  button: {
3313
3387
  minWidth: {
@@ -3337,7 +3411,7 @@
3337
3411
  return onTafViewModeButtonPress('CANCEL');
3338
3412
  }
3339
3413
  }, "Cancel"), canBe.includes('CORRECTED') && /*#__PURE__*/React__default["default"].createElement(material.Button, {
3340
- "data-testid": "correctaf",
3414
+ "data-testid": "correcttaf",
3341
3415
  variant: "tertiary",
3342
3416
  onClick: function onClick() {
3343
3417
  return onTafViewModeButtonPress('CORRECT');
@@ -3391,21 +3465,7 @@
3391
3465
  if action DRAFT_AMEND - new status will be DRAFT_AMENDED
3392
3466
  if action DRAFT_CORRECT - new status will be DRAFT_CORRECTED
3393
3467
  */
3394
- switch (tafAction) {
3395
- case 'AMEND':
3396
- case 'DRAFT_AMEND':
3397
- onTafEditModeButtonPress('DRAFT_AMEND');
3398
- break;
3399
-
3400
- case 'CORRECT':
3401
- case 'DRAFT_CORRECT':
3402
- onTafEditModeButtonPress('DRAFT_CORRECT');
3403
- break;
3404
-
3405
- default:
3406
- onTafEditModeButtonPress('DRAFT');
3407
- break;
3408
- }
3468
+ onTafEditModeButtonPress(tafActionToDraftAction(tafAction));
3409
3469
  }
3410
3470
  }, "Save"), /*#__PURE__*/React__default["default"].createElement(material.Button, {
3411
3471
  "data-testid": "publishtaf",
@@ -3418,21 +3478,7 @@
3418
3478
  if action DRAFT_AMEND - new status will be AMENDED
3419
3479
  if action DRAFT_CORRECT - new status will be CORRECTED
3420
3480
  */
3421
- switch (tafAction) {
3422
- case 'AMEND':
3423
- case 'DRAFT_AMEND':
3424
- onTafEditModeButtonPress('AMEND');
3425
- break;
3426
-
3427
- case 'CORRECT':
3428
- case 'DRAFT_CORRECT':
3429
- onTafEditModeButtonPress('CORRECT');
3430
- break;
3431
-
3432
- default:
3433
- onTafEditModeButtonPress('PUBLISH');
3434
- break;
3435
- }
3481
+ onTafEditModeButtonPress(tafActionToPublishAction(tafAction));
3436
3482
  }
3437
3483
  }, "Publish"))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
3438
3484
  item: true,
@@ -3486,140 +3532,22 @@
3486
3532
  }, /*#__PURE__*/React__default["default"].createElement(iconsMaterial.DragIndicator, null));
3487
3533
  };
3488
3534
 
3489
- var ThumbsUp = function ThumbsUp(props) {
3490
- return /*#__PURE__*/React__default["default"].createElement(material.SvgIcon, __assign({
3491
- fontSize: "inherit",
3492
- viewBox: "0 0 58 69"
3493
- }, props), /*#__PURE__*/React__default["default"].createElement("title", null, "Thumbs up"), /*#__PURE__*/React__default["default"].createElement("g", {
3494
- id: "Thumbs-up",
3495
- stroke: "none",
3496
- strokeWidth: "1",
3497
- fill: "none",
3498
- fillRule: "evenodd"
3499
- }, /*#__PURE__*/React__default["default"].createElement("path", {
3500
- d: "M3.99883665,31.7843145 C7.41834232,30.0745617 7.39773108,30.3805485 10.9988366,28.8843145 C14.5999422,27.3880805 16.06167,27.0500418 18.1988366,25.8843145 C19.0904815,25.3979628 19.820202,24.8243341 20.5488366,24.1634286 C20.9845024,23.7682595 22.8819728,21.7794437 23.5488366,20.8277879 C24.2586546,19.8148341 25.1756722,18.5003429 25.9988366,16.8843145 C28.3936103,12.1829184 28.889513,9.4076237 29.8988366,6.88431453 C30.4506375,5.50481234 31.0206747,4.13576029 31.6089482,2.77715837 C31.8562473,2.20602771 32.1648239,1.47549588 32.9988366,0.88431453 C33.2365758,0.715795602 34.0556054,0.253858312 35.0144255,0.0843145301 C36.0262338,-0.0945989315 37.1937102,0.0296108539 37.9980376,0.28431453 C38.7449403,0.520833719 39.4692925,0.860990256 40.1710941,1.30478414 C40.2879689,1.37869154 41.2393256,2.13799569 41.8988366,3.58269657 C42.290748,4.4412034 42.5040976,4.92788584 42.7988366,6.88431453 C42.9953293,8.18860032 43.0453293,9.52193365 42.9488366,10.8843145 C42.947848,11.8251839 42.6645146,13.1585172 42.0988366,14.8843145 C41.9160014,15.4421169 41.6403041,16.2990156 41.2988366,17.1941099 C40.9325633,18.1542284 40.4965053,19.1582935 40.1988366,19.8843145 C39.1594737,22.4193462 37.7498356,25.6900566 37.4561402,26.5124038 C37.2603433,27.0606352 37.1745754,27.6512721 37.1988366,28.2843145 C37.21217,28.4109812 37.2455033,28.5187344 37.2988366,28.6075742 C37.35217,28.6964139 37.45217,28.821994 37.5988366,28.9843145 C38.7401033,28.7100145 39.6802034,28.5266812 40.4191367,28.4343145 C41.6262088,28.2834305 44.7342553,28.0975232 47.4943878,28.1962584 C50.2545202,28.2949937 51.7465936,28.4428269 52.9988366,28.8843145 C53.8336653,29.1786396 54.540332,29.8453063 55.1188366,30.8843145 C55.3507184,31.5616882 55.477385,32.2303996 55.4988366,32.8904489 C55.5202882,33.5504981 55.4369549,34.21512 55.2488366,34.8843145 C54.956044,35.585751 54.5393773,36.1190843 53.9988366,36.4843145 C53.4582959,36.8495447 52.6416293,37.1495447 51.5488366,37.3843145 C51.46217,37.6709812 51.4455033,37.9376479 51.4988366,38.1843145 C51.55217,38.4309812 51.7188366,38.5976479 51.9988366,38.6843145 C53.0027645,38.7154727 53.6750204,38.7821393 54.0156044,38.8843145 C54.7031375,39.0905745 55.3642149,39.4239078 55.9988366,39.8843145 C56.4980387,40.3674862 56.831372,40.7202741 56.9988366,40.9426784 C57.2459451,41.2708552 57.8988366,42.3863253 57.8988366,43.8843145 C57.8988366,44.882974 57.53217,45.882974 56.7988366,46.8843145 C56.4100652,47.2645006 55.9767318,47.5818962 55.4988366,47.8365013 C55.0209415,48.0911064 54.5157721,48.2737108 53.9833285,48.3843145 L52.6988366,48.3843145 C52.2988366,48.6576479 52.0988366,48.9643145 52.0988366,49.3043145 C52.0988366,49.6443145 52.1655033,49.9376479 52.2988366,50.1843145 L53.4440689,50.6343145 C54.0486381,50.9097065 54.566894,51.3263732 54.9988366,51.8843145 C55.2403033,52.1962176 55.7126861,53.1830494 55.7488366,53.8843145 C55.7849872,54.5855797 55.7892838,54.8412841 55.675362,55.3021772 C55.5409724,55.8458769 55.3321306,56.373256 54.9488366,56.8843145 C54.6880408,57.2320423 54.3421972,57.542124 54.0113058,57.8145598 C53.720974,58.0536013 53.0623839,58.3923099 52.0355354,58.6843145 C51.8426264,58.739172 51.4970601,58.8058387 50.9988366,58.8843145 L49.2488366,58.9843145 C48.96217,59.1509812 48.7955033,59.3509812 48.7488366,59.5843145 C48.70217,59.8176479 48.7855033,60.0643145 48.9988366,60.3243145 L50.0168579,60.6843145 C51.0110333,61.2176479 51.5216929,61.9496429 51.5488366,62.8802998 C51.5895523,64.276285 51.475285,65.4556464 50.0016466,66.7843145 C49.4876586,67.2477386 48.8545536,67.4912052 48.1023318,67.7343145 C47.6452927,67.8820242 46.8607943,68.0486909 45.7488366,68.2343145 L40.0010327,68.6843145 C38.1462353,68.7443145 36.81217,68.7776479 35.9988366,68.7843145 C34.7788366,68.7943145 28.6377735,68.7414839 25.3910307,68.5132824 C22.1442879,68.2850808 21.4236621,68.1168902 18.9258088,67.5843145 C16.4279556,67.0517389 16.0894589,66.9976619 13.9988366,66.0843145 C12.6050885,65.4754163 11.2717551,64.6754163 9.99883665,63.6843145 L5.99912679,59.8445931 C5.6005732,59.505994 5.13964906,59.1744645 4.61635438,58.8500046 C3.83141237,58.3633147 3.44878136,58.2942773 2.99883665,57.9843145 C2.44718062,57.6042838 2.05635486,57.1737105 1.71932092,56.7662516 C1.30382099,56.2639309 0.723401214,54.7703696 0.498836646,53.8721113 C0.239479861,52.8346842 0.182966814,51.4491222 0.134208514,50.425802 C0.00166588165,47.644049 0.0975252306,47.2982714 0.0687602378,44.8458357 C0.0452570713,42.8420109 -0.0277106081,40.4082829 0.0112302522,39.9409643 C0.224109489,37.3862585 0.450803729,36.3915418 0.898836646,34.8843145 C1.09883665,34.2114947 1.78104521,33.1945675 2.17275045,32.889441 C2.5644557,32.5843145 3.13875358,32.2143561 3.99883665,31.7843145 Z",
3501
- id: "Path-2",
3502
- fill: "#FFBF00"
3503
- }), /*#__PURE__*/React__default["default"].createElement("path", {
3504
- d: "M37.1988366,28.2843145 C36.6491114,28.3570112 36.2566531,28.4236779 36.0214618,28.4843145 C35.0603746,28.7321005 34.3937143,29.0314706 34.021481,29.207818 C33.777778,29.3232735 32.5285093,30.04554 31.6988366,30.8956082 C31.0356177,31.5751308 30.7670551,32.3363186 30.5620165,32.9344937 C29.9561734,34.7019667 30.4904911,36.5989836 30.5988366,36.8981554 C30.8174274,37.5017447 31.0945063,37.9694877 31.2988366,38.4843145 C31.4064264,38.7553957 31.4498365,39.7521385 31.3985954,40.9130014 C31.388536,41.1408948 31.3995111,42.8738523 30.5816296,45.1307691 C30.125032,46.3907349 29.4940749,47.743868 28.6988366,48.906031 C27.6082165,50.4998658 26.3589437,51.7345157 26.1988366,51.8770596 C25.2520649,52.7199732 23.8988366,53.516454 23.3777374,54.1031009 C22.8566381,54.6897478 22.8988366,54.7174426 22.8988366,54.8843145 C22.8988366,55.0643438 22.9342857,55.2139882 23.0063234,55.32641 C23.2544011,55.7135594 23.9363916,55.6592779 25.0988366,54.8843145 C25.8683088,54.3713331 26.8213311,53.5952018 27.5988366,52.8259025 C28.3369913,52.0955388 28.9092218,51.3713331 29.2988366,50.8843145 C29.6096134,50.4958436 30.1890589,49.8244169 30.7488366,48.8700346 C31.0160857,48.4143934 31.4327524,47.5858201 31.9988366,46.3843145 C31.9988366,46.7176479 32.33217,47.2176479 32.9988366,47.8843145 C33.1686748,48.0541527 33.5020081,48.3041527 33.9988366,48.6343145 C33.535822,48.6343145 33.2024887,48.6676479 32.9988366,48.7343145 C31.9774176,49.1343145 31.4345654,49.3440777 30.8488366,49.8843145 C30.1709576,50.5095446 29.6310297,51.1756019 29.3988366,52.3843145 C29.1722814,53.5636787 29.3142136,54.632966 29.6488366,55.5921767 C29.928312,56.3933044 30.3156141,57.1176481 30.9865396,57.7652076 C31.1856402,57.9573742 31.5230725,58.2304098 31.9988366,58.5843145 C30.2988366,59.4509812 29.4488366,60.8843145 29.4488366,62.8843145 C29.4488366,65.8843145 31.4988366,68.7843145 35.9988366,68.7843145 C37.2162866,68.7843145 38.5382158,68.7607397 39.9988366,68.6843145 C41.1579568,68.623665 43.0746234,68.473665 45.7488366,68.2343145 C42.81999,68.0652276 40.9033233,67.948561 39.9988366,67.8843145 C38.4397862,67.7735739 34.9576244,67.4218793 34.5109642,67.2843145 C33.8898949,67.0930342 33.3876529,66.66767 32.9988366,66.3843145 C31.7988366,65.509797 31.6488366,63.8668327 31.6488366,63.3843145 C31.6488366,62.6767971 32.115551,61.4820497 32.7124803,60.9291427 C33.2967248,60.387985 34.101504,59.9827037 34.9988366,59.8343145 C36.8129843,59.5343145 37.8279851,59.6343145 38.9968712,59.6343145 C41.8836014,59.6343145 46.4559662,59.9063364 47.0327603,59.9503801 C47.6352731,59.9963876 48.2906319,60.1194654 48.9988366,60.3196132 C48.7881139,60.0647262 48.7047806,59.8196266 48.7488366,59.5843145 C48.7928927,59.3490025 48.9595594,59.1490025 49.2488366,58.9843145 C41.7042463,58.5910176 37.2875796,58.2576842 35.9988366,57.9843145 C34.0657222,57.57426 33.0783849,56.5232188 32.4988366,55.3843145 C32.1808463,54.7594131 31.9988366,54.0680377 32.1988366,52.8843145 C32.4054546,51.661422 33.0758788,51.154421 33.9988366,50.7343145 C35.0343809,50.2629616 36.2160776,50.213626 38.0168693,50.1343145 C41.4226671,49.9843145 41.9988366,49.8715355 44.9988366,49.8843145 C47.4322993,49.8928339 49.8656327,49.9928339 52.2988366,50.1843145 C52.1655033,49.9452767 52.0988366,49.6535253 52.0988366,49.3090604 C52.0988366,48.9645954 52.2988366,48.6563468 52.6988366,48.3843145 C49.4970675,48.4374708 47.2644784,48.4840975 46.0010696,48.5241946 C42.8267531,48.6249387 40.1650305,48.7843145 38.0159019,48.6090596 C36.5073153,48.3843145 35.5349602,47.7454709 35.0988366,47.3586886 C33.5267511,45.9644623 33.6909724,44.1458838 33.6988366,43.902953 C33.7490538,42.3517256 34.2594453,41.6540102 34.9988366,41.2843145 C36.9988366,40.2843145 38.521019,40.3843145 40.9988366,39.8843145 L51.9988366,38.6843145 C51.7847588,38.5992008 51.6347588,38.4325341 51.5488366,38.1843145 C51.4629145,37.9360949 51.4629145,37.6694283 51.5488366,37.3843145 C48.6830402,37.6590904 46.693269,37.8590904 45.579523,37.9843145 C44.2653604,38.1320725 42.7384649,38.3154059 40.9988366,38.5343145 C38.9988366,38.6009812 37.6749072,38.5733169 37.0270482,38.4513217 C35.0988366,38.2216852 33.4888366,37.4843145 33.4388366,34.8545872 C33.3888366,32.7744565 33.7430954,32.2207578 33.8988366,31.9295788 C34.3117653,31.1575537 34.9128559,30.575799 35.3988366,30.1843145 C36.0681111,29.6451768 36.8014444,29.2451768 37.5988366,28.9843145 C37.4503711,28.8228789 37.3503711,28.6970685 37.2988366,28.6068833 C37.2473022,28.516698 37.2139689,28.4091751 37.1988366,28.2843145 Z",
3505
- id: "Path",
3506
- fill: "#F28700"
3507
- })));
3508
- };
3509
-
3510
- var getPaneTitle = function getPaneTitle(sumOfErrors) {
3511
- switch (sumOfErrors) {
3512
- case 0:
3513
- return 'Looks good';
3514
-
3515
- case 1:
3516
- return 'There is an issue to address';
3517
-
3518
- default:
3519
- return 'There are a few issues to address';
3520
- }
3521
- };
3522
-
3523
- var getErrorDefaultMessage = function getErrorDefaultMessage(error) {
3524
- switch (error.type) {
3525
- case 'required':
3526
- {
3527
- return 'this field is required';
3528
- }
3529
-
3530
- default:
3531
- {
3532
- return error.message;
3533
- }
3534
- }
3535
- };
3536
-
3537
- var capitalizeWord = function capitalizeWord(_a) {
3538
- var _b = __read(_a),
3539
- firstLetter = _b[0],
3540
- restOfWord = _b.slice(1);
3541
-
3542
- return firstLetter.toUpperCase() + restOfWord.join('');
3543
- };
3544
- var humanizeErrorMessage = function humanizeErrorMessage(nameAsString) {
3545
- var nameWithoutBrackets = nameAsString.replace(/[[\]']+/g, '');
3546
- var nameLowerCase = nameWithoutBrackets.toLowerCase();
3547
-
3548
- var _a = __read(nameLowerCase.split(/([0-9]+)/) // split num bers from field and build array
3549
- .filter(function (s) {
3550
- return s.length;
3551
- }), 2),
3552
- fieldName = _a[0],
3553
- fieldNumberedValue = _a[1];
3554
-
3555
- var nameCapitalized = capitalizeWord(fieldName);
3556
-
3557
- if (fieldNumberedValue) {
3558
- // when name contains a number we assume it's a formgroup and we add a index +1 for human readability
3559
- var fieldNumber = parseInt(fieldNumberedValue, 10) + 1;
3560
- return nameCapitalized + " " + fieldNumber;
3561
- }
3562
-
3563
- return nameCapitalized;
3564
- };
3565
- var getErrorMessage = function getErrorMessage(error, index) {
3566
- var name = error.ref.name;
3567
-
3568
- var _a = __read(name.split('.'), 1),
3569
- firstNamePart = _a[0];
3570
-
3571
- var fieldErrorTitle = humanizeErrorMessage(firstNamePart);
3572
- return index + 1 + ". " + fieldErrorTitle + ": " + getErrorDefaultMessage(error);
3573
- };
3574
- var MODAL_DIALOG_ELEMENT = 'modal-dialog';
3575
-
3576
- var IssuesPane = function IssuesPane(_a) {
3577
- var isOpen = _a.isOpen,
3578
- handleClose = _a.handleClose,
3579
- _b = _a.errorList,
3580
- errorList = _b === void 0 ? [] : _b,
3581
- _c = _a.startPosition,
3582
- startPosition = _c === void 0 ? {
3583
- left: 20,
3584
- top: 50
3585
- } : _c;
3586
- var rootElement = document.getElementById(MODAL_DIALOG_ELEMENT) || document.body;
3587
- return /*#__PURE__*/ReactDOM__default["default"].createPortal( /*#__PURE__*/React__namespace.createElement(shared.ToolContainerDraggable, {
3588
- startSize: {
3589
- width: '577px',
3590
- height: '200px'
3591
- },
3592
- startPosition: startPosition,
3593
- minWidth: 300,
3594
- onClose: handleClose,
3595
- title: getPaneTitle(errorList.length),
3596
- headerSize: "xs",
3597
- isOpen: isOpen,
3598
- "data-testid": "moveable-issues-pane",
3599
- bounds: "parent"
3600
- }, /*#__PURE__*/React__namespace.createElement(material.Box, {
3601
- component: "div",
3602
- sx: {
3603
- marginTop: '16px',
3604
- marginLeft: '24px'
3605
- }
3606
- }, errorList.length === 0 && /*#__PURE__*/React__namespace.createElement(material.Box, {
3607
- component: "div",
3608
- sx: {
3609
- fontSize: '4rem'
3610
- },
3611
- "data-testid": "zeroIssuesImage"
3612
- }, /*#__PURE__*/React__namespace.createElement(ThumbsUp, null)), errorList.length > 0 && errorList.map(function (error, index) {
3613
- return /*#__PURE__*/React__namespace.createElement(material.Typography // eslint-disable-next-line react/no-array-index-key
3614
- , {
3615
- // eslint-disable-next-line react/no-array-index-key
3616
- key: "message-" + index,
3617
- variant: "body1",
3618
- "data-testid": "errorMessage"
3619
- }, getErrorMessage(error, index));
3620
- }))), rootElement);
3621
- };
3622
-
3535
+ /* *
3536
+ * Licensed under the Apache License, Version 2.0 (the "License");
3537
+ * you may not use this file except in compliance with the License.
3538
+ * You may obtain a copy of the License at
3539
+ *
3540
+ * http://www.apache.org/licenses/LICENSE-2.0
3541
+ *
3542
+ * Unless required by applicable law or agreed to in writing, software
3543
+ * distributed under the License is distributed on an "AS IS" BASIS,
3544
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3545
+ * See the License for the specific language governing permissions and
3546
+ * limitations under the License.
3547
+ *
3548
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3549
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
3550
+ * */
3623
3551
  var getCustomError = function getCustomError(error) {
3624
3552
  var name = error.ref.name;
3625
3553
  var isChangeGroup = name.includes('changeGroups');
@@ -3630,7 +3558,6 @@
3630
3558
  row: row
3631
3559
  });
3632
3560
  };
3633
-
3634
3561
  var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
3635
3562
  switch (sumOfErrors) {
3636
3563
  case 0:
@@ -3677,7 +3604,6 @@
3677
3604
  return list.concat(error);
3678
3605
  }, []);
3679
3606
  };
3680
-
3681
3607
  var getErrors = function getErrors(errors) {
3682
3608
  var errorList = Object.keys(errors).reduce(function (list, key) {
3683
3609
  var errorValue = errors[key];
@@ -3694,29 +3620,41 @@
3694
3620
  return errorList;
3695
3621
  };
3696
3622
 
3623
+ /* *
3624
+ * Licensed under the Apache License, Version 2.0 (the "License");
3625
+ * you may not use this file except in compliance with the License.
3626
+ * You may obtain a copy of the License at
3627
+ *
3628
+ * http://www.apache.org/licenses/LICENSE-2.0
3629
+ *
3630
+ * Unless required by applicable law or agreed to in writing, software
3631
+ * distributed under the License is distributed on an "AS IS" BASIS,
3632
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3633
+ * See the License for the specific language governing permissions and
3634
+ * limitations under the License.
3635
+ *
3636
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3637
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
3638
+ * */
3639
+
3697
3640
  var IssuesButton = function IssuesButton(_a) {
3698
3641
  var _b = _a.errors,
3699
- errors = _b === void 0 ? {} : _b;
3642
+ errors = _b === void 0 ? {} : _b,
3643
+ _c = _a.isIssuesPaneOpen,
3644
+ isIssuesPaneOpen = _c === void 0 ? false : _c,
3645
+ _d = _a.setIsIssuesPaneOpen,
3646
+ setIsIssuesPaneOpen = _d === void 0 ? function () {
3647
+ return null;
3648
+ } : _d;
3700
3649
  var errorList = filterDuplicateErrors(getErrors(errors));
3701
3650
  var totalErrors = errorList.length;
3702
3651
  var errorStatus = totalErrors > 0 ? 'error' : 'success';
3703
3652
  var buttonColor = "geowebColors.functional." + errorStatus;
3704
3653
 
3705
- var _c = __read(React__namespace.useState(false), 2),
3706
- isIssuesPaneOpen = _c[0],
3707
- setIsIssuesPaneOpen = _c[1];
3708
-
3709
- var toggleIssuesPane = function toggleIssuesPane() {
3710
- return setIsIssuesPaneOpen(!isIssuesPaneOpen);
3654
+ var toggleIssuesPane = function toggleIssuesPane(newPosition) {
3655
+ return setIsIssuesPaneOpen(!isIssuesPaneOpen, newPosition);
3711
3656
  };
3712
3657
 
3713
- var _d = __read(React__namespace.useState({
3714
- left: 0,
3715
- top: 0
3716
- }), 2),
3717
- startPosition = _d[0],
3718
- setStartPosition = _d[1];
3719
-
3720
3658
  var onClickButton = function onClickButton(event) {
3721
3659
  var _a;
3722
3660
 
@@ -3732,11 +3670,10 @@
3732
3670
  left: left - parentOffset.left + 100,
3733
3671
  top: top - parentOffset.top
3734
3672
  };
3735
- setStartPosition(newPosition);
3736
- toggleIssuesPane();
3673
+ toggleIssuesPane(newPosition);
3737
3674
  };
3738
3675
 
3739
- return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
3676
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
3740
3677
  title: "View details"
3741
3678
  }, /*#__PURE__*/React__namespace.createElement(material.Chip, {
3742
3679
  "data-testid": "issuesButton",
@@ -3756,68 +3693,279 @@
3756
3693
  },
3757
3694
  fontSize: 12
3758
3695
  }
3759
- })), /*#__PURE__*/React__namespace.createElement(IssuesPane, {
3760
- errorList: errorList,
3761
- handleClose: toggleIssuesPane,
3762
- isOpen: isIssuesPaneOpen,
3763
- startPosition: startPosition
3764
3696
  }));
3765
3697
  };
3766
3698
 
3767
- var noop = function noop() {};
3699
+ var ThumbsUp = function ThumbsUp(props) {
3700
+ return /*#__PURE__*/React__default["default"].createElement(material.SvgIcon, __assign({
3701
+ fontSize: "inherit",
3702
+ viewBox: "0 0 58 69"
3703
+ }, props), /*#__PURE__*/React__default["default"].createElement("title", null, "Thumbs up"), /*#__PURE__*/React__default["default"].createElement("g", {
3704
+ id: "Thumbs-up",
3705
+ stroke: "none",
3706
+ strokeWidth: "1",
3707
+ fill: "none",
3708
+ fillRule: "evenodd"
3709
+ }, /*#__PURE__*/React__default["default"].createElement("path", {
3710
+ d: "M3.99883665,31.7843145 C7.41834232,30.0745617 7.39773108,30.3805485 10.9988366,28.8843145 C14.5999422,27.3880805 16.06167,27.0500418 18.1988366,25.8843145 C19.0904815,25.3979628 19.820202,24.8243341 20.5488366,24.1634286 C20.9845024,23.7682595 22.8819728,21.7794437 23.5488366,20.8277879 C24.2586546,19.8148341 25.1756722,18.5003429 25.9988366,16.8843145 C28.3936103,12.1829184 28.889513,9.4076237 29.8988366,6.88431453 C30.4506375,5.50481234 31.0206747,4.13576029 31.6089482,2.77715837 C31.8562473,2.20602771 32.1648239,1.47549588 32.9988366,0.88431453 C33.2365758,0.715795602 34.0556054,0.253858312 35.0144255,0.0843145301 C36.0262338,-0.0945989315 37.1937102,0.0296108539 37.9980376,0.28431453 C38.7449403,0.520833719 39.4692925,0.860990256 40.1710941,1.30478414 C40.2879689,1.37869154 41.2393256,2.13799569 41.8988366,3.58269657 C42.290748,4.4412034 42.5040976,4.92788584 42.7988366,6.88431453 C42.9953293,8.18860032 43.0453293,9.52193365 42.9488366,10.8843145 C42.947848,11.8251839 42.6645146,13.1585172 42.0988366,14.8843145 C41.9160014,15.4421169 41.6403041,16.2990156 41.2988366,17.1941099 C40.9325633,18.1542284 40.4965053,19.1582935 40.1988366,19.8843145 C39.1594737,22.4193462 37.7498356,25.6900566 37.4561402,26.5124038 C37.2603433,27.0606352 37.1745754,27.6512721 37.1988366,28.2843145 C37.21217,28.4109812 37.2455033,28.5187344 37.2988366,28.6075742 C37.35217,28.6964139 37.45217,28.821994 37.5988366,28.9843145 C38.7401033,28.7100145 39.6802034,28.5266812 40.4191367,28.4343145 C41.6262088,28.2834305 44.7342553,28.0975232 47.4943878,28.1962584 C50.2545202,28.2949937 51.7465936,28.4428269 52.9988366,28.8843145 C53.8336653,29.1786396 54.540332,29.8453063 55.1188366,30.8843145 C55.3507184,31.5616882 55.477385,32.2303996 55.4988366,32.8904489 C55.5202882,33.5504981 55.4369549,34.21512 55.2488366,34.8843145 C54.956044,35.585751 54.5393773,36.1190843 53.9988366,36.4843145 C53.4582959,36.8495447 52.6416293,37.1495447 51.5488366,37.3843145 C51.46217,37.6709812 51.4455033,37.9376479 51.4988366,38.1843145 C51.55217,38.4309812 51.7188366,38.5976479 51.9988366,38.6843145 C53.0027645,38.7154727 53.6750204,38.7821393 54.0156044,38.8843145 C54.7031375,39.0905745 55.3642149,39.4239078 55.9988366,39.8843145 C56.4980387,40.3674862 56.831372,40.7202741 56.9988366,40.9426784 C57.2459451,41.2708552 57.8988366,42.3863253 57.8988366,43.8843145 C57.8988366,44.882974 57.53217,45.882974 56.7988366,46.8843145 C56.4100652,47.2645006 55.9767318,47.5818962 55.4988366,47.8365013 C55.0209415,48.0911064 54.5157721,48.2737108 53.9833285,48.3843145 L52.6988366,48.3843145 C52.2988366,48.6576479 52.0988366,48.9643145 52.0988366,49.3043145 C52.0988366,49.6443145 52.1655033,49.9376479 52.2988366,50.1843145 L53.4440689,50.6343145 C54.0486381,50.9097065 54.566894,51.3263732 54.9988366,51.8843145 C55.2403033,52.1962176 55.7126861,53.1830494 55.7488366,53.8843145 C55.7849872,54.5855797 55.7892838,54.8412841 55.675362,55.3021772 C55.5409724,55.8458769 55.3321306,56.373256 54.9488366,56.8843145 C54.6880408,57.2320423 54.3421972,57.542124 54.0113058,57.8145598 C53.720974,58.0536013 53.0623839,58.3923099 52.0355354,58.6843145 C51.8426264,58.739172 51.4970601,58.8058387 50.9988366,58.8843145 L49.2488366,58.9843145 C48.96217,59.1509812 48.7955033,59.3509812 48.7488366,59.5843145 C48.70217,59.8176479 48.7855033,60.0643145 48.9988366,60.3243145 L50.0168579,60.6843145 C51.0110333,61.2176479 51.5216929,61.9496429 51.5488366,62.8802998 C51.5895523,64.276285 51.475285,65.4556464 50.0016466,66.7843145 C49.4876586,67.2477386 48.8545536,67.4912052 48.1023318,67.7343145 C47.6452927,67.8820242 46.8607943,68.0486909 45.7488366,68.2343145 L40.0010327,68.6843145 C38.1462353,68.7443145 36.81217,68.7776479 35.9988366,68.7843145 C34.7788366,68.7943145 28.6377735,68.7414839 25.3910307,68.5132824 C22.1442879,68.2850808 21.4236621,68.1168902 18.9258088,67.5843145 C16.4279556,67.0517389 16.0894589,66.9976619 13.9988366,66.0843145 C12.6050885,65.4754163 11.2717551,64.6754163 9.99883665,63.6843145 L5.99912679,59.8445931 C5.6005732,59.505994 5.13964906,59.1744645 4.61635438,58.8500046 C3.83141237,58.3633147 3.44878136,58.2942773 2.99883665,57.9843145 C2.44718062,57.6042838 2.05635486,57.1737105 1.71932092,56.7662516 C1.30382099,56.2639309 0.723401214,54.7703696 0.498836646,53.8721113 C0.239479861,52.8346842 0.182966814,51.4491222 0.134208514,50.425802 C0.00166588165,47.644049 0.0975252306,47.2982714 0.0687602378,44.8458357 C0.0452570713,42.8420109 -0.0277106081,40.4082829 0.0112302522,39.9409643 C0.224109489,37.3862585 0.450803729,36.3915418 0.898836646,34.8843145 C1.09883665,34.2114947 1.78104521,33.1945675 2.17275045,32.889441 C2.5644557,32.5843145 3.13875358,32.2143561 3.99883665,31.7843145 Z",
3711
+ id: "Path-2",
3712
+ fill: "#FFBF00"
3713
+ }), /*#__PURE__*/React__default["default"].createElement("path", {
3714
+ d: "M37.1988366,28.2843145 C36.6491114,28.3570112 36.2566531,28.4236779 36.0214618,28.4843145 C35.0603746,28.7321005 34.3937143,29.0314706 34.021481,29.207818 C33.777778,29.3232735 32.5285093,30.04554 31.6988366,30.8956082 C31.0356177,31.5751308 30.7670551,32.3363186 30.5620165,32.9344937 C29.9561734,34.7019667 30.4904911,36.5989836 30.5988366,36.8981554 C30.8174274,37.5017447 31.0945063,37.9694877 31.2988366,38.4843145 C31.4064264,38.7553957 31.4498365,39.7521385 31.3985954,40.9130014 C31.388536,41.1408948 31.3995111,42.8738523 30.5816296,45.1307691 C30.125032,46.3907349 29.4940749,47.743868 28.6988366,48.906031 C27.6082165,50.4998658 26.3589437,51.7345157 26.1988366,51.8770596 C25.2520649,52.7199732 23.8988366,53.516454 23.3777374,54.1031009 C22.8566381,54.6897478 22.8988366,54.7174426 22.8988366,54.8843145 C22.8988366,55.0643438 22.9342857,55.2139882 23.0063234,55.32641 C23.2544011,55.7135594 23.9363916,55.6592779 25.0988366,54.8843145 C25.8683088,54.3713331 26.8213311,53.5952018 27.5988366,52.8259025 C28.3369913,52.0955388 28.9092218,51.3713331 29.2988366,50.8843145 C29.6096134,50.4958436 30.1890589,49.8244169 30.7488366,48.8700346 C31.0160857,48.4143934 31.4327524,47.5858201 31.9988366,46.3843145 C31.9988366,46.7176479 32.33217,47.2176479 32.9988366,47.8843145 C33.1686748,48.0541527 33.5020081,48.3041527 33.9988366,48.6343145 C33.535822,48.6343145 33.2024887,48.6676479 32.9988366,48.7343145 C31.9774176,49.1343145 31.4345654,49.3440777 30.8488366,49.8843145 C30.1709576,50.5095446 29.6310297,51.1756019 29.3988366,52.3843145 C29.1722814,53.5636787 29.3142136,54.632966 29.6488366,55.5921767 C29.928312,56.3933044 30.3156141,57.1176481 30.9865396,57.7652076 C31.1856402,57.9573742 31.5230725,58.2304098 31.9988366,58.5843145 C30.2988366,59.4509812 29.4488366,60.8843145 29.4488366,62.8843145 C29.4488366,65.8843145 31.4988366,68.7843145 35.9988366,68.7843145 C37.2162866,68.7843145 38.5382158,68.7607397 39.9988366,68.6843145 C41.1579568,68.623665 43.0746234,68.473665 45.7488366,68.2343145 C42.81999,68.0652276 40.9033233,67.948561 39.9988366,67.8843145 C38.4397862,67.7735739 34.9576244,67.4218793 34.5109642,67.2843145 C33.8898949,67.0930342 33.3876529,66.66767 32.9988366,66.3843145 C31.7988366,65.509797 31.6488366,63.8668327 31.6488366,63.3843145 C31.6488366,62.6767971 32.115551,61.4820497 32.7124803,60.9291427 C33.2967248,60.387985 34.101504,59.9827037 34.9988366,59.8343145 C36.8129843,59.5343145 37.8279851,59.6343145 38.9968712,59.6343145 C41.8836014,59.6343145 46.4559662,59.9063364 47.0327603,59.9503801 C47.6352731,59.9963876 48.2906319,60.1194654 48.9988366,60.3196132 C48.7881139,60.0647262 48.7047806,59.8196266 48.7488366,59.5843145 C48.7928927,59.3490025 48.9595594,59.1490025 49.2488366,58.9843145 C41.7042463,58.5910176 37.2875796,58.2576842 35.9988366,57.9843145 C34.0657222,57.57426 33.0783849,56.5232188 32.4988366,55.3843145 C32.1808463,54.7594131 31.9988366,54.0680377 32.1988366,52.8843145 C32.4054546,51.661422 33.0758788,51.154421 33.9988366,50.7343145 C35.0343809,50.2629616 36.2160776,50.213626 38.0168693,50.1343145 C41.4226671,49.9843145 41.9988366,49.8715355 44.9988366,49.8843145 C47.4322993,49.8928339 49.8656327,49.9928339 52.2988366,50.1843145 C52.1655033,49.9452767 52.0988366,49.6535253 52.0988366,49.3090604 C52.0988366,48.9645954 52.2988366,48.6563468 52.6988366,48.3843145 C49.4970675,48.4374708 47.2644784,48.4840975 46.0010696,48.5241946 C42.8267531,48.6249387 40.1650305,48.7843145 38.0159019,48.6090596 C36.5073153,48.3843145 35.5349602,47.7454709 35.0988366,47.3586886 C33.5267511,45.9644623 33.6909724,44.1458838 33.6988366,43.902953 C33.7490538,42.3517256 34.2594453,41.6540102 34.9988366,41.2843145 C36.9988366,40.2843145 38.521019,40.3843145 40.9988366,39.8843145 L51.9988366,38.6843145 C51.7847588,38.5992008 51.6347588,38.4325341 51.5488366,38.1843145 C51.4629145,37.9360949 51.4629145,37.6694283 51.5488366,37.3843145 C48.6830402,37.6590904 46.693269,37.8590904 45.579523,37.9843145 C44.2653604,38.1320725 42.7384649,38.3154059 40.9988366,38.5343145 C38.9988366,38.6009812 37.6749072,38.5733169 37.0270482,38.4513217 C35.0988366,38.2216852 33.4888366,37.4843145 33.4388366,34.8545872 C33.3888366,32.7744565 33.7430954,32.2207578 33.8988366,31.9295788 C34.3117653,31.1575537 34.9128559,30.575799 35.3988366,30.1843145 C36.0681111,29.6451768 36.8014444,29.2451768 37.5988366,28.9843145 C37.4503711,28.8228789 37.3503711,28.6970685 37.2988366,28.6068833 C37.2473022,28.516698 37.2139689,28.4091751 37.1988366,28.2843145 Z",
3715
+ id: "Path",
3716
+ fill: "#F28700"
3717
+ })));
3718
+ };
3768
3719
 
3769
- var TafForm = function TafForm(_a) {
3770
- var // can be removed after old TAF is gone
3771
- defaultTafAction = _a.tafAction,
3772
- isDefaultDisabled = _a.isDisabled,
3773
- _b = _a.staticTAC,
3774
- staticTAC = _b === void 0 ? '' : _b,
3775
- tafFromBackend = _a.tafFromBackend,
3776
- _c = _a.onFormAction,
3777
- onFormAction = _c === void 0 ? function () {
3778
- return null;
3779
- } : _c;
3780
- var originalTaf = tafFromBackend.taf;
3720
+ var getPaneTitle = function getPaneTitle(sumOfErrors) {
3721
+ switch (sumOfErrors) {
3722
+ case 0:
3723
+ return 'Looks good';
3724
+
3725
+ case 1:
3726
+ return 'There is an issue to address';
3727
+
3728
+ default:
3729
+ return 'There are a few issues to address';
3730
+ }
3731
+ };
3732
+
3733
+ var capitalizeWord = function capitalizeWord(_a) {
3734
+ var _b = __read(_a),
3735
+ firstLetter = _b[0],
3736
+ restOfWord = _b.slice(1);
3737
+
3738
+ return firstLetter.toUpperCase() + restOfWord.join('');
3739
+ };
3740
+ var humanizeErrorMessage = function humanizeErrorMessage(nameAsString) {
3741
+ var nameWithoutBrackets = nameAsString.replace(/[[\]']+/g, '');
3742
+ var nameLowerCase = nameWithoutBrackets.toLowerCase();
3743
+
3744
+ var _a = __read(nameLowerCase.split(/([0-9]+)/) // split num bers from field and build array
3745
+ .filter(function (s) {
3746
+ return s.length;
3747
+ }), 2),
3748
+ fieldName = _a[0],
3749
+ fieldNumberedValue = _a[1];
3750
+
3751
+ var nameCapitalized = capitalizeWord(fieldName);
3752
+
3753
+ if (fieldNumberedValue) {
3754
+ // when name contains a number we assume it's a formgroup and we add a index +1 for human readability
3755
+ var fieldNumber = parseInt(fieldNumberedValue, 10) + 1;
3756
+ return nameCapitalized + " " + fieldNumber;
3757
+ }
3758
+
3759
+ return nameCapitalized;
3760
+ };
3761
+ var getErrorMessage = function getErrorMessage(error, index) {
3762
+ var name = error.ref.name;
3763
+
3764
+ var _a = __read(name.split('.'), 1),
3765
+ firstNamePart = _a[0];
3766
+
3767
+ var fieldErrorTitle = humanizeErrorMessage(firstNamePart);
3768
+ return index + 1 + ". " + fieldErrorTitle + ": " + error.message;
3769
+ };
3770
+ var MODAL_DIALOG_ELEMENT = 'modal-dialog';
3771
+ var useIssuesPane = function useIssuesPane() {
3772
+ var _a = __read(React__namespace.useState(false), 2),
3773
+ isIssuesPaneOpen = _a[0],
3774
+ setIsIssuesPaneOpen = _a[1];
3775
+
3776
+ var _b = __read(React__namespace.useState(null), 2),
3777
+ startPosition = _b[0],
3778
+ setStartPosition = _b[1];
3779
+
3780
+ var onToggleIssuesPane = function onToggleIssuesPane(isOpen, newPosition) {
3781
+ if (!startPosition) {
3782
+ setStartPosition(newPosition);
3783
+ }
3784
+
3785
+ setIsIssuesPaneOpen(isOpen);
3786
+ };
3787
+
3788
+ var onCloseIssuesPane = function onCloseIssuesPane() {
3789
+ return setIsIssuesPaneOpen(false);
3790
+ };
3791
+
3792
+ return {
3793
+ isIssuesPaneOpen: isIssuesPaneOpen,
3794
+ startPosition: startPosition,
3795
+ onToggleIssuesPane: onToggleIssuesPane,
3796
+ onCloseIssuesPane: onCloseIssuesPane
3797
+ };
3798
+ };
3799
+
3800
+ var IssuesPane = function IssuesPane(_a) {
3801
+ var _b = _a.errorList,
3802
+ errorList = _b === void 0 ? [] : _b,
3803
+ isOpen = _a.isOpen,
3804
+ handleClose = _a.handleClose,
3805
+ _c = _a.startPosition,
3806
+ startPosition = _c === void 0 ? {
3807
+ left: 20,
3808
+ top: 50
3809
+ } : _c;
3810
+ var rootElement = document.getElementById(MODAL_DIALOG_ELEMENT) || document.body;
3811
+ return /*#__PURE__*/ReactDOM__default["default"].createPortal( /*#__PURE__*/React__namespace.createElement(shared.ToolContainerDraggable, {
3812
+ startSize: {
3813
+ width: '577px',
3814
+ height: '200px'
3815
+ },
3816
+ startPosition: startPosition,
3817
+ minWidth: 300,
3818
+ onClose: handleClose,
3819
+ title: getPaneTitle(errorList.length),
3820
+ headerSize: "xs",
3821
+ isOpen: isOpen,
3822
+ "data-testid": "moveable-issues-pane",
3823
+ bounds: "parent"
3824
+ }, /*#__PURE__*/React__namespace.createElement(material.Box, {
3825
+ component: "div",
3826
+ sx: {
3827
+ marginTop: '16px',
3828
+ marginLeft: '24px'
3829
+ }
3830
+ }, errorList.length === 0 && /*#__PURE__*/React__namespace.createElement(material.Box, {
3831
+ component: "div",
3832
+ sx: {
3833
+ fontSize: '4rem'
3834
+ },
3835
+ "data-testid": "zeroIssuesImage"
3836
+ }, /*#__PURE__*/React__namespace.createElement(ThumbsUp, null)), errorList.length > 0 && errorList.map(function (error, index) {
3837
+ return /*#__PURE__*/React__namespace.createElement(material.Typography // eslint-disable-next-line react/no-array-index-key
3838
+ , {
3839
+ // eslint-disable-next-line react/no-array-index-key
3840
+ key: "message-" + index,
3841
+ variant: "body1",
3842
+ "data-testid": "errorMessage"
3843
+ }, getErrorMessage(error, index));
3844
+ }))), rootElement);
3845
+ };
3846
+
3847
+ var TafModuleContext = /*#__PURE__*/React__namespace.createContext({
3848
+ onValidateForm: null,
3849
+ registerValidateForm: null,
3850
+ tafAction: null,
3851
+ setTafAction: null,
3852
+ isFormDirty: null,
3853
+ setIsFormDirty: null
3854
+ });
3855
+ var useTafModuleContext = function useTafModuleContext() {
3856
+ return React__namespace.useContext(TafModuleContext);
3857
+ };
3858
+ var useTafModuleState = function useTafModuleState(_a) {
3859
+ var onPreventCloseView = _a.onPreventCloseView;
3860
+
3861
+ var _b = __read(React__namespace.useState(function () {
3862
+ return new Promise(function () {
3863
+ return true;
3864
+ });
3865
+ }), 2),
3866
+ onValidateForm = _b[0],
3867
+ registerValidateForm = _b[1];
3868
+
3869
+ var _c = __read(React__namespace.useState(), 2),
3870
+ tafAction = _c[0],
3871
+ setTafAction = _c[1];
3872
+
3873
+ var _d = __read(React__namespace.useState(false), 2),
3874
+ isFormDirty = _d[0],
3875
+ setIsFormDirty = _d[1];
3876
+
3877
+ var onRegisterValidateForm = function onRegisterValidateForm(promiseToRegister) {
3878
+ registerValidateForm(function () {
3879
+ return promiseToRegister;
3880
+ });
3881
+ };
3882
+
3883
+ var onChangeFormDirty = function onChangeFormDirty(isDirty) {
3884
+ if (isDirty !== isFormDirty) {
3885
+ setIsFormDirty(isDirty);
3886
+ onPreventCloseView(isDirty);
3887
+ }
3888
+ };
3781
3889
 
3782
- var _d = __read(React__default["default"].useState(defaultTafAction), 2),
3783
- tafAction = _d[0],
3784
- setTafAction = _d[1];
3890
+ return {
3891
+ onValidateForm: onValidateForm,
3892
+ registerValidateForm: onRegisterValidateForm,
3893
+ tafAction: tafAction,
3894
+ setTafAction: setTafAction,
3895
+ isFormDirty: isFormDirty,
3896
+ setIsFormDirty: onChangeFormDirty
3897
+ };
3898
+ };
3899
+ var TafModuleProvider = function TafModuleProvider(_a) {
3900
+ var children = _a.children,
3901
+ _b = _a.onPreventCloseView,
3902
+ onPreventCloseView = _b === void 0 ? function () {} : _b;
3903
+ var contextState = useTafModuleState({
3904
+ onPreventCloseView: onPreventCloseView
3905
+ });
3906
+ return /*#__PURE__*/React__namespace.createElement(TafModuleContext.Provider, {
3907
+ value: contextState
3908
+ }, children);
3909
+ };
3785
3910
 
3786
- var _e = __read(React__default["default"].useState(isDefaultDisabled), 2),
3787
- isDisabled = _e[0],
3788
- setIsDisabled = _e[1];
3911
+ var noop = function noop() {};
3789
3912
 
3913
+ var TafForm = function TafForm(_a) {
3914
+ var tafFromBackend = _a.tafFromBackend,
3915
+ _b = _a.onFormAction,
3916
+ onFormAction = _b === void 0 ? function () {
3917
+ return null;
3918
+ } : _b,
3919
+ _c = _a.isIssuesPaneOpen,
3920
+ isIssuesPaneOpen = _c === void 0 ? false : _c,
3921
+ _d = _a.setIsIssuesPaneOpen,
3922
+ setIsIssuesPaneOpen = _d === void 0 ? function () {
3923
+ return null;
3924
+ } : _d,
3925
+ _e = _a.isDisabled,
3926
+ isDisabled = _e === void 0 ? false : _e,
3927
+ _f = _a.setIsDisabled,
3928
+ setIsDisabled = _f === void 0 ? function () {
3929
+ return null;
3930
+ } : _f;
3931
+ var originalTaf = tafFromBackend.taf;
3932
+ var isDefaultDisabled = getIsFormDefaultDisabled(tafFromBackend.taf.status);
3790
3933
  var confirmDialog = shared.useConfirmationDialog();
3791
3934
 
3792
- var _f = shared.useDraftFormHelpers(),
3793
- toggleIsDraft = _f.toggleIsDraft,
3794
- DraftFieldHelper = _f.DraftFieldHelper;
3935
+ var _g = shared.useDraftFormHelpers(true),
3936
+ toggleIsDraft = _g.toggleIsDraft,
3937
+ DraftFieldHelper = _g.DraftFieldHelper;
3938
+
3939
+ var _h = useTafModuleContext(),
3940
+ registerValidateForm = _h.registerValidateForm,
3941
+ tafAction = _h.tafAction,
3942
+ setTafAction = _h.setTafAction,
3943
+ setIsFormDirty = _h.setIsFormDirty;
3795
3944
 
3796
3945
  var api$1 = api.useApiContext().api;
3797
3946
  var isMounted = shared.useIsMounted().isMounted;
3798
3947
 
3799
- var _g = reactHookForm.useFormContext(),
3800
- control = _g.control,
3801
- handleSubmit = _g.handleSubmit,
3802
- watch = _g.watch,
3803
- trigger = _g.trigger,
3804
- formState = _g.formState,
3805
- getValues = _g.getValues,
3806
- setValue = _g.setValue,
3807
- reset = _g.reset;
3948
+ var _j = reactHookForm.useFormContext(),
3949
+ control = _j.control,
3950
+ handleSubmit = _j.handleSubmit,
3951
+ trigger = _j.trigger,
3952
+ formState = _j.formState,
3953
+ getValues = _j.getValues,
3954
+ setValue = _j.setValue,
3955
+ reset = _j.reset;
3808
3956
 
3809
3957
  var isFormDirty = formState.isDirty,
3810
3958
  errors = formState.errors;
3811
3959
  shared.usePreventBrowserClose(isFormDirty && !isDisabled);
3812
3960
  var hiddenInputFields = ['baseTime', 'issueDate', 'type', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd'];
3813
3961
 
3814
- var _h = __read(React__default["default"].useState(watch()), 2),
3815
- delayedFormValues = _h[0],
3816
- setDelayedFormValues = _h[1];
3962
+ var _k = __read(React__default["default"].useState(getValues()), 2),
3963
+ delayedFormValues = _k[0],
3964
+ setDelayedFormValues = _k[1];
3817
3965
 
3818
- var _j = __read(useTACGenerator(convertTafValuesToObject(delayedFormValues), api$1.getTAC, staticTAC), 2),
3819
- TAC = _j[0],
3820
- updateTAC = _j[1];
3966
+ var _l = __read(useTACGenerator(tafFromBackend.taf, api$1.getTAC), 2),
3967
+ TAC = _l[0],
3968
+ updateTAC = _l[1];
3821
3969
 
3822
3970
  var hasErrors = Object.keys(errors).length;
3823
3971
 
@@ -3826,7 +3974,7 @@
3826
3974
  };
3827
3975
 
3828
3976
  React__default["default"].useEffect(function () {
3829
- if (staticTAC === '' && isMounted.current && isFormDirty) {
3977
+ if (isMounted.current && isFormDirty) {
3830
3978
  var newTAC = hasErrors ? null : convertTafValuesToObject(delayedFormValues);
3831
3979
  updateTAC(newTAC);
3832
3980
  } // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -3838,7 +3986,11 @@
3838
3986
  updateTAC(convertTafValuesToObject(delayedFormValues));
3839
3987
  } // eslint-disable-next-line react-hooks/exhaustive-deps
3840
3988
 
3841
- }, [hasErrors]);
3989
+ }, [hasErrors]); // Needed to be able to show a confirmation dialog on switching tabs when form is edited and not saved
3990
+
3991
+ React__default["default"].useEffect(function () {
3992
+ setIsFormDirty(isFormDirty);
3993
+ }, [isFormDirty, setIsFormDirty]);
3842
3994
 
3843
3995
  var onSubmit = function onSubmit(data) {
3844
3996
  // eslint-disable-next-line no-console
@@ -3883,6 +4035,7 @@
3883
4035
  toggleIsDraft(true);
3884
4036
  handleSubmit(function (data) {
3885
4037
  onFormAction(action, convertTafValuesToObject(data));
4038
+ reset(getValues());
3886
4039
  })();
3887
4040
  break;
3888
4041
 
@@ -3946,7 +4099,7 @@
3946
4099
  switch (action) {
3947
4100
  case 'CANCEL':
3948
4101
  showConfirmDialog(action).then(function () {
3949
- onFormAction(action, tafFromBackend.taf);
4102
+ onFormAction(action, convertTafValuesToObject(prepareTafValues(tafFromBackend.taf, action)));
3950
4103
  });
3951
4104
  break;
3952
4105
 
@@ -3956,19 +4109,19 @@
3956
4109
  }
3957
4110
  };
3958
4111
 
3959
- var _k = reactHookForm.useFieldArray({
4112
+ var _m = reactHookForm.useFieldArray({
3960
4113
  control: control,
3961
4114
  name: 'changeGroups'
3962
4115
  }),
3963
- fields = _k.fields,
3964
- insert = _k.insert,
3965
- remove = _k.remove,
3966
- move = _k.move;
4116
+ fields = _m.fields,
4117
+ insert = _m.insert,
4118
+ remove = _m.remove,
4119
+ move = _m.move;
3967
4120
 
3968
- var _l = useDragOrder(trigger, move, onFormBlur),
3969
- onChangeOrder = _l.onChangeOrder,
3970
- onStartDrag = _l.onStartDrag,
3971
- activeDraggingIndex = _l.activeDraggingIndex;
4121
+ var _o = useDragOrder(trigger, move, onFormBlur),
4122
+ onChangeOrder = _o.onChangeOrder,
4123
+ onStartDrag = _o.onStartDrag,
4124
+ activeDraggingIndex = _o.activeDraggingIndex;
3972
4125
 
3973
4126
  var onRemoverow = function onRemoverow(index) {
3974
4127
  confirmDialog({
@@ -4049,16 +4202,57 @@
4049
4202
  });
4050
4203
  };
4051
4204
 
4205
+ var _p = __read(React__default["default"].useState(false), 2),
4206
+ shouldValidate = _p[0],
4207
+ setShouldValidate = _p[1];
4208
+
4209
+ React__default["default"].useEffect(function () {
4210
+ setIsDisabled(isDefaultDisabled);
4211
+ var defaultValues = prepareTafValues(tafFromBackend.taf, undefined, !isDefaultDisabled && !tafFromBackend.taf.changeGroups); // set initial form values
4212
+
4213
+ reset(defaultValues); // set validate flag to validate after the values have been set
4214
+
4215
+ setShouldValidate(true); // register validate method to use in parent components
4216
+
4217
+ var onValidateFormPromise = function onValidateFormPromise() {
4218
+ return new Promise(function (resolve, reject) {
4219
+ toggleIsDraft(true);
4220
+ handleSubmit(function (formData) {
4221
+ resolve(convertTafValuesToObject(formData));
4222
+ })().then(function (formData) {
4223
+ if (formData === undefined) {
4224
+ reject();
4225
+ }
4226
+
4227
+ resolve(formData);
4228
+ });
4229
+ });
4230
+ };
4231
+
4232
+ registerValidateForm(onValidateFormPromise); // set default taf action
4233
+
4234
+ setTafAction(fromStatusToAction(originalTaf.status));
4235
+ return function () {
4236
+ reset({});
4237
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
4238
+ }, []);
4052
4239
  React__default["default"].useEffect(function () {
4053
- if (!isDisabled) {
4240
+ var newValues = prepareTafValues(tafFromBackend.taf, undefined, !isDefaultDisabled && !tafFromBackend.taf.changeGroups); // set new form values when tafFromBackend changed
4241
+
4242
+ reset(newValues); // eslint-disable-next-line react-hooks/exhaustive-deps
4243
+ }, [tafFromBackend]);
4244
+ React__default["default"].useEffect(function () {
4245
+ if (shouldValidate && !isDisabled) {
4054
4246
  // trigger validation on all changegroup validity times after initial load since they could be outside the new validity period
4055
- var validFields = fields.map(function (_field, index) {
4247
+ var _a = tafFromBackend.taf.changeGroups,
4248
+ changeGroups = _a === void 0 ? [] : _a;
4249
+ var validFields = changeGroups.map(function (_field, index) {
4056
4250
  return "changeGroups[" + index + "].valid";
4057
4251
  });
4058
4252
  trigger(validFields);
4059
4253
  } // eslint-disable-next-line react-hooks/exhaustive-deps
4060
4254
 
4061
- }, []);
4255
+ }, [shouldValidate]);
4062
4256
  return /*#__PURE__*/React__default["default"].createElement("form", {
4063
4257
  "data-testid": "taf-form",
4064
4258
  onSubmit: handleSubmit(onSubmit),
@@ -4136,7 +4330,9 @@
4136
4330
  }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
4137
4331
  item: true
4138
4332
  }, /*#__PURE__*/React__default["default"].createElement(IssuesButton, {
4139
- errors: errors
4333
+ errors: errors,
4334
+ isIssuesPaneOpen: isIssuesPaneOpen,
4335
+ setIsIssuesPaneOpen: setIsIssuesPaneOpen
4140
4336
  }))), /*#__PURE__*/React__default["default"].createElement(TafFormButtons, {
4141
4337
  isFormDisabled: isDisabled,
4142
4338
  tafAction: tafAction,
@@ -4151,50 +4347,6 @@
4151
4347
  }), /*#__PURE__*/React__default["default"].createElement(DraftFieldHelper, null));
4152
4348
  };
4153
4349
 
4154
- /* *
4155
- * Licensed under the Apache License, Version 2.0 (the "License");
4156
- * you may not use this file except in compliance with the License.
4157
- * You may obtain a copy of the License at
4158
- *
4159
- * http://www.apache.org/licenses/LICENSE-2.0
4160
- *
4161
- * Unless required by applicable law or agreed to in writing, software
4162
- * distributed under the License is distributed on an "AS IS" BASIS,
4163
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4164
- * See the License for the specific language governing permissions and
4165
- * limitations under the License.
4166
- *
4167
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4168
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
4169
- * */
4170
-
4171
- var TafFormWrapper = function TafFormWrapper(_a) {
4172
- var tafFromBackend = _a.tafFromBackend,
4173
- mode = _a.mode,
4174
- _b = _a.TAC,
4175
- TAC = _b === void 0 ? '' : _b,
4176
- onFormAction = _a.onFormAction,
4177
- tafAction = _a.tafAction;
4178
- var taf = tafFromBackend.taf;
4179
- var isDisabled = mode === 'view';
4180
- var defaultValues = prepareTafValues(taf, undefined, !isDisabled && !taf.changeGroups);
4181
- var options = {
4182
- defaultValues: defaultValues,
4183
- mode: 'onTouched',
4184
- reValidateMode: 'onChange',
4185
- criteriaMode: 'all'
4186
- };
4187
- return /*#__PURE__*/React__default["default"].createElement(formFields.ReactHookFormProvider, {
4188
- options: options
4189
- }, /*#__PURE__*/React__default["default"].createElement(TafForm, {
4190
- isDisabled: isDisabled,
4191
- staticTAC: TAC,
4192
- onFormAction: onFormAction,
4193
- tafFromBackend: tafFromBackend,
4194
- tafAction: tafAction
4195
- }));
4196
- };
4197
-
4198
4350
  /* *
4199
4351
  * Licensed under the Apache License, Version 2.0 (the "License");
4200
4352
  * you may not use this file except in compliance with the License.
@@ -4380,16 +4532,41 @@
4380
4532
  'aria-controls': "simple-tabpanel-" + index
4381
4533
  };
4382
4534
  };
4535
+ var prepareTafExportValues = function prepareTafExportValues(tafToCopy, currentTaf) {
4536
+ var _a;
4383
4537
 
4384
- var EditIcon = function EditIcon(props) {
4385
- var theme = material.useTheme();
4386
- return /*#__PURE__*/React__namespace.createElement(material.SvgIcon, __assign({}, props), /*#__PURE__*/React__namespace.createElement("g", null, /*#__PURE__*/React__namespace.createElement("path", {
4387
- d: "m8.332 17.09-.005.001-2.652.604.956-2.542.001-.001.001-.001.857-.744 1.69 1.945-.848.738zm.71.815L20.932 7.577 17.823 4 5.933 14.329l-.01.008.005.005L4.173 19l4.857-1.09-.004-.02.019.02-.002-.005z",
4388
- fillRule: "evenodd",
4389
- fill: "" + theme.palette.geowebColors.buttons.tertiary["default"].color
4390
- })));
4538
+ var convertedCopy = prepareTafValues(tafToCopy, undefined, false);
4539
+ var baseForecast = convertedCopy.baseForecast,
4540
+ _b = convertedCopy.changeGroups,
4541
+ changeGroups = _b === void 0 ? [] : _b;
4542
+ return __assign(__assign({}, currentTaf), {
4543
+ baseForecast: __assign(__assign(__assign({}, emptyBaseForecast), baseForecast), {
4544
+ valid: (_a = currentTaf === null || currentTaf === void 0 ? void 0 : currentTaf.baseForecast) === null || _a === void 0 ? void 0 : _a.valid
4545
+ }),
4546
+ changeGroups: changeGroups
4547
+ });
4391
4548
  };
4392
4549
 
4550
+ /* *
4551
+ * Licensed under the Apache License, Version 2.0 (the "License");
4552
+ * you may not use this file except in compliance with the License.
4553
+ * You may obtain a copy of the License at
4554
+ *
4555
+ * http://www.apache.org/licenses/LICENSE-2.0
4556
+ *
4557
+ * Unless required by applicable law or agreed to in writing, software
4558
+ * distributed under the License is distributed on an "AS IS" BASIS,
4559
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4560
+ * See the License for the specific language governing permissions and
4561
+ * limitations under the License.
4562
+ *
4563
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4564
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4565
+ * */
4566
+ var EditIcon = material.createSvgIcon( /*#__PURE__*/React__namespace.createElement("path", {
4567
+ d: "m8.332 17.09-.005.001-2.652.604.956-2.542.001-.001.001-.001.857-.744 1.69 1.945-.848.738zm.71.815L20.932 7.577 17.823 4 5.933 14.329l-.01.008.005.005L4.173 19l4.857-1.09-.004-.02.019.02-.002-.005z"
4568
+ }), 'Edit');
4569
+
4393
4570
  var StatusIcon = function StatusIcon(_a) {
4394
4571
  var timeSlot = _a.timeSlot,
4395
4572
  status = _a.status;
@@ -4399,45 +4576,96 @@
4399
4576
  }
4400
4577
 
4401
4578
  if (status === 'EXPIRED') {
4402
- return /*#__PURE__*/React__namespace.createElement(iconsMaterial.Schedule, {
4579
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4580
+ title: "Expired",
4581
+ placement: "right"
4582
+ }, /*#__PURE__*/React__namespace.createElement(iconsMaterial.Schedule, {
4403
4583
  "data-testid": "status-expired",
4404
4584
  fontSize: "small",
4405
4585
  sx: {
4406
4586
  transform: 'scaleX(-1)',
4407
4587
  color: 'geowebColors.buttons.tertiary.disabled.color'
4408
4588
  }
4409
- });
4589
+ }));
4410
4590
  }
4411
4591
 
4412
4592
  if (status === 'CANCELLED') {
4413
- return /*#__PURE__*/React__namespace.createElement(DoDisturbIcon__default["default"], {
4593
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4594
+ title: "Cancelled",
4595
+ placement: "right"
4596
+ }, /*#__PURE__*/React__namespace.createElement(DoDisturbIcon__default["default"], {
4414
4597
  "data-testid": "status-cancelled",
4415
4598
  fontSize: "small",
4416
4599
  sx: {
4417
4600
  color: 'geowebColors.captions.captionError.rgba'
4418
4601
  }
4419
- });
4602
+ }));
4420
4603
  }
4421
4604
 
4422
4605
  if (status === 'DRAFT' || status === 'DRAFT_CORRECTED' || status === 'DRAFT_AMENDED') {
4423
- return /*#__PURE__*/React__namespace.createElement(EditIcon, {
4424
- "data-testid": "status-draft"
4425
- });
4606
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4607
+ title: "Draft",
4608
+ placement: "right"
4609
+ }, /*#__PURE__*/React__namespace.createElement(material.SvgIcon, {
4610
+ component: EditIcon,
4611
+ "data-testid": "status-draft",
4612
+ sx: {
4613
+ color: 'geowebColors.buttons.tertiary.default.color'
4614
+ }
4615
+ }));
4426
4616
  }
4427
4617
 
4428
- return timeSlot === 'ACTIVE' ? /*#__PURE__*/React__namespace.createElement(iconsMaterial.CheckCircle, {
4618
+ return timeSlot === 'ACTIVE' ? /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4619
+ title: "Active",
4620
+ placement: "right"
4621
+ }, /*#__PURE__*/React__namespace.createElement(iconsMaterial.CheckCircle, {
4429
4622
  "data-testid": "status-active",
4430
4623
  fontSize: "small",
4431
4624
  sx: {
4432
4625
  color: 'geowebColors.functional.success'
4433
4626
  }
4434
- }) : /*#__PURE__*/React__namespace.createElement(iconsMaterial.Schedule, {
4627
+ })) : /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4628
+ title: "Upcoming",
4629
+ placement: "right"
4630
+ }, /*#__PURE__*/React__namespace.createElement(iconsMaterial.Schedule, {
4435
4631
  "data-testid": "status-upcoming",
4436
4632
  fontSize: "small",
4437
4633
  sx: {
4438
4634
  color: 'geowebColors.functional.success'
4439
4635
  }
4440
- });
4636
+ }));
4637
+ };
4638
+
4639
+ /* *
4640
+ * Licensed under the Apache License, Version 2.0 (the "License");
4641
+ * you may not use this file except in compliance with the License.
4642
+ * You may obtain a copy of the License at
4643
+ *
4644
+ * http://www.apache.org/licenses/LICENSE-2.0
4645
+ *
4646
+ * Unless required by applicable law or agreed to in writing, software
4647
+ * distributed under the License is distributed on an "AS IS" BASIS,
4648
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4649
+ * See the License for the specific language governing permissions and
4650
+ * limitations under the License.
4651
+ *
4652
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4653
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4654
+ * */
4655
+ var ExportIcon = /*#__PURE__*/React__default["default"].createElement(material.SvgIcon, null, /*#__PURE__*/React__default["default"].createElement("path", {
4656
+ d: "M14.744 5.476a1.252 1.252 0 1 0 0 2.504h2.752v9.516H6.48v-1.753a1.251 1.251 0 1 0-2.504 0v3.004c0 .693.561 1.253 1.252 1.253h13.52C19.44 20 20 19.44 20 18.747V6.727c0-.69-.56-1.251-1.252-1.251zM9.133 2.385a1.252 1.252 0 0 0-1.77 0L1.773 7.974l5.54 5.54c.49.49 1.281.49 1.77 0l.022-.026a1.25 1.25 0 0 0-.021-1.745L6.568 9.225h1.371c.914 0 2.756.618 4.045 2.763 1.29 2.145.352 2.526.653 2.526.301 0 1.943-1.798.721-4.295-1.71-3.498-4.6-3.498-5.346-3.498H6.568l2.565-2.565a1.253 1.253 0 0 0 0-1.771z"
4657
+ }));
4658
+
4659
+ var ExportButton = function ExportButton(_a) {
4660
+ var onClick = _a.onClick,
4661
+ isHidden = _a.isHidden;
4662
+ return isHidden ? null : /*#__PURE__*/React__default["default"].createElement(material.Tooltip, {
4663
+ title: "Import TAC",
4664
+ placement: "left"
4665
+ }, /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement(shared.ToolButton, {
4666
+ onClick: onClick,
4667
+ "data-testid": "export-tac-button"
4668
+ }, ExportIcon)));
4441
4669
  };
4442
4670
 
4443
4671
  /* *
@@ -4460,18 +4688,40 @@
4460
4688
  var TacContainer = function TacContainer(_a) {
4461
4689
  var taf = _a.taf,
4462
4690
  _b = _a.isActive,
4463
- isActive = _b === void 0 ? false : _b;
4691
+ isActive = _b === void 0 ? false : _b,
4692
+ _c = _a.isFormDisabled,
4693
+ isFormDisabled = _c === void 0 ? false : _c;
4464
4694
  var api$1 = api.useApiContext().api;
4465
4695
 
4466
- var _c = __read(useTACGenerator(taf, api$1.getTAC), 2),
4467
- TAC = _c[0],
4468
- retrieveTAC = _c[1];
4696
+ var _d = __read(useTACGenerator(taf, api$1.getTAC), 2),
4697
+ TAC = _d[0],
4698
+ retrieveTAC = _d[1];
4469
4699
 
4470
4700
  var status = taf.status,
4471
4701
  location = taf.location,
4472
4702
  baseTime = taf.baseTime;
4473
4703
  var locationLabel = getLocationSetting(location).label;
4474
4704
  var timeSlot = getTafTimeSlot(baseTime, location, status);
4705
+
4706
+ var _e = reactHookForm.useFormContext(),
4707
+ getValues = _e.getValues,
4708
+ trigger = _e.trigger,
4709
+ setValue = _e.setValue;
4710
+
4711
+ var handleExport = function handleExport() {
4712
+ var currentTaf = getValues();
4713
+ var newTaf = prepareTafExportValues(taf, currentTaf);
4714
+ setValue('baseForecast', newTaf.baseForecast, {
4715
+ shouldDirty: true
4716
+ });
4717
+ setValue('changeGroups', newTaf.changeGroups, {
4718
+ shouldDirty: true
4719
+ });
4720
+ setTimeout(function () {
4721
+ trigger(); // trigger all fields validation
4722
+ }, 0);
4723
+ };
4724
+
4475
4725
  React__default["default"].useEffect(function () {
4476
4726
  if (isActive) {
4477
4727
  retrieveTAC(taf);
@@ -4487,14 +4737,22 @@
4487
4737
  sx: {
4488
4738
  display: 'flex',
4489
4739
  alignItems: 'center',
4490
- marginBottom: '2px'
4740
+ justifyContent: 'space-between',
4741
+ height: 24
4742
+ }
4743
+ }, /*#__PURE__*/React__default["default"].createElement(material.Box, {
4744
+ sx: {
4745
+ display: 'flex',
4746
+ alignItems: 'center'
4491
4747
  }
4492
4748
  }, /*#__PURE__*/React__default["default"].createElement(material.Box, {
4493
4749
  sx: {
4494
- width: 20,
4495
- height: 20,
4750
+ width: 24,
4751
+ height: 24,
4496
4752
  display: 'flex',
4497
- marginRight: '6px'
4753
+ marginRight: '2px',
4754
+ alignItems: 'center',
4755
+ justifyContent: 'center'
4498
4756
  }
4499
4757
  }, /*#__PURE__*/React__default["default"].createElement(StatusIcon, {
4500
4758
  timeSlot: timeSlot,
@@ -4521,7 +4779,10 @@
4521
4779
  },
4522
4780
  "data-testid": "tafLocationLabel",
4523
4781
  component: "span"
4524
- }, locationLabel))), /*#__PURE__*/React__default["default"].createElement(material.Box, {
4782
+ }, locationLabel))), /*#__PURE__*/React__default["default"].createElement(ExportButton, {
4783
+ onClick: handleExport,
4784
+ isHidden: isFormDisabled || tacHasError(TAC)
4785
+ })), /*#__PURE__*/React__default["default"].createElement(material.Box, {
4525
4786
  sx: {
4526
4787
  fontSize: '12px',
4527
4788
  letterSpacing: '0.4px',
@@ -4557,11 +4818,13 @@
4557
4818
  _e = _a.hideTitle,
4558
4819
  hideTitle = _e === void 0 ? false : _e,
4559
4820
  _f = _a.activeTaf,
4560
- activeTaf = _f === void 0 ? null : _f;
4821
+ activeTaf = _f === void 0 ? null : _f,
4822
+ _g = _a.isFormDisabled,
4823
+ isFormDisabled = _g === void 0 ? false : _g;
4561
4824
 
4562
- var _g = __read(React__default["default"].useState(0), 2),
4563
- activeTab = _g[0],
4564
- setActiveTab = _g[1];
4825
+ var _h = __read(React__default["default"].useState(0), 2),
4826
+ activeTab = _h[0],
4827
+ setActiveTab = _h[1];
4565
4828
 
4566
4829
  var scrollRef = React__default["default"].useRef(null);
4567
4830
  var tabs = [{
@@ -4653,7 +4916,8 @@
4653
4916
  return /*#__PURE__*/React__default["default"].createElement(TacContainer, {
4654
4917
  key: taf.uuid,
4655
4918
  taf: taf,
4656
- isActive: isActiveLocation(taf.location)
4919
+ isActive: isActiveLocation(taf.location),
4920
+ isFormDisabled: isFormDisabled
4657
4921
  });
4658
4922
  }));
4659
4923
  })));
@@ -4727,7 +4991,13 @@
4727
4991
  var timeSlot = _a.timeSlot,
4728
4992
  _b = _a.onChangeTimeSlot,
4729
4993
  onChangeTimeSlot = _b === void 0 ? function () {} : _b,
4730
- tafFromBackend = _a.tafFromBackend;
4994
+ _c = _a.tafFromBackend,
4995
+ tafFromBackend = _c === void 0 ? {
4996
+ taf: {
4997
+ baseTime: '2022-01-06T12:00:00Z',
4998
+ location: 'EHAM'
4999
+ }
5000
+ } : _c;
4731
5001
 
4732
5002
  if (!tafFromBackend) {
4733
5003
  return null;
@@ -4735,9 +5005,9 @@
4735
5005
 
4736
5006
  var activeTab = timeSlot === 'UPCOMING' ? 0 : 1;
4737
5007
 
4738
- var _c = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location),
4739
- currentBaseTime = _c.currentBaseTime,
4740
- nextBaseTime = _c.nextBaseTime;
5008
+ var _d = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location),
5009
+ currentBaseTime = _d.currentBaseTime,
5010
+ nextBaseTime = _d.nextBaseTime;
4741
5011
 
4742
5012
  var tabs = [{
4743
5013
  title: "Upcoming " + formatBaseTime(nextBaseTime),
@@ -4755,12 +5025,13 @@
4755
5025
  value: activeTab,
4756
5026
  onChange: onChangeTab,
4757
5027
  "aria-label": "timeslot-tabs",
5028
+ "data-testid": "timeslot-tabs",
4758
5029
  variant: "fullWidth"
4759
5030
  }, tabs.map(function (tab, index) {
4760
5031
  return /*#__PURE__*/React__default["default"].createElement(material.Tab, __assign({
4761
5032
  key: tab.title,
4762
5033
  label: tab.title,
4763
- "data-testid": "tab-" + index,
5034
+ "data-testid": "toptab-" + index,
4764
5035
  sx: {
4765
5036
  fontSize: 16
4766
5037
  }
@@ -4880,73 +5151,72 @@
4880
5151
  }
4881
5152
  };
4882
5153
 
4883
- var TafPanel = function TafPanel(_a) {
4884
- var tafFromBackend = _a.tafFromBackend,
4885
- activeTafIndex = _a.activeTafIndex,
4886
- index = _a.index,
4887
- _b = _a.onPostTaf,
4888
- onPostTaf = _b === void 0 ? function () {} : _b;
4889
- var api$1 = api.useApiContext().api;
5154
+ var parseErrorMessage = function parseErrorMessage(error, params) {
5155
+ return params.changeStatusTo === 'CANCELLED' ? {
5156
+ type: 'CANCELLED',
5157
+ title: 'Cancelling this TAF failed, please try again'
5158
+ } : {
5159
+ type: 'SERVER',
5160
+ title: 'An error has occurred while saving, please try again',
5161
+ message: shared.getAxiosErrorMessage(error)
5162
+ };
5163
+ };
4890
5164
 
4891
- var _c = __read(React__default["default"].useState(false), 2),
4892
- isLoading = _c[0],
4893
- setLoading = _c[1];
5165
+ var usePostTafRequest = function usePostTafRequest(request, errorParser) {
5166
+ if (errorParser === void 0) {
5167
+ errorParser = parseErrorMessage;
5168
+ }
4894
5169
 
4895
- var _d = __read(React__default["default"].useState(null), 2),
4896
- error = _d[0],
4897
- setError = _d[1]; // removes cancelled error message
5170
+ var isMounted = shared.useIsMounted().isMounted;
4898
5171
 
5172
+ var _a = __read(React__default["default"].useState(false), 2),
5173
+ isLoading = _a[0],
5174
+ setLoading = _a[1];
4899
5175
 
4900
- React__default["default"].useEffect(function () {
4901
- var cancelErrorTimeout = error && error.type === 'CANCELLED' ? setTimeout(function () {
4902
- setError(null);
4903
- }, 10000) : null;
4904
- return function () {
4905
- if (cancelErrorTimeout !== null) {
4906
- clearTimeout(cancelErrorTimeout);
4907
- }
4908
- };
4909
- }, [error]);
5176
+ var _b = __read(React__default["default"].useState(null), 2),
5177
+ error = _b[0],
5178
+ setError = _b[1];
4910
5179
 
4911
- var postTaf = function postTaf(data) {
5180
+ var doRequest = function doRequest(params) {
4912
5181
  return __awaiter(void 0, void 0, void 0, function () {
4913
- var error_1, newError;
5182
+ var error_1, newErrorr;
4914
5183
  return __generator(this, function (_a) {
4915
5184
  switch (_a.label) {
4916
5185
  case 0:
4917
- _a.trys.push([0, 2,, 3]);
4918
-
4919
5186
  setLoading(true);
5187
+ setError(null);
5188
+ _a.label = 1;
5189
+
5190
+ case 1:
5191
+ _a.trys.push([1, 3,, 4]);
5192
+
4920
5193
  return [4
4921
5194
  /*yield*/
4922
- , api$1.postTaf(data)];
5195
+ , request(params)];
4923
5196
 
4924
- case 1:
5197
+ case 2:
4925
5198
  _a.sent();
4926
5199
 
5200
+ if (!isMounted.current) return [2
5201
+ /*return*/
5202
+ ];
4927
5203
  setLoading(false);
4928
- setError(null); // callback
4929
-
4930
- onPostTaf();
5204
+ setError(null);
4931
5205
  return [3
4932
5206
  /*break*/
4933
- , 3];
5207
+ , 4];
4934
5208
 
4935
- case 2:
5209
+ case 3:
4936
5210
  error_1 = _a.sent();
4937
- newError = data.changeStatusTo === 'CANCELLED' ? {
4938
- type: 'CANCELLED',
4939
- title: 'Cancelling this TAF failed, please try again'
4940
- } : {
4941
- type: 'SERVER',
4942
- title: 'An error has occurred while saving, please try again',
4943
- message: shared.getAxiosErrorMessage(error_1)
4944
- };
4945
- setError(newError);
5211
+ if (!isMounted.current) return [2
5212
+ /*return*/
5213
+ ];
5214
+ newErrorr = errorParser ? errorParser(error_1, params) : error_1;
4946
5215
  setLoading(false);
4947
- throw error_1;
5216
+ setError(newErrorr);
5217
+ throw newErrorr;
4948
5218
 
4949
- case 3:
5219
+ case 4:
4950
5220
  return [2
4951
5221
  /*return*/
4952
5222
  ];
@@ -4955,9 +5225,37 @@
4955
5225
  });
4956
5226
  };
4957
5227
 
4958
- var getViewMode = function getViewMode(status) {
4959
- return status === 'NEW' || status === 'DRAFT' || status === 'DRAFT_AMENDED' || status === 'DRAFT_CORRECTED' ? 'edit' : 'view';
5228
+ return {
5229
+ isLoading: isLoading,
5230
+ error: error,
5231
+ setError: setError,
5232
+ doRequest: doRequest
4960
5233
  };
5234
+ };
5235
+
5236
+ var TafPanel = function TafPanel(_a) {
5237
+ var tafFromBackend = _a.tafFromBackend,
5238
+ activeTafIndex = _a.activeTafIndex,
5239
+ index = _a.index,
5240
+ _b = _a.isLoading,
5241
+ isLoading = _b === void 0 ? false : _b,
5242
+ _c = _a.postTaf,
5243
+ postTaf = _c === void 0 ? function () {
5244
+ return null;
5245
+ } : _c,
5246
+ _d = _a.isIssuesPaneOpen,
5247
+ isIssuesPaneOpen = _d === void 0 ? false : _d,
5248
+ _e = _a.setIsIssuesPaneOpen,
5249
+ setIsIssuesPaneOpen = _e === void 0 ? function () {
5250
+ return null;
5251
+ } : _e,
5252
+ _f = _a.isFormDisabled,
5253
+ isFormDisabled = _f === void 0 ? false : _f,
5254
+ _g = _a.setIsFormDisabled,
5255
+ setIsFormDisabled = _g === void 0 ? function () {
5256
+ return null;
5257
+ } : _g,
5258
+ error = _a.error;
4961
5259
 
4962
5260
  var onTafAction = function onTafAction(action, taf) {
4963
5261
  return __awaiter(void 0, void 0, void 0, function () {
@@ -5070,12 +5368,35 @@
5070
5368
  severity: "error",
5071
5369
  title: error.title,
5072
5370
  info: error.message,
5073
- dataTestId: "taf-error"
5074
- }), /*#__PURE__*/React__default["default"].createElement(TafFormWrapper, {
5075
- mode: getViewMode(tafFromBackend.taf.status),
5371
+ dataTestId: "taf-error",
5372
+ shouldClose: true
5373
+ }), /*#__PURE__*/React__default["default"].createElement(material.Box, {
5374
+ sx: {
5375
+ marginTop: '10px',
5376
+ padding: 1
5377
+ }
5378
+ }, /*#__PURE__*/React__default["default"].createElement(TafForm, {
5076
5379
  tafFromBackend: tafFromBackend,
5077
- onFormAction: onTafAction
5078
- }));
5380
+ onFormAction: onTafAction,
5381
+ isIssuesPaneOpen: isIssuesPaneOpen,
5382
+ setIsIssuesPaneOpen: setIsIssuesPaneOpen,
5383
+ isDisabled: isFormDisabled,
5384
+ setIsDisabled: setIsFormDisabled
5385
+ })));
5386
+ };
5387
+
5388
+ var IssuesPaneWrapper = function IssuesPaneWrapper(props) {
5389
+ var errors = reactHookForm.useFormContext().formState.errors;
5390
+ var errorList = filterDuplicateErrors(getErrors(errors));
5391
+ return /*#__PURE__*/React__namespace.createElement(IssuesPane, __assign({
5392
+ errorList: errorList
5393
+ }, props));
5394
+ };
5395
+
5396
+ var CONFIRM_DIALOG_OPTIONS = {
5397
+ title: 'Whoops',
5398
+ description: "It's not possible to autosave this TAF due to the presence of issue(s). Are you sure you want to close this TAF? Any changes made will be lost.",
5399
+ confirmLabel: 'Exit without saving'
5079
5400
  };
5080
5401
 
5081
5402
  var TafLayout = function TafLayout(_a) {
@@ -5083,30 +5404,147 @@
5083
5404
  tafList = _b === void 0 ? [] : _b,
5084
5405
  _c = _a.onPostTaf,
5085
5406
  onPostTaf = _c === void 0 ? function () {} : _c;
5407
+ var api$1 = api.useApiContext().api;
5408
+ var confirmDialog = shared.useConfirmationDialog();
5409
+
5410
+ var _d = useIssuesPane(),
5411
+ isIssuesPaneOpen = _d.isIssuesPaneOpen,
5412
+ onToggleIssuesPane = _d.onToggleIssuesPane,
5413
+ onCloseIssuesPane = _d.onCloseIssuesPane,
5414
+ startPosition = _d.startPosition;
5415
+
5416
+ var _e = usePostTafRequest(api$1.postTaf),
5417
+ isLoading = _e.isLoading,
5418
+ postTafRequest = _e.doRequest,
5419
+ error = _e.error,
5420
+ setError = _e.setError;
5421
+
5422
+ var _f = useTafModuleContext(),
5423
+ onValidateForm = _f.onValidateForm,
5424
+ tafAction = _f.tafAction,
5425
+ isFormDirty = _f.isFormDirty;
5426
+
5427
+ var _g = __read(React__default["default"].useState(sortTafTimeSlots(tafList)), 2),
5428
+ _h = _g[0],
5429
+ upcoming = _h.upcoming,
5430
+ current = _h.current,
5431
+ expired = _h.expired,
5432
+ updateSortedTafs = _g[1];
5433
+
5434
+ var _j = __read(current.slice(-1), 1),
5435
+ lastCurrentTaf = _j[0];
5436
+
5437
+ var _k = __read(React__default["default"].useState('UPCOMING'), 2),
5438
+ timeSlot = _k[0],
5439
+ setTimeSlot = _k[1];
5440
+
5441
+ var _l = __read(React__default["default"].useState(upcoming), 2),
5442
+ locations = _l[0],
5443
+ setLocations = _l[1];
5444
+
5445
+ var _m = __read(React__default["default"].useState(0), 2),
5446
+ activeTafIndex = _m[0],
5447
+ setActiveTafIndex = _m[1];
5448
+
5449
+ var _o = __read(React__default["default"].useState(false), 2),
5450
+ isFormDisabled = _o[0],
5451
+ setIsFormDisabled = _o[1];
5452
+
5453
+ var postTaf = function postTaf(data) {
5454
+ return __awaiter(void 0, void 0, void 0, function () {
5455
+ return __generator(this, function (_a) {
5456
+ switch (_a.label) {
5457
+ case 0:
5458
+ return [4
5459
+ /*yield*/
5460
+ , postTafRequest(data)];
5461
+
5462
+ case 1:
5463
+ _a.sent(); // callback
5464
+
5465
+
5466
+ onPostTaf();
5467
+ return [2
5468
+ /*return*/
5469
+ ];
5470
+ }
5471
+ });
5472
+ });
5473
+ };
5474
+
5475
+ function onChangeTab(action, value) {
5476
+ return __awaiter(this, void 0, void 0, function () {
5477
+ var taf;
5478
+ return __generator(this, function (_a) {
5479
+ switch (_a.label) {
5480
+ case 0:
5481
+ if (!isFormDirty) return [3
5482
+ /*break*/
5483
+ , 6];
5484
+ _a.label = 1;
5485
+
5486
+ case 1:
5487
+ _a.trys.push([1, 4,, 5]);
5488
+
5489
+ return [4
5490
+ /*yield*/
5491
+ , onValidateForm()];
5492
+
5493
+ case 2:
5494
+ taf = _a.sent();
5495
+ return [4
5496
+ /*yield*/
5497
+ , postTaf({
5498
+ taf: taf,
5499
+ changeStatusTo: fromActionToStatus(tafActionToDraftAction(tafAction))
5500
+ })];
5501
+
5502
+ case 3:
5503
+ _a.sent();
5504
+
5505
+ action(value);
5506
+ return [3
5507
+ /*break*/
5508
+ , 5];
5086
5509
 
5087
- var _d = __read(React__default["default"].useState(sortTafTimeSlots(tafList)), 2),
5088
- _e = _d[0],
5089
- upcoming = _e.upcoming,
5090
- current = _e.current,
5091
- expired = _e.expired,
5092
- updateSortedTafs = _d[1];
5510
+ case 4:
5511
+ _a.sent();
5512
+ confirmDialog(CONFIRM_DIALOG_OPTIONS).then(function () {
5513
+ action(value);
5514
+ setError(null);
5515
+ });
5516
+ return [3
5517
+ /*break*/
5518
+ , 5];
5093
5519
 
5094
- var _f = __read(upcoming.slice(-1), 1),
5095
- lastUpcomingTaf = _f[0];
5520
+ case 5:
5521
+ return [3
5522
+ /*break*/
5523
+ , 7];
5096
5524
 
5097
- var _g = __read(React__default["default"].useState('UPCOMING'), 2),
5098
- timeSlot = _g[0],
5099
- setTimeSlot = _g[1];
5525
+ case 6:
5526
+ action(value);
5527
+ setError(null);
5528
+ _a.label = 7;
5100
5529
 
5101
- var _h = __read(React__default["default"].useState(upcoming), 2),
5102
- locations = _h[0],
5103
- setLocations = _h[1];
5530
+ case 7:
5531
+ return [2
5532
+ /*return*/
5533
+ ];
5534
+ }
5535
+ });
5536
+ });
5537
+ }
5104
5538
 
5105
- var _j = __read(React__default["default"].useState(0), 2),
5106
- activeTafIndex = _j[0],
5107
- setActiveTafIndex = _j[1];
5539
+ var onChangeLocationTab = function onChangeLocationTab(index) {
5540
+ onChangeTab(setActiveTafIndex, index);
5541
+ };
5108
5542
 
5109
5543
  var onChangeTimeSlot = function onChangeTimeSlot(newTimeSlot) {
5544
+ onChangeTab(changeTimeSlot, newTimeSlot);
5545
+ };
5546
+
5547
+ var changeTimeSlot = function changeTimeSlot(newTimeSlot) {
5110
5548
  setTimeSlot(newTimeSlot);
5111
5549
  setLocations(newTimeSlot === 'ACTIVE' ? current : upcoming);
5112
5550
  setActiveTafIndex(0);
@@ -5124,6 +5562,16 @@
5124
5562
  var newIndex = newActiveIndex !== -1 ? newActiveIndex : activeTafIndex;
5125
5563
  setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
5126
5564
  }, [tafList, setLocations]);
5565
+ React__default["default"].useEffect(function () {
5566
+ var cancelErrorTimeout = error && error.type === 'CANCELLED' ? setTimeout(function () {
5567
+ setError(null);
5568
+ }, 10000) : null;
5569
+ return function () {
5570
+ if (cancelErrorTimeout !== null) {
5571
+ clearTimeout(cancelErrorTimeout);
5572
+ }
5573
+ };
5574
+ }, [error, setError]);
5127
5575
 
5128
5576
  if (!tafList) {
5129
5577
  return null;
@@ -5166,7 +5614,7 @@
5166
5614
  xs: 12,
5167
5615
  sm: 9
5168
5616
  }, /*#__PURE__*/React__default["default"].createElement(TopTabs, {
5169
- tafFromBackend: lastUpcomingTaf,
5617
+ tafFromBackend: lastCurrentTaf,
5170
5618
  timeSlot: timeSlot,
5171
5619
  onChangeTimeSlot: onChangeTimeSlot
5172
5620
  }))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
@@ -5190,7 +5638,7 @@
5190
5638
  }, /*#__PURE__*/React__default["default"].createElement(LocationTabs, {
5191
5639
  tafList: locations,
5192
5640
  activeIndex: activeTafIndex,
5193
- onChangeTab: setActiveTafIndex,
5641
+ onChangeTab: onChangeLocationTab,
5194
5642
  timeSlot: timeSlot
5195
5643
  })), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
5196
5644
  item: true,
@@ -5198,8 +5646,6 @@
5198
5646
  }, /*#__PURE__*/React__default["default"].createElement(material.Card, {
5199
5647
  variant: "outlined",
5200
5648
  sx: {
5201
- padding: 1,
5202
- paddingTop: 0,
5203
5649
  marginBottom: '12px',
5204
5650
  position: 'relative'
5205
5651
  }
@@ -5214,24 +5660,50 @@
5214
5660
  activeTafIndex: activeTafIndex,
5215
5661
  index: index,
5216
5662
  tafFromBackend: tafFromBackend,
5217
- onPostTaf: onPostTaf
5663
+ isIssuesPaneOpen: isIssuesPaneOpen,
5664
+ setIsIssuesPaneOpen: onToggleIssuesPane,
5665
+ isFormDisabled: isFormDisabled,
5666
+ setIsFormDisabled: setIsFormDisabled,
5667
+ postTaf: postTaf,
5668
+ isLoading: isLoading,
5669
+ error: error
5218
5670
  });
5219
5671
  }))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
5220
5672
  item: true,
5221
- xs: 3,
5222
- sx: {
5223
- height: '100%'
5673
+ xs: 0,
5674
+ sm: 3,
5675
+ height: {
5676
+ xs: 0,
5677
+ sm: '100%'
5224
5678
  },
5225
- display: {
5226
- xs: 'none',
5227
- sm: 'block'
5679
+ width: {
5680
+ xs: 0,
5681
+ sm: '100%'
5228
5682
  }
5229
5683
  }, /*#__PURE__*/React__default["default"].createElement(TacOverview, {
5230
5684
  upcomingTafs: upcoming,
5231
5685
  currentTafs: current,
5232
5686
  expiredTafs: expired,
5233
- activeTaf: activeTaf
5234
- })))))));
5687
+ activeTaf: activeTaf,
5688
+ isFormDisabled: isFormDisabled
5689
+ })))))), /*#__PURE__*/React__default["default"].createElement(IssuesPaneWrapper, {
5690
+ handleClose: onCloseIssuesPane,
5691
+ isOpen: isIssuesPaneOpen,
5692
+ startPosition: startPosition
5693
+ }));
5694
+ };
5695
+
5696
+ var TafWrapper = function TafWrapper(_a) {
5697
+ var children = _a.children,
5698
+ props = __rest(_a, ["children"]);
5699
+
5700
+ return /*#__PURE__*/React__namespace.createElement(TafModuleProvider, __assign({}, props), /*#__PURE__*/React__namespace.createElement(shared.ConfirmationServiceProvider, null, /*#__PURE__*/React__namespace.createElement(formFields.ReactHookFormProvider, {
5701
+ options: {
5702
+ mode: 'onTouched',
5703
+ reValidateMode: 'onChange',
5704
+ criteriaMode: 'all'
5705
+ }
5706
+ }, children)));
5235
5707
  };
5236
5708
 
5237
5709
  var TafModule = function TafModule() {
@@ -5311,18 +5783,20 @@
5311
5783
  }), hasTafListError && /*#__PURE__*/React__namespace.createElement(shared.AlertBanner, {
5312
5784
  severity: "error",
5313
5785
  title: "An error has occurred while retrieving the list",
5314
- info: getTafListError.message
5786
+ info: getTafListError.message,
5787
+ dataTestId: "taf-list-error",
5788
+ shouldClose: true
5315
5789
  }), /*#__PURE__*/React__namespace.createElement(TafLayout, {
5316
5790
  tafList: tafList,
5317
5791
  onPostTaf: reFetchNewTafList
5318
5792
  }));
5319
5793
  };
5320
5794
 
5321
- var Wrapper = function Wrapper() {
5322
- return /*#__PURE__*/React__namespace.createElement(shared.ConfirmationServiceProvider, null, /*#__PURE__*/React__namespace.createElement(TafModule, null));
5795
+ var Wrapper = function Wrapper(props) {
5796
+ return /*#__PURE__*/React__namespace.createElement(TafWrapper, __assign({}, props), /*#__PURE__*/React__namespace.createElement(TafModule, null));
5323
5797
  };
5324
5798
 
5325
- var createApi = function createApi(url, appUrl, auth, setAuth, authTokenUrl, authClientId) {
5799
+ var createApi$1 = function createApi(url, appUrl, auth, setAuth, authTokenUrl, authClientId) {
5326
5800
  var axiosInstance = api.createApiInstance(url, appUrl, auth, setAuth, authTokenUrl, authClientId);
5327
5801
  return {
5328
5802
  // api data
@@ -5338,9 +5812,1064 @@
5338
5812
  };
5339
5813
  };
5340
5814
 
5341
- exports.TafFormWrapper = TafFormWrapper;
5815
+ var currentDate = moment__default["default"].utc().format('YYYY-MM-DD');
5816
+ var tomorrowDate = moment__default["default"].utc().add(1, 'day').format('YYYY-MM-DD');
5817
+ var airportPeriod = 6;
5818
+ var airportValidity = 40;
5819
+
5820
+ var validDateRange = function validDateRange(refHour, period) {
5821
+ var startHour = period * Math.floor(parseInt(refHour.format('HH'), 10) / period) % 24;
5822
+ var start = refHour.set({
5823
+ hour: startHour,
5824
+ minute: 0,
5825
+ second: 0
5826
+ });
5827
+ var end = start.clone().add(airportValidity, 'hours');
5828
+ return [start.format('YYYY-MM-DDTHH:mm:ss'), end.format('YYYY-MM-DDTHH:mm:ss')];
5829
+ };
5830
+
5831
+ var dateAdd = function dateAdd(refDateAsString, hours) {
5832
+ return moment__default["default"].utc(refDateAsString).add(hours, 'hours').format('YYYY-MM-DDTHH:mm:ss');
5833
+ };
5834
+
5835
+ var _a = __read(validDateRange(moment__default["default"].utc(), airportPeriod), 2),
5836
+ currentValidDateStart = _a[0],
5837
+ currentValidDateEnd = _a[1];
5838
+
5839
+ var _b = __read(validDateRange(moment__default["default"].utc().add(6, 'hours'), airportPeriod), 2),
5840
+ upcomingValidDateStart = _b[0],
5841
+ upcomingValidDateEnd = _b[1];
5842
+
5843
+ var _c = __read(validDateRange(moment__default["default"].utc().add(-6, 'hours'), airportPeriod), 2),
5844
+ expiredValidDateStart = _c[0],
5845
+ expiredValidDateEnd = _c[1];
5846
+
5847
+ var fakeTafList = [{
5848
+ creationDate: upcomingValidDateStart,
5849
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
5850
+ taf: {
5851
+ uuid: '5f9583fjdf0f337925',
5852
+ baseTime: upcomingValidDateStart,
5853
+ validDateStart: upcomingValidDateStart,
5854
+ validDateEnd: upcomingValidDateEnd,
5855
+ location: 'EHAM',
5856
+ status: 'NEW',
5857
+ type: 'NORMAL',
5858
+ messageType: 'ORG',
5859
+ baseForecast: {
5860
+ valid: {
5861
+ start: upcomingValidDateStart,
5862
+ end: upcomingValidDateEnd
5863
+ }
5864
+ }
5865
+ }
5866
+ }, {
5867
+ creationDate: upcomingValidDateStart,
5868
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
5869
+ taf: {
5870
+ uuid: '5f9583fjd111137925',
5871
+ baseTime: upcomingValidDateStart,
5872
+ validDateStart: upcomingValidDateStart,
5873
+ validDateEnd: upcomingValidDateEnd,
5874
+ location: 'EHRD',
5875
+ status: 'DRAFT',
5876
+ type: 'NORMAL',
5877
+ messageType: 'ORG',
5878
+ baseForecast: {
5879
+ valid: {
5880
+ start: upcomingValidDateStart,
5881
+ end: upcomingValidDateEnd
5882
+ },
5883
+ wind: {
5884
+ direction: 180,
5885
+ speed: 10,
5886
+ unit: 'KT'
5887
+ },
5888
+ cavOK: true
5889
+ }
5890
+ }
5891
+ }, {
5892
+ creationDate: upcomingValidDateStart,
5893
+ canbe: ['CANCELLED', 'AMENDED', 'DISCARDED'],
5894
+ taf: {
5895
+ uuid: '754905485',
5896
+ baseTime: upcomingValidDateStart,
5897
+ previousId: '5f9583fjdf45ff4330f337925',
5898
+ validDateStart: upcomingValidDateStart,
5899
+ validDateEnd: upcomingValidDateEnd,
5900
+ previousValidDateStart: upcomingValidDateStart,
5901
+ previousValidDateEnd: upcomingValidDateEnd,
5902
+ location: 'EHLE',
5903
+ status: 'DRAFT_AMENDED',
5904
+ type: 'NORMAL',
5905
+ messageType: 'AMD',
5906
+ baseForecast: {
5907
+ valid: {
5908
+ start: upcomingValidDateStart,
5909
+ end: upcomingValidDateEnd
5910
+ },
5911
+ visibility: {
5912
+ range: 600,
5913
+ unit: 'M'
5914
+ },
5915
+ wind: {
5916
+ direction: 180,
5917
+ speed: 10,
5918
+ unit: 'KT'
5919
+ },
5920
+ weather: {
5921
+ weather1: 'SN'
5922
+ },
5923
+ cloud: {
5924
+ cloud1: {
5925
+ coverage: 'BKN',
5926
+ height: 35
5927
+ }
5928
+ }
5929
+ },
5930
+ changeGroups: [{
5931
+ change: 'TEMPO',
5932
+ probability: 'PROB30',
5933
+ valid: {
5934
+ start: dateAdd(upcomingValidDateStart, 3),
5935
+ end: dateAdd(upcomingValidDateStart, 4)
5936
+ },
5937
+ visibility: {
5938
+ range: 100,
5939
+ unit: 'M'
5940
+ },
5941
+ cloud: {
5942
+ cloud1: {
5943
+ verticalVisibility: 5
5944
+ }
5945
+ }
5946
+ }]
5947
+ }
5948
+ }, {
5949
+ creationDate: upcomingValidDateStart,
5950
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
5951
+ taf: {
5952
+ uuid: '43545345345',
5953
+ issueDate: upcomingValidDateStart,
5954
+ baseTime: currentDate + "T18:00:00Z",
5955
+ validDateStart: currentDate + "T18:00:00Z",
5956
+ validDateEnd: upcomingValidDateEnd,
5957
+ previousId: 'jkdjkdfjkgdf',
5958
+ previousValidDateStart: upcomingValidDateStart,
5959
+ previousValidDateEnd: upcomingValidDateEnd,
5960
+ location: 'EHLE',
5961
+ status: 'CORRECTED',
5962
+ type: 'NORMAL',
5963
+ messageType: 'COR',
5964
+ baseForecast: {
5965
+ valid: {
5966
+ start: upcomingValidDateStart,
5967
+ end: upcomingValidDateEnd
5968
+ },
5969
+ wind: {
5970
+ direction: 350,
5971
+ speed: 46,
5972
+ gust: 67,
5973
+ unit: 'KT'
5974
+ },
5975
+ cavOK: true
5976
+ },
5977
+ changeGroups: [{
5978
+ change: 'BECMG',
5979
+ valid: {
5980
+ start: dateAdd(upcomingValidDateStart, 1),
5981
+ end: dateAdd(upcomingValidDateStart, 2)
5982
+ },
5983
+ visibility: {
5984
+ range: 1000,
5985
+ unit: 'M'
5986
+ },
5987
+ weather: {
5988
+ weather1: 'MIFG'
5989
+ },
5990
+ cloud: {
5991
+ cloud1: 'NSC'
5992
+ }
5993
+ }, {
5994
+ change: 'FM',
5995
+ valid: {
5996
+ start: dateAdd(upcomingValidDateStart, 2)
5997
+ },
5998
+ visibility: {
5999
+ range: 6000,
6000
+ unit: 'M'
6001
+ },
6002
+ weather: {
6003
+ weather1: '+SHRA'
6004
+ },
6005
+ cloud: {
6006
+ cloud1: {
6007
+ coverage: 'BKN',
6008
+ height: 40
6009
+ },
6010
+ cloud2: {
6011
+ coverage: 'OVC',
6012
+ height: 60,
6013
+ type: 'CB'
6014
+ }
6015
+ }
6016
+ }]
6017
+ }
6018
+ }, {
6019
+ creationDate: upcomingValidDateStart,
6020
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6021
+ taf: {
6022
+ uuid: '5f9583fjdf45ff4330f337925',
6023
+ issueDate: upcomingValidDateStart,
6024
+ baseTime: upcomingValidDateStart,
6025
+ validDateStart: upcomingValidDateStart,
6026
+ validDateEnd: upcomingValidDateEnd,
6027
+ location: 'EHGG',
6028
+ status: 'PUBLISHED',
6029
+ type: 'NORMAL',
6030
+ messageType: 'ORG',
6031
+ baseForecast: {
6032
+ valid: {
6033
+ start: upcomingValidDateEnd,
6034
+ end: upcomingValidDateEnd
6035
+ },
6036
+ visibility: {
6037
+ range: 600,
6038
+ unit: 'M'
6039
+ },
6040
+ wind: {
6041
+ direction: 180,
6042
+ speed: 10,
6043
+ unit: 'KT'
6044
+ },
6045
+ weather: {
6046
+ weather1: 'SN'
6047
+ },
6048
+ cloud: {
6049
+ cloud1: {
6050
+ coverage: 'BKN',
6051
+ height: 35
6052
+ }
6053
+ }
6054
+ },
6055
+ changeGroups: [{
6056
+ change: 'TEMPO',
6057
+ probability: 'PROB30',
6058
+ valid: {
6059
+ start: dateAdd(upcomingValidDateStart, 1),
6060
+ end: dateAdd(upcomingValidDateStart, 2)
6061
+ },
6062
+ visibility: {
6063
+ range: 200,
6064
+ unit: 'M'
6065
+ },
6066
+ cloud: {
6067
+ cloud1: {
6068
+ verticalVisibility: 5
6069
+ }
6070
+ }
6071
+ }]
6072
+ }
6073
+ }, {
6074
+ creationDate: upcomingValidDateStart,
6075
+ canbe: ['AMENDED'],
6076
+ taf: {
6077
+ uuid: '5464565464',
6078
+ previousId: '5445fghrfg3546456',
6079
+ issueDate: upcomingValidDateStart,
6080
+ baseTime: upcomingValidDateStart,
6081
+ validDateStart: upcomingValidDateStart,
6082
+ validDateEnd: upcomingValidDateEnd,
6083
+ previousValidDateStart: upcomingValidDateStart,
6084
+ previousValidDateEnd: upcomingValidDateEnd,
6085
+ location: 'EHBK',
6086
+ status: 'CANCELLED',
6087
+ type: 'NORMAL',
6088
+ messageType: 'CNL',
6089
+ baseForecast: {
6090
+ valid: {
6091
+ start: upcomingValidDateStart,
6092
+ end: upcomingValidDateEnd
6093
+ },
6094
+ visibility: {
6095
+ range: 600,
6096
+ unit: 'M'
6097
+ },
6098
+ wind: {
6099
+ direction: 180,
6100
+ speed: 10,
6101
+ unit: 'KT'
6102
+ },
6103
+ weather: {
6104
+ weather1: 'SN'
6105
+ },
6106
+ cloud: {
6107
+ cloud1: {
6108
+ coverage: 'BKN',
6109
+ height: 35
6110
+ }
6111
+ }
6112
+ }
6113
+ }
6114
+ }, {
6115
+ creationDate: upcomingValidDateStart,
6116
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6117
+ taf: {
6118
+ uuid: 'gh56734fghfgh',
6119
+ previousId: '8574jnf93475',
6120
+ issueDate: currentDate + "T16:16:00Z",
6121
+ baseTime: upcomingValidDateStart,
6122
+ validDateStart: upcomingValidDateStart,
6123
+ validDateEnd: upcomingValidDateEnd,
6124
+ previousValidDateStart: upcomingValidDateStart,
6125
+ previousValidDateEnd: upcomingValidDateEnd,
6126
+ location: 'TNCB',
6127
+ status: 'AMENDED',
6128
+ type: 'NORMAL',
6129
+ messageType: 'AMD',
6130
+ baseForecast: {
6131
+ valid: {
6132
+ start: currentDate + "T16:12:00Z",
6133
+ end: upcomingValidDateEnd
6134
+ },
6135
+ visibility: {
6136
+ range: 600,
6137
+ unit: 'M'
6138
+ },
6139
+ wind: {
6140
+ direction: 180,
6141
+ speed: 10,
6142
+ unit: 'KT'
6143
+ },
6144
+ weather: {
6145
+ weather1: 'SN'
6146
+ },
6147
+ cloud: {
6148
+ cloud1: {
6149
+ coverage: 'BKN',
6150
+ height: 35
6151
+ }
6152
+ }
6153
+ }
6154
+ }
6155
+ }, {
6156
+ creationDate: currentValidDateStart,
6157
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6158
+ taf: {
6159
+ uuid: 'giskdj09845872039',
6160
+ issueDate: currentValidDateStart,
6161
+ baseTime: currentValidDateStart,
6162
+ validDateStart: currentValidDateStart,
6163
+ validDateEnd: currentValidDateEnd,
6164
+ location: 'EHAM',
6165
+ status: 'PUBLISHED',
6166
+ type: 'NORMAL',
6167
+ messageType: 'ORG',
6168
+ baseForecast: {
6169
+ valid: {
6170
+ start: currentValidDateStart,
6171
+ end: currentValidDateEnd
6172
+ },
6173
+ visibility: {
6174
+ range: 500,
6175
+ unit: 'M'
6176
+ },
6177
+ wind: {
6178
+ direction: 200,
6179
+ speed: 20,
6180
+ gust: 35,
6181
+ unit: 'KT'
6182
+ },
6183
+ weather: {
6184
+ weather1: 'SN'
6185
+ },
6186
+ cloud: {
6187
+ cloud1: {
6188
+ coverage: 'BKN',
6189
+ height: 40
6190
+ }
6191
+ }
6192
+ }
6193
+ }
6194
+ }, {
6195
+ creationDate: currentValidDateStart,
6196
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6197
+ taf: {
6198
+ uuid: 'ghskdj09845872039',
6199
+ baseTime: currentValidDateStart,
6200
+ validDateStart: currentValidDateStart,
6201
+ validDateEnd: currentValidDateEnd,
6202
+ location: 'EHRD',
6203
+ status: 'NEW',
6204
+ type: 'NORMAL',
6205
+ messageType: 'ORG',
6206
+ baseForecast: {
6207
+ valid: {
6208
+ start: currentValidDateStart,
6209
+ end: currentValidDateEnd
6210
+ }
6211
+ }
6212
+ }
6213
+ }, {
6214
+ creationDate: currentValidDateStart,
6215
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6216
+ taf: {
6217
+ uuid: 'ghskdj09845872040',
6218
+ issueDate: currentValidDateStart,
6219
+ baseTime: currentValidDateStart,
6220
+ validDateStart: currentValidDateStart,
6221
+ validDateEnd: currentValidDateEnd,
6222
+ location: 'EHLE',
6223
+ status: 'NEW',
6224
+ type: 'NORMAL',
6225
+ messageType: 'ORG',
6226
+ baseForecast: {
6227
+ valid: {
6228
+ start: currentValidDateStart,
6229
+ end: currentValidDateEnd
6230
+ }
6231
+ }
6232
+ }
6233
+ }, {
6234
+ creationDate: currentDate + "T06:00:00Z",
6235
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6236
+ taf: {
6237
+ uuid: 'ghskdj09845872041',
6238
+ issueDate: currentValidDateStart,
6239
+ baseTime: currentValidDateStart,
6240
+ validDateStart: currentValidDateStart,
6241
+ validDateEnd: currentValidDateEnd,
6242
+ location: 'EHGG',
6243
+ status: 'NEW',
6244
+ type: 'NORMAL',
6245
+ messageType: 'ORG',
6246
+ baseForecast: {
6247
+ valid: {
6248
+ start: currentValidDateStart,
6249
+ end: currentValidDateEnd
6250
+ }
6251
+ }
6252
+ }
6253
+ }, {
6254
+ creationDate: currentDate + "T06:00:00Z",
6255
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6256
+ taf: {
6257
+ uuid: 'ghskdj09845872042',
6258
+ issueDate: currentValidDateStart,
6259
+ baseTime: currentValidDateStart,
6260
+ validDateStart: currentValidDateStart,
6261
+ validDateEnd: currentValidDateEnd,
6262
+ location: 'EHBK',
6263
+ status: 'NEW',
6264
+ type: 'NORMAL',
6265
+ messageType: 'ORG',
6266
+ baseForecast: {
6267
+ valid: {
6268
+ start: currentValidDateStart,
6269
+ end: currentValidDateEnd
6270
+ }
6271
+ }
6272
+ }
6273
+ }, {
6274
+ creationDate: currentDate + "T06:00:00Z",
6275
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6276
+ taf: {
6277
+ uuid: 'ghskdj09845872043',
6278
+ issueDate: currentValidDateStart,
6279
+ baseTime: currentValidDateStart,
6280
+ validDateStart: currentValidDateStart,
6281
+ validDateEnd: currentValidDateEnd,
6282
+ location: 'TNCB',
6283
+ status: 'NEW',
6284
+ type: 'NORMAL',
6285
+ messageType: 'ORG',
6286
+ baseForecast: {
6287
+ valid: {
6288
+ start: currentValidDateStart,
6289
+ end: currentValidDateEnd
6290
+ }
6291
+ }
6292
+ }
6293
+ }, {
6294
+ creationDate: expiredValidDateStart,
6295
+ canbe: [],
6296
+ taf: {
6297
+ uuid: 'sdkjhsdf90845890',
6298
+ issueDate: expiredValidDateStart,
6299
+ baseTime: expiredValidDateStart,
6300
+ validDateStart: expiredValidDateStart,
6301
+ validDateEnd: expiredValidDateEnd,
6302
+ location: 'EHAM',
6303
+ status: 'EXPIRED',
6304
+ type: 'NORMAL',
6305
+ messageType: 'ORG',
6306
+ baseForecast: {
6307
+ valid: {
6308
+ start: expiredValidDateStart,
6309
+ end: expiredValidDateEnd
6310
+ },
6311
+ cavOK: true,
6312
+ wind: {
6313
+ direction: 50,
6314
+ speed: 5,
6315
+ unit: 'KT'
6316
+ }
6317
+ },
6318
+ changeGroups: [{
6319
+ change: 'BECMG',
6320
+ valid: {
6321
+ start: dateAdd(expiredValidDateStart, 1),
6322
+ end: dateAdd(expiredValidDateStart, 4)
6323
+ },
6324
+ visibility: {
6325
+ range: 1000,
6326
+ unit: 'M'
6327
+ },
6328
+ weather: {
6329
+ weather1: 'MIFG'
6330
+ }
6331
+ }, {
6332
+ change: 'FM',
6333
+ valid: {
6334
+ start: dateAdd(expiredValidDateStart, 5)
6335
+ },
6336
+ visibility: {
6337
+ range: 6000,
6338
+ unit: 'M'
6339
+ },
6340
+ weather: {
6341
+ weather1: '+SHRA'
6342
+ },
6343
+ cloud: {
6344
+ cloud1: {
6345
+ coverage: 'BKN',
6346
+ height: 40
6347
+ },
6348
+ cloud2: {
6349
+ coverage: 'OVC',
6350
+ height: 60,
6351
+ type: 'CB'
6352
+ }
6353
+ }
6354
+ }]
6355
+ }
6356
+ }];
6357
+ var fakeNewTaf = {
6358
+ creationDate: currentDate + "T12:00:00Z",
6359
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6360
+ taf: {
6361
+ type: 'NORMAL',
6362
+ messageType: 'ORG',
6363
+ status: 'NEW',
6364
+ uuid: '5f9583fjdf0445332f337925',
6365
+ baseTime: currentDate + "T12:00:00Z",
6366
+ validDateStart: currentDate + "T12:00:00Z",
6367
+ validDateEnd: tomorrowDate + "T18:00:00Z",
6368
+ location: 'EHBK',
6369
+ baseForecast: {
6370
+ valid: {
6371
+ start: currentDate + "T12:00:00Z",
6372
+ end: tomorrowDate + "T18:00:00Z"
6373
+ }
6374
+ }
6375
+ }
6376
+ };
6377
+ ({
6378
+ creationDate: "2022-01-06T12:00:00Z",
6379
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6380
+ taf: __assign(__assign({}, fakeNewTaf.taf), {
6381
+ baseTime: "2022-01-06T12:00:00Z",
6382
+ validDateStart: "2022-01-06T12:00:00Z",
6383
+ validDateEnd: "2022-01-07T18:00:00Z",
6384
+ baseForecast: {
6385
+ valid: {
6386
+ start: "2022-01-06T12:00:00Z",
6387
+ end: "2022-01-07T18:00:00Z"
6388
+ }
6389
+ }
6390
+ })
6391
+ });
6392
+ var fakePublishedTaf = {
6393
+ creationDate: currentDate + "T12:00:00Z",
6394
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6395
+ taf: {
6396
+ uuid: 'slsdkjg-023895',
6397
+ issueDate: currentDate + "T12:00:00Z",
6398
+ baseTime: currentDate + "T12:00:00Z",
6399
+ validDateStart: currentDate + "T12:00:00Z",
6400
+ validDateEnd: tomorrowDate + "T18:00:00Z",
6401
+ location: 'EHLE',
6402
+ status: 'PUBLISHED',
6403
+ type: 'NORMAL',
6404
+ messageType: 'ORG',
6405
+ baseForecast: {
6406
+ valid: {
6407
+ start: currentDate + "T12:00:00Z",
6408
+ end: tomorrowDate + "T18:00:00Z"
6409
+ },
6410
+ wind: {
6411
+ direction: 50,
6412
+ speed: 5,
6413
+ unit: 'KT'
6414
+ },
6415
+ cavOK: true
6416
+ },
6417
+ changeGroups: [{
6418
+ change: 'FM',
6419
+ valid: {
6420
+ start: currentDate + "T12:00:00Z"
6421
+ },
6422
+ visibility: {
6423
+ range: 6000,
6424
+ unit: 'M'
6425
+ },
6426
+ weather: {
6427
+ weather1: '+SHRA'
6428
+ },
6429
+ wind: {
6430
+ direction: 10,
6431
+ speed: 10,
6432
+ unit: 'KT',
6433
+ gust: 35
6434
+ },
6435
+ cloud: {
6436
+ cloud1: {
6437
+ coverage: 'BKN',
6438
+ height: 40
6439
+ },
6440
+ cloud2: {
6441
+ coverage: 'OVC',
6442
+ height: 60,
6443
+ type: 'CB'
6444
+ }
6445
+ }
6446
+ }, {
6447
+ change: 'BECMG',
6448
+ valid: {
6449
+ start: currentDate + "T23:00:00Z",
6450
+ end: tomorrowDate + "T01:00:00Z"
6451
+ },
6452
+ wind: {
6453
+ direction: 150,
6454
+ speed: 5,
6455
+ unit: 'KT'
6456
+ },
6457
+ visibility: {
6458
+ range: 1000,
6459
+ unit: 'M'
6460
+ },
6461
+ weather: {
6462
+ weather1: 'MIFG'
6463
+ }
6464
+ }]
6465
+ }
6466
+ };
6467
+ ({
6468
+ creationDate: "2022-01-06T12:00:00Z",
6469
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6470
+ taf: __assign(__assign({}, fakePublishedTaf.taf), {
6471
+ location: 'EHGG',
6472
+ baseTime: "2022-01-06T12:00:00Z",
6473
+ issueDate: "2022-01-06T12:00:00Z",
6474
+ validDateStart: "2022-01-06T12:00:00Z",
6475
+ validDateEnd: "2022-01-07T18:00:00Z",
6476
+ baseForecast: __assign(__assign({}, fakePublishedTaf.taf.baseForecast), {
6477
+ valid: {
6478
+ start: "2022-01-06T12:00:00Z",
6479
+ end: "2022-01-07T18:00:00Z"
6480
+ }
6481
+ }),
6482
+ changeGroups: [{
6483
+ change: 'FM',
6484
+ valid: {
6485
+ start: "2022-01-06T12:00:00Z"
6486
+ },
6487
+ visibility: {
6488
+ range: 6000,
6489
+ unit: 'M'
6490
+ },
6491
+ weather: {
6492
+ weather1: '+SHRA'
6493
+ },
6494
+ wind: {
6495
+ direction: 10,
6496
+ speed: 10,
6497
+ unit: 'KT',
6498
+ gust: 35
6499
+ },
6500
+ cloud: {
6501
+ cloud1: {
6502
+ coverage: 'BKN',
6503
+ height: 40
6504
+ },
6505
+ cloud2: {
6506
+ coverage: 'OVC',
6507
+ height: 60,
6508
+ type: 'CB'
6509
+ }
6510
+ }
6511
+ }, {
6512
+ change: 'BECMG',
6513
+ valid: {
6514
+ start: "2022-01-06T23:00:00Z",
6515
+ end: "2022-01-07T00:00:00Z"
6516
+ },
6517
+ wind: {
6518
+ direction: 150,
6519
+ speed: 5,
6520
+ unit: 'KT'
6521
+ },
6522
+ visibility: {
6523
+ range: 1000,
6524
+ unit: 'M'
6525
+ },
6526
+ weather: {
6527
+ weather1: 'MIFG'
6528
+ }
6529
+ }]
6530
+ })
6531
+ });
6532
+ var fakeDraftTaf = {
6533
+ creationDate: currentDate + "T18:00:00Z",
6534
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6535
+ taf: {
6536
+ uuid: '5f9583fjdf0f337925',
6537
+ baseTime: currentDate + "T18:00:00Z",
6538
+ validDateStart: currentDate + "T18:00:00Z",
6539
+ validDateEnd: tomorrowDate + "T23:59:00Z",
6540
+ location: 'EHLE',
6541
+ status: 'DRAFT',
6542
+ type: 'NORMAL',
6543
+ messageType: 'ORG',
6544
+ baseForecast: {
6545
+ valid: {
6546
+ start: currentDate + "T18:00:00Z",
6547
+ end: tomorrowDate + "T23:59:00Z"
6548
+ },
6549
+ wind: {
6550
+ direction: 150,
6551
+ speed: 5,
6552
+ unit: 'KT'
6553
+ },
6554
+ visibility: {
6555
+ range: 1000,
6556
+ unit: 'M'
6557
+ },
6558
+ weather: {
6559
+ weather1: 'BCFG'
6560
+ },
6561
+ cloud: {
6562
+ cloud1: {
6563
+ coverage: 'FEW',
6564
+ height: 15
6565
+ }
6566
+ }
6567
+ }
6568
+ }
6569
+ };
6570
+ ({
6571
+ creationDate: "2022-01-06T18:00:00Z",
6572
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6573
+ taf: __assign(__assign({}, fakeDraftTaf.taf), {
6574
+ baseTime: "2022-01-06T18:00:00Z",
6575
+ validDateStart: "2022-01-06T18:00:00Z",
6576
+ validDateEnd: "2022-01-07T23:59:00Z",
6577
+ baseForecast: __assign(__assign({}, fakeDraftTaf.taf.baseForecast), {
6578
+ valid: {
6579
+ start: "2022-01-06T18:00:00Z",
6580
+ end: "2022-01-07T23:59:00Z"
6581
+ }
6582
+ })
6583
+ })
6584
+ });
6585
+ var fakeDraftAmendmentTaf = {
6586
+ creationDate: currentDate + "T14:00:00Z",
6587
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6588
+ taf: {
6589
+ uuid: '954905487',
6590
+ previousId: '5f9583fjdf45ff4330f337925',
6591
+ issueDate: currentDate + "T14:00:00Z",
6592
+ baseTime: currentDate + "T12:00:00Z",
6593
+ validDateStart: currentDate + "T14:00:00Z",
6594
+ validDateEnd: tomorrowDate + "T18:00:00Z",
6595
+ previousValidDateStart: currentDate + "T12:00:00Z",
6596
+ previousValidDateEnd: tomorrowDate + "T18:00:00Z",
6597
+ location: 'EHAM',
6598
+ status: 'DRAFT_AMENDED',
6599
+ type: 'NORMAL',
6600
+ messageType: 'AMD',
6601
+ baseForecast: {
6602
+ valid: {
6603
+ start: currentDate + "T14:00:00Z",
6604
+ end: tomorrowDate + "T18:00:00Z"
6605
+ },
6606
+ visibility: {
6607
+ range: 600,
6608
+ unit: 'M'
6609
+ },
6610
+ wind: {
6611
+ direction: 180,
6612
+ speed: 10,
6613
+ unit: 'KT'
6614
+ },
6615
+ weather: {
6616
+ weather1: 'SN'
6617
+ },
6618
+ cloud: {
6619
+ cloud1: {
6620
+ coverage: 'BKN',
6621
+ height: 35
6622
+ }
6623
+ }
6624
+ },
6625
+ changeGroups: [{
6626
+ change: 'TEMPO',
6627
+ probability: 'PROB30',
6628
+ valid: {
6629
+ start: currentDate + "T15:00:00Z",
6630
+ end: currentDate + "T16:00:00Z"
6631
+ },
6632
+ visibility: {
6633
+ range: 100,
6634
+ unit: 'M'
6635
+ },
6636
+ cloud: {
6637
+ cloud1: {
6638
+ verticalVisibility: 5
6639
+ }
6640
+ }
6641
+ }]
6642
+ }
6643
+ };
6644
+
6645
+ ({
6646
+ creationDate: "2022-01-06T14:00:00Z",
6647
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6648
+ taf: __assign(__assign({}, fakeDraftAmendmentTaf.taf), {
6649
+ location: 'EHRD',
6650
+ issueDate: "2022-01-06T14:00:00Z",
6651
+ baseTime: "2022-01-06T12:00:00Z",
6652
+ validDateStart: "2022-01-06T14:00:00Z",
6653
+ validDateEnd: "2022-01-07T18:00:00Z",
6654
+ previousValidDateStart: "2022-01-06T12:00:00Z",
6655
+ previousValidDateEnd: "2022-01-07T18:00:00Z",
6656
+ baseForecast: __assign(__assign({}, fakeDraftAmendmentTaf.taf.baseForecast), {
6657
+ valid: {
6658
+ start: "2022-01-06T14:00:00Z",
6659
+ end: "2022-01-07T18:00:00Z"
6660
+ }
6661
+ }),
6662
+ changeGroups: []
6663
+ })
6664
+ });
6665
+ var fakeAmendmentTaf = {
6666
+ creationDate: currentDate + "T14:00:00Z",
6667
+ canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
6668
+ taf: {
6669
+ uuid: '754905486',
6670
+ previousId: '5f9583fjdf45ff4330f337925',
6671
+ issueDate: currentDate + "T14:00:00Z",
6672
+ baseTime: currentDate + "T12:00:00Z",
6673
+ validDateStart: currentDate + "T14:00:00Z",
6674
+ validDateEnd: tomorrowDate + "T18:00:00Z",
6675
+ previousValidDateStart: currentDate + "T12:00:00Z",
6676
+ previousValidDateEnd: tomorrowDate + "T18:00:00Z",
6677
+ location: 'EHAM',
6678
+ status: 'AMENDED',
6679
+ type: 'NORMAL',
6680
+ messageType: 'AMD',
6681
+ baseForecast: {
6682
+ valid: {
6683
+ start: currentDate + "T14:00:00Z",
6684
+ end: tomorrowDate + "T18:00:00Z"
6685
+ },
6686
+ visibility: {
6687
+ range: 600,
6688
+ unit: 'M'
6689
+ },
6690
+ wind: {
6691
+ direction: 180,
6692
+ speed: 10,
6693
+ unit: 'KT'
6694
+ },
6695
+ weather: {
6696
+ weather1: 'SN'
6697
+ },
6698
+ cloud: {
6699
+ cloud1: {
6700
+ coverage: 'BKN',
6701
+ height: 35
6702
+ }
6703
+ }
6704
+ }
6705
+ }
6706
+ };
6707
+
6708
+ ({
6709
+ creationDate: "2022-01-06T14:00:00Z",
6710
+ canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
6711
+ taf: __assign(__assign({}, fakeAmendmentTaf.taf), {
6712
+ uuid: '7549058980',
6713
+ issueDate: "2022-01-06T14:00:00Z",
6714
+ baseTime: "2022-01-06T12:00:00Z",
6715
+ validDateStart: "2022-01-06T14:00:00Z",
6716
+ validDateEnd: "2022-01-07T18:00:00Z",
6717
+ previousValidDateStart: "2022-01-06T12:00:00Z",
6718
+ previousValidDateEnd: "2022-01-07T18:00:00Z",
6719
+ baseForecast: __assign(__assign({}, fakeAmendmentTaf.taf.baseForecast), {
6720
+ valid: {
6721
+ start: "2022-01-06T14:00:00Z",
6722
+ end: "2022-01-07T18:00:00Z"
6723
+ }
6724
+ })
6725
+ })
6726
+ });
6727
+
6728
+ var fakeTafTac = 'TAF EHAM 0812/0918 20020G35KT 0500 SN BKN040\nBECMG 0814/0816 0700 BKN001=';
6729
+
6730
+ var fakePromise = function fakePromise(withRandomError) {
6731
+ return new Promise(function (resolve, reject) {
6732
+ setTimeout(function () {
6733
+ if (!withRandomError) return resolve();
6734
+ var randomError = Math.floor(Math.random() * 4) + 1;
6735
+ return randomError === 4 ? reject(new Error('something went wrong')) : resolve();
6736
+ }, 300);
6737
+ });
6738
+ };
6739
+
6740
+ var fakeAxiosInstance = {
6741
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6742
+ get: function get(_url, _params) {
6743
+ return fakePromise(false);
6744
+ },
6745
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6746
+ post: function post(_url, _params) {
6747
+ return fakePromise(false);
6748
+ }
6749
+ };
6750
+ var createApi = function createApi() {
6751
+ return {
6752
+ getTafList: function getTafList() {
6753
+ // eslint-disable-next-line no-console
6754
+ console.log('Retrieving new TAF list');
6755
+ return fakeAxiosInstance.get('/taflist').then(function () {
6756
+ return {
6757
+ data: __spreadArray([], __read(fakeTafList))
6758
+ };
6759
+ });
6760
+ },
6761
+ getTAC: function getTAC() {
6762
+ // eslint-disable-next-line no-console
6763
+ return fakeAxiosInstance.post('/taf2tac').then(function () {
6764
+ return {
6765
+ data: fakeTafTac
6766
+ };
6767
+ });
6768
+ },
6769
+ postTaf: function postTaf(_postTaf) {
6770
+ // eslint-disable-next-line no-console
6771
+ console.log("The new status of the taf will be " + _postTaf.changeStatusTo); // eslint-disable-next-line no-console
6772
+
6773
+ console.log('form has been posted with following values:', _postTaf.taf);
6774
+ return fakeAxiosInstance.post('/taf', _postTaf);
6775
+ }
6776
+ };
6777
+ };
6778
+
6779
+ /* *
6780
+ * Licensed under the Apache License, Version 2.0 (the "License");
6781
+ * you may not use this file except in compliance with the License.
6782
+ * You may obtain a copy of the License at
6783
+ *
6784
+ * http://www.apache.org/licenses/LICENSE-2.0
6785
+ *
6786
+ * Unless required by applicable law or agreed to in writing, software
6787
+ * distributed under the License is distributed on an "AS IS" BASIS,
6788
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6789
+ * See the License for the specific language governing permissions and
6790
+ * limitations under the License.
6791
+ *
6792
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
6793
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
6794
+ * */
6795
+ var tafScreenPreset = {
6796
+ id: 'screenConfigTaf',
6797
+ title: 'TAF',
6798
+ views: {
6799
+ byId: {
6800
+ taf: {
6801
+ title: 'TAF',
6802
+ componentType: 'TafModule',
6803
+ initialProps: {}
6804
+ }
6805
+ },
6806
+ allIds: ['taf']
6807
+ },
6808
+ syncGroups: [],
6809
+ mosaicNode: 'taf'
6810
+ };
6811
+ var TafApiWrapper = function TafApiWrapper(_a) {
6812
+ var config = _a.config,
6813
+ auth = _a.auth,
6814
+ onSetAuth = _a.onSetAuth,
6815
+ onPreventCloseView = _a.onPreventCloseView;
6816
+ return config ? /*#__PURE__*/React__namespace.createElement(api.ApiProvider, {
6817
+ baseURL: config.baseUrl,
6818
+ appURL: config.appUrl,
6819
+ auth: auth,
6820
+ onSetAuth: onSetAuth,
6821
+ createApi: createApi$1,
6822
+ authTokenUrl: config.authTokenUrl,
6823
+ authClientId: config.authClientId
6824
+ }, /*#__PURE__*/React__namespace.createElement(shared.ErrorBoundary, null, /*#__PURE__*/React__namespace.createElement(Wrapper, {
6825
+ onPreventCloseView: onPreventCloseView
6826
+ }))) : null;
6827
+ };
6828
+ var componentsLookUp = function componentsLookUp(payload, _a, // TODO: find a good way to type this module without the apps complaining
6829
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
6830
+ ConnectedModuleWrapper) {
6831
+ var config = _a.config,
6832
+ auth = _a.auth,
6833
+ onSetAuth = _a.onSetAuth;
6834
+
6835
+ if (ConnectedModuleWrapper === void 0) {
6836
+ ConnectedModuleWrapper = null;
6837
+ }
6838
+
6839
+ var componentType = payload.componentType;
6840
+
6841
+ switch (componentType) {
6842
+ case 'TafModule':
6843
+ if (ConnectedModuleWrapper) {
6844
+ return /*#__PURE__*/React__namespace.createElement(ConnectedModuleWrapper, {
6845
+ component: TafApiWrapper,
6846
+ payload: payload,
6847
+ "data-testid": "tafmodule",
6848
+ config: config,
6849
+ auth: auth,
6850
+ onSetAuth: onSetAuth
6851
+ });
6852
+ }
6853
+
6854
+ return /*#__PURE__*/React__namespace.createElement(TafApiWrapper, {
6855
+ "data-testid": "tafmodule",
6856
+ config: config,
6857
+ auth: auth,
6858
+ onSetAuth: onSetAuth
6859
+ });
6860
+
6861
+ default:
6862
+ return null;
6863
+ }
6864
+ };
6865
+
6866
+ exports.TafApiWrapper = TafApiWrapper;
6867
+ exports.TafForm = TafForm;
5342
6868
  exports.TafModule = Wrapper;
5343
- exports.createApi = createApi;
6869
+ exports.componentsLookUp = componentsLookUp;
6870
+ exports.createApi = createApi$1;
6871
+ exports.createFakeApi = createApi;
6872
+ exports.tafScreenPreset = tafScreenPreset;
5344
6873
 
5345
6874
  Object.defineProperty(exports, '__esModule', { value: true });
5346
6875