@opengeoweb/taf 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
 
@@ -2218,9 +2218,10 @@
2218
2218
  .filter(function (value) {
2219
2219
  return Object.keys(value).length;
2220
2220
  });
2221
+ var parsedBaseForecast = productToPost.baseForecast && parseFormValues(productToPost.baseForecast, tafStart, tafEnd);
2221
2222
 
2222
2223
  var parsedFormValues = __assign(__assign({}, productToPost), {
2223
- baseForecast: parseFormValues(productToPost.baseForecast, tafStart, tafEnd),
2224
+ baseForecast: parsedBaseForecast,
2224
2225
  changeGroups: parsedChangeGroups
2225
2226
  });
2226
2227
 
@@ -3486,6 +3487,170 @@
3486
3487
  }, /*#__PURE__*/React__default["default"].createElement(iconsMaterial.DragIndicator, null));
3487
3488
  };
3488
3489
 
3490
+ /* *
3491
+ * Licensed under the Apache License, Version 2.0 (the "License");
3492
+ * you may not use this file except in compliance with the License.
3493
+ * You may obtain a copy of the License at
3494
+ *
3495
+ * http://www.apache.org/licenses/LICENSE-2.0
3496
+ *
3497
+ * Unless required by applicable law or agreed to in writing, software
3498
+ * distributed under the License is distributed on an "AS IS" BASIS,
3499
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3500
+ * See the License for the specific language governing permissions and
3501
+ * limitations under the License.
3502
+ *
3503
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3504
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
3505
+ * */
3506
+ var getCustomError = function getCustomError(error) {
3507
+ var name = error.ref.name;
3508
+ var isChangeGroup = name.includes('changeGroups');
3509
+ var matchRowNumber = name.match(/\[(.*?)\]/);
3510
+ var row = matchRowNumber ? parseInt(matchRowNumber[1], 10) : null;
3511
+ return __assign(__assign({}, error), {
3512
+ isChangeGroup: isChangeGroup,
3513
+ row: row
3514
+ });
3515
+ };
3516
+ var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
3517
+ switch (sumOfErrors) {
3518
+ case 0:
3519
+ return '0 issues';
3520
+
3521
+ case 1:
3522
+ return '1 issue';
3523
+
3524
+ default:
3525
+ return sumOfErrors + " issues";
3526
+ }
3527
+ };
3528
+
3529
+ var getErrorValues = function getErrorValues(fieldErrors) {
3530
+ if (!fieldErrors) return [];
3531
+ return Object.keys(fieldErrors).reduce(function (list, key) {
3532
+ var error = __assign({}, fieldErrors[key]);
3533
+
3534
+ if (error.ref) {
3535
+ return list.concat(getCustomError(error));
3536
+ }
3537
+
3538
+ return list.concat(getErrorValues(error));
3539
+ }, []);
3540
+ };
3541
+
3542
+ var filterDuplicateErrors = function filterDuplicateErrors(errors) {
3543
+ return errors.reduce(function (list, error) {
3544
+ // check on type validateRequiredSub and validateRequiredMainOptional since these are giving 'duplicates'
3545
+ if (error.type === 'validateRequiredSub') {
3546
+ var exist = list.find(function (e) {
3547
+ return e.type === 'validateRequiredSub' && e.row === error.row;
3548
+ });
3549
+ return exist ? list : list.concat(error);
3550
+ }
3551
+
3552
+ if (error.type === 'validateRequiredMainOptional') {
3553
+ var exist = list.find(function (e) {
3554
+ return e.type === 'validateRequiredMainOptional' && e.row === error.row;
3555
+ });
3556
+ return exist ? list : list.concat(error);
3557
+ }
3558
+
3559
+ return list.concat(error);
3560
+ }, []);
3561
+ };
3562
+ var getErrors = function getErrors(errors) {
3563
+ var errorList = Object.keys(errors).reduce(function (list, key) {
3564
+ var errorValue = errors[key];
3565
+
3566
+ if (Array.isArray(errorValue)) {
3567
+ var errorValues = errorValue.reduce(function (l, i) {
3568
+ return l.concat(getErrorValues(i));
3569
+ }, []);
3570
+ return list.concat.apply(list, __spreadArray([], __read(errorValues)));
3571
+ }
3572
+
3573
+ return list.concat(getErrorValues(errorValue));
3574
+ }, []);
3575
+ return errorList;
3576
+ };
3577
+
3578
+ /* *
3579
+ * Licensed under the Apache License, Version 2.0 (the "License");
3580
+ * you may not use this file except in compliance with the License.
3581
+ * You may obtain a copy of the License at
3582
+ *
3583
+ * http://www.apache.org/licenses/LICENSE-2.0
3584
+ *
3585
+ * Unless required by applicable law or agreed to in writing, software
3586
+ * distributed under the License is distributed on an "AS IS" BASIS,
3587
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3588
+ * See the License for the specific language governing permissions and
3589
+ * limitations under the License.
3590
+ *
3591
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3592
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
3593
+ * */
3594
+
3595
+ var IssuesButton = function IssuesButton(_a) {
3596
+ var _b = _a.errors,
3597
+ errors = _b === void 0 ? {} : _b,
3598
+ _c = _a.isIssuesPaneOpen,
3599
+ isIssuesPaneOpen = _c === void 0 ? false : _c,
3600
+ _d = _a.setIsIssuesPaneOpen,
3601
+ setIsIssuesPaneOpen = _d === void 0 ? function () {
3602
+ return null;
3603
+ } : _d;
3604
+ var errorList = filterDuplicateErrors(getErrors(errors));
3605
+ var totalErrors = errorList.length;
3606
+ var errorStatus = totalErrors > 0 ? 'error' : 'success';
3607
+ var buttonColor = "geowebColors.functional." + errorStatus;
3608
+
3609
+ var toggleIssuesPane = function toggleIssuesPane(newPosition) {
3610
+ return setIsIssuesPaneOpen(!isIssuesPaneOpen, newPosition);
3611
+ };
3612
+
3613
+ var onClickButton = function onClickButton(event) {
3614
+ var _a;
3615
+
3616
+ var _b = event.currentTarget.getBoundingClientRect(),
3617
+ left = _b.left,
3618
+ top = _b.top;
3619
+
3620
+ var parentOffset = ((_a = document.getElementById('tafmodule')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || {
3621
+ top: 0,
3622
+ left: 0
3623
+ };
3624
+ var newPosition = {
3625
+ left: left - parentOffset.left + 100,
3626
+ top: top - parentOffset.top
3627
+ };
3628
+ toggleIssuesPane(newPosition);
3629
+ };
3630
+
3631
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
3632
+ title: "View details"
3633
+ }, /*#__PURE__*/React__namespace.createElement(material.Chip, {
3634
+ "data-testid": "issuesButton",
3635
+ className: "status-" + errorStatus,
3636
+ size: "small",
3637
+ label: getIssuesLabel(totalErrors),
3638
+ onClick: onClickButton,
3639
+ sx: {
3640
+ width: '74px',
3641
+ color: '#ffffff',
3642
+ backgroundColor: buttonColor,
3643
+ '&:hover': {
3644
+ backgroundColor: buttonColor
3645
+ },
3646
+ '&:focus': {
3647
+ backgroundColor: buttonColor
3648
+ },
3649
+ fontSize: 12
3650
+ }
3651
+ }));
3652
+ };
3653
+
3489
3654
  var ThumbsUp = function ThumbsUp(props) {
3490
3655
  return /*#__PURE__*/React__default["default"].createElement(material.SvgIcon, __assign({
3491
3656
  fontSize: "inherit",
@@ -3572,12 +3737,40 @@
3572
3737
  return index + 1 + ". " + fieldErrorTitle + ": " + getErrorDefaultMessage(error);
3573
3738
  };
3574
3739
  var MODAL_DIALOG_ELEMENT = 'modal-dialog';
3740
+ var useIssuesPane = function useIssuesPane() {
3741
+ var _a = __read(React__namespace.useState(false), 2),
3742
+ isIssuesPaneOpen = _a[0],
3743
+ setIsIssuesPaneOpen = _a[1];
3744
+
3745
+ var _b = __read(React__namespace.useState(null), 2),
3746
+ startPosition = _b[0],
3747
+ setStartPosition = _b[1];
3748
+
3749
+ var onToggleIssuesPane = function onToggleIssuesPane(isOpen, newPosition) {
3750
+ if (!startPosition) {
3751
+ setStartPosition(newPosition);
3752
+ }
3753
+
3754
+ setIsIssuesPaneOpen(isOpen);
3755
+ };
3756
+
3757
+ var onCloseIssuesPane = function onCloseIssuesPane() {
3758
+ return setIsIssuesPaneOpen(false);
3759
+ };
3760
+
3761
+ return {
3762
+ isIssuesPaneOpen: isIssuesPaneOpen,
3763
+ startPosition: startPosition,
3764
+ onToggleIssuesPane: onToggleIssuesPane,
3765
+ onCloseIssuesPane: onCloseIssuesPane
3766
+ };
3767
+ };
3575
3768
 
3576
3769
  var IssuesPane = function IssuesPane(_a) {
3577
- var isOpen = _a.isOpen,
3578
- handleClose = _a.handleClose,
3579
- _b = _a.errorList,
3770
+ var _b = _a.errorList,
3580
3771
  errorList = _b === void 0 ? [] : _b,
3772
+ isOpen = _a.isOpen,
3773
+ handleClose = _a.handleClose,
3581
3774
  _c = _a.startPosition,
3582
3775
  startPosition = _c === void 0 ? {
3583
3776
  left: 20,
@@ -3620,204 +3813,96 @@
3620
3813
  }))), rootElement);
3621
3814
  };
3622
3815
 
3623
- var getCustomError = function getCustomError(error) {
3624
- var name = error.ref.name;
3625
- var isChangeGroup = name.includes('changeGroups');
3626
- var matchRowNumber = name.match(/\[(.*?)\]/);
3627
- var row = matchRowNumber ? parseInt(matchRowNumber[1], 10) : null;
3628
- return __assign(__assign({}, error), {
3629
- isChangeGroup: isChangeGroup,
3630
- row: row
3631
- });
3632
- };
3633
-
3634
- var getIssuesLabel = function getIssuesLabel(sumOfErrors) {
3635
- switch (sumOfErrors) {
3636
- case 0:
3637
- return '0 issues';
3638
-
3639
- case 1:
3640
- return '1 issue';
3641
-
3642
- default:
3643
- return sumOfErrors + " issues";
3644
- }
3645
- };
3646
-
3647
- var getErrorValues = function getErrorValues(fieldErrors) {
3648
- if (!fieldErrors) return [];
3649
- return Object.keys(fieldErrors).reduce(function (list, key) {
3650
- var error = __assign({}, fieldErrors[key]);
3651
-
3652
- if (error.ref) {
3653
- return list.concat(getCustomError(error));
3654
- }
3655
-
3656
- return list.concat(getErrorValues(error));
3657
- }, []);
3658
- };
3659
-
3660
- var filterDuplicateErrors = function filterDuplicateErrors(errors) {
3661
- return errors.reduce(function (list, error) {
3662
- // check on type validateRequiredSub and validateRequiredMainOptional since these are giving 'duplicates'
3663
- if (error.type === 'validateRequiredSub') {
3664
- var exist = list.find(function (e) {
3665
- return e.type === 'validateRequiredSub' && e.row === error.row;
3666
- });
3667
- return exist ? list : list.concat(error);
3668
- }
3669
-
3670
- if (error.type === 'validateRequiredMainOptional') {
3671
- var exist = list.find(function (e) {
3672
- return e.type === 'validateRequiredMainOptional' && e.row === error.row;
3673
- });
3674
- return exist ? list : list.concat(error);
3675
- }
3676
-
3677
- return list.concat(error);
3678
- }, []);
3679
- };
3680
-
3681
- var getErrors = function getErrors(errors) {
3682
- var errorList = Object.keys(errors).reduce(function (list, key) {
3683
- var errorValue = errors[key];
3684
-
3685
- if (Array.isArray(errorValue)) {
3686
- var errorValues = errorValue.reduce(function (l, i) {
3687
- return l.concat(getErrorValues(i));
3688
- }, []);
3689
- return list.concat.apply(list, __spreadArray([], __read(errorValues)));
3690
- }
3816
+ var fromStatusToAction = function fromStatusToAction(tafStatus) {
3817
+ switch (tafStatus) {
3818
+ case 'DRAFT':
3819
+ return 'DRAFT';
3691
3820
 
3692
- return list.concat(getErrorValues(errorValue));
3693
- }, []);
3694
- return errorList;
3695
- };
3821
+ case 'DRAFT_AMENDED':
3822
+ return 'DRAFT_AMEND';
3696
3823
 
3697
- var IssuesButton = function IssuesButton(_a) {
3698
- var _b = _a.errors,
3699
- errors = _b === void 0 ? {} : _b;
3700
- var errorList = filterDuplicateErrors(getErrors(errors));
3701
- var totalErrors = errorList.length;
3702
- var errorStatus = totalErrors > 0 ? 'error' : 'success';
3703
- var buttonColor = "geowebColors.functional." + errorStatus;
3824
+ case 'DRAFT_CORRECTED':
3825
+ return 'DRAFT_CORRECT';
3704
3826
 
3705
- var _c = __read(React__namespace.useState(false), 2),
3706
- isIssuesPaneOpen = _c[0],
3707
- setIsIssuesPaneOpen = _c[1];
3827
+ case 'PUBLISHED':
3828
+ return 'PUBLISH';
3708
3829
 
3709
- var toggleIssuesPane = function toggleIssuesPane() {
3710
- return setIsIssuesPaneOpen(!isIssuesPaneOpen);
3711
- };
3830
+ case 'AMENDED':
3831
+ return 'AMEND';
3712
3832
 
3713
- var _d = __read(React__namespace.useState({
3714
- left: 0,
3715
- top: 0
3716
- }), 2),
3717
- startPosition = _d[0],
3718
- setStartPosition = _d[1];
3833
+ case 'CORRECTED':
3834
+ return 'CORRECT';
3719
3835
 
3720
- var onClickButton = function onClickButton(event) {
3721
- var _a;
3836
+ case 'CANCELLED':
3837
+ return 'CANCEL';
3722
3838
 
3723
- var _b = event.currentTarget.getBoundingClientRect(),
3724
- left = _b.left,
3725
- top = _b.top;
3839
+ default:
3840
+ return 'NEW';
3841
+ }
3842
+ }; // prevents default functionality
3726
3843
 
3727
- var parentOffset = ((_a = document.getElementById('tafmodule')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || {
3728
- top: 0,
3729
- left: 0
3730
- };
3731
- var newPosition = {
3732
- left: left - parentOffset.left + 100,
3733
- top: top - parentOffset.top
3734
- };
3735
- setStartPosition(newPosition);
3736
- toggleIssuesPane();
3737
- };
3738
-
3739
- return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
3740
- title: "View details"
3741
- }, /*#__PURE__*/React__namespace.createElement(material.Chip, {
3742
- "data-testid": "issuesButton",
3743
- className: "status-" + errorStatus,
3744
- size: "small",
3745
- label: getIssuesLabel(totalErrors),
3746
- onClick: onClickButton,
3747
- sx: {
3748
- width: '74px',
3749
- color: '#ffffff',
3750
- backgroundColor: buttonColor,
3751
- '&:hover': {
3752
- backgroundColor: buttonColor
3753
- },
3754
- '&:focus': {
3755
- backgroundColor: buttonColor
3756
- },
3757
- fontSize: 12
3758
- }
3759
- })), /*#__PURE__*/React__namespace.createElement(IssuesPane, {
3760
- errorList: errorList,
3761
- handleClose: toggleIssuesPane,
3762
- isOpen: isIssuesPaneOpen,
3763
- startPosition: startPosition
3764
- }));
3765
- };
3766
3844
 
3767
3845
  var noop = function noop() {};
3768
3846
 
3769
3847
  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,
3848
+ var _b = _a.isDisabled,
3849
+ isDefaultDisabled = _b === void 0 ? false : _b,
3775
3850
  tafFromBackend = _a.tafFromBackend,
3776
3851
  _c = _a.onFormAction,
3777
3852
  onFormAction = _c === void 0 ? function () {
3778
3853
  return null;
3779
- } : _c;
3854
+ } : _c,
3855
+ _d = _a.onFormDirty,
3856
+ onFormDirty = _d === void 0 ? function () {
3857
+ return null;
3858
+ } : _d,
3859
+ _e = _a.isIssuesPaneOpen,
3860
+ isIssuesPaneOpen = _e === void 0 ? false : _e,
3861
+ _f = _a.setIsIssuesPaneOpen,
3862
+ setIsIssuesPaneOpen = _f === void 0 ? function () {
3863
+ return null;
3864
+ } : _f;
3780
3865
  var originalTaf = tafFromBackend.taf;
3866
+ var defaultTafAction = fromStatusToAction(originalTaf.status);
3781
3867
 
3782
- var _d = __read(React__default["default"].useState(defaultTafAction), 2),
3783
- tafAction = _d[0],
3784
- setTafAction = _d[1];
3868
+ var _g = __read(React__default["default"].useState(defaultTafAction), 2),
3869
+ tafAction = _g[0],
3870
+ setTafAction = _g[1];
3785
3871
 
3786
- var _e = __read(React__default["default"].useState(isDefaultDisabled), 2),
3787
- isDisabled = _e[0],
3788
- setIsDisabled = _e[1];
3872
+ var _h = __read(React__default["default"].useState(isDefaultDisabled), 2),
3873
+ isDisabled = _h[0],
3874
+ setIsDisabled = _h[1];
3789
3875
 
3790
3876
  var confirmDialog = shared.useConfirmationDialog();
3791
3877
 
3792
- var _f = shared.useDraftFormHelpers(),
3793
- toggleIsDraft = _f.toggleIsDraft,
3794
- DraftFieldHelper = _f.DraftFieldHelper;
3878
+ var _j = shared.useDraftFormHelpers(),
3879
+ toggleIsDraft = _j.toggleIsDraft,
3880
+ DraftFieldHelper = _j.DraftFieldHelper;
3795
3881
 
3796
3882
  var api$1 = api.useApiContext().api;
3797
3883
  var isMounted = shared.useIsMounted().isMounted;
3798
3884
 
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;
3885
+ var _k = reactHookForm.useFormContext(),
3886
+ control = _k.control,
3887
+ handleSubmit = _k.handleSubmit,
3888
+ trigger = _k.trigger,
3889
+ formState = _k.formState,
3890
+ getValues = _k.getValues,
3891
+ setValue = _k.setValue,
3892
+ reset = _k.reset;
3808
3893
 
3809
3894
  var isFormDirty = formState.isDirty,
3810
3895
  errors = formState.errors;
3811
3896
  shared.usePreventBrowserClose(isFormDirty && !isDisabled);
3812
3897
  var hiddenInputFields = ['baseTime', 'issueDate', 'type', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd'];
3813
3898
 
3814
- var _h = __read(React__default["default"].useState(watch()), 2),
3815
- delayedFormValues = _h[0],
3816
- setDelayedFormValues = _h[1];
3899
+ var _l = __read(React__default["default"].useState(getValues()), 2),
3900
+ delayedFormValues = _l[0],
3901
+ setDelayedFormValues = _l[1];
3817
3902
 
3818
- var _j = __read(useTACGenerator(convertTafValuesToObject(delayedFormValues), api$1.getTAC, staticTAC), 2),
3819
- TAC = _j[0],
3820
- updateTAC = _j[1];
3903
+ var _m = __read(useTACGenerator(tafFromBackend.taf, api$1.getTAC), 2),
3904
+ TAC = _m[0],
3905
+ updateTAC = _m[1];
3821
3906
 
3822
3907
  var hasErrors = Object.keys(errors).length;
3823
3908
 
@@ -3826,7 +3911,7 @@
3826
3911
  };
3827
3912
 
3828
3913
  React__default["default"].useEffect(function () {
3829
- if (staticTAC === '' && isMounted.current && isFormDirty) {
3914
+ if (isMounted.current && isFormDirty) {
3830
3915
  var newTAC = hasErrors ? null : convertTafValuesToObject(delayedFormValues);
3831
3916
  updateTAC(newTAC);
3832
3917
  } // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -3838,7 +3923,11 @@
3838
3923
  updateTAC(convertTafValuesToObject(delayedFormValues));
3839
3924
  } // eslint-disable-next-line react-hooks/exhaustive-deps
3840
3925
 
3841
- }, [hasErrors]);
3926
+ }, [hasErrors]); // Needed to be able to show a confirmation dialog on switching tabs when form is edited and not saved
3927
+
3928
+ React__default["default"].useEffect(function () {
3929
+ onFormDirty(isFormDirty);
3930
+ }, [isFormDirty, onFormDirty]);
3842
3931
 
3843
3932
  var onSubmit = function onSubmit(data) {
3844
3933
  // eslint-disable-next-line no-console
@@ -3956,19 +4045,19 @@
3956
4045
  }
3957
4046
  };
3958
4047
 
3959
- var _k = reactHookForm.useFieldArray({
4048
+ var _o = reactHookForm.useFieldArray({
3960
4049
  control: control,
3961
4050
  name: 'changeGroups'
3962
4051
  }),
3963
- fields = _k.fields,
3964
- insert = _k.insert,
3965
- remove = _k.remove,
3966
- move = _k.move;
4052
+ fields = _o.fields,
4053
+ insert = _o.insert,
4054
+ remove = _o.remove,
4055
+ move = _o.move;
3967
4056
 
3968
- var _l = useDragOrder(trigger, move, onFormBlur),
3969
- onChangeOrder = _l.onChangeOrder,
3970
- onStartDrag = _l.onStartDrag,
3971
- activeDraggingIndex = _l.activeDraggingIndex;
4057
+ var _p = useDragOrder(trigger, move, onFormBlur),
4058
+ onChangeOrder = _p.onChangeOrder,
4059
+ onStartDrag = _p.onStartDrag,
4060
+ activeDraggingIndex = _p.activeDraggingIndex;
3972
4061
 
3973
4062
  var onRemoverow = function onRemoverow(index) {
3974
4063
  confirmDialog({
@@ -4049,16 +4138,32 @@
4049
4138
  });
4050
4139
  };
4051
4140
 
4141
+ var _q = __read(React__default["default"].useState(false), 2),
4142
+ shouldValidate = _q[0],
4143
+ setShouldValidate = _q[1];
4144
+
4052
4145
  React__default["default"].useEffect(function () {
4053
- if (!isDisabled) {
4146
+ var defaultValues = prepareTafValues(tafFromBackend.taf, undefined, !isDisabled && !tafFromBackend.taf.changeGroups); // set initial form values
4147
+
4148
+ reset(defaultValues); // set validate flag to validate after the values have been set
4149
+
4150
+ setShouldValidate(true);
4151
+ return function () {
4152
+ reset();
4153
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
4154
+ }, []);
4155
+ React__default["default"].useEffect(function () {
4156
+ if (shouldValidate && !isDisabled) {
4054
4157
  // 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) {
4158
+ var _a = tafFromBackend.taf.changeGroups,
4159
+ changeGroups = _a === void 0 ? [] : _a;
4160
+ var validFields = changeGroups.map(function (_field, index) {
4056
4161
  return "changeGroups[" + index + "].valid";
4057
4162
  });
4058
4163
  trigger(validFields);
4059
4164
  } // eslint-disable-next-line react-hooks/exhaustive-deps
4060
4165
 
4061
- }, []);
4166
+ }, [shouldValidate]);
4062
4167
  return /*#__PURE__*/React__default["default"].createElement("form", {
4063
4168
  "data-testid": "taf-form",
4064
4169
  onSubmit: handleSubmit(onSubmit),
@@ -4136,7 +4241,9 @@
4136
4241
  }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
4137
4242
  item: true
4138
4243
  }, /*#__PURE__*/React__default["default"].createElement(IssuesButton, {
4139
- errors: errors
4244
+ errors: errors,
4245
+ isIssuesPaneOpen: isIssuesPaneOpen,
4246
+ setIsIssuesPaneOpen: setIsIssuesPaneOpen
4140
4247
  }))), /*#__PURE__*/React__default["default"].createElement(TafFormButtons, {
4141
4248
  isFormDisabled: isDisabled,
4142
4249
  tafAction: tafAction,
@@ -4151,50 +4258,6 @@
4151
4258
  }), /*#__PURE__*/React__default["default"].createElement(DraftFieldHelper, null));
4152
4259
  };
4153
4260
 
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
4261
  /* *
4199
4262
  * Licensed under the Apache License, Version 2.0 (the "License");
4200
4263
  * you may not use this file except in compliance with the License.
@@ -4381,14 +4444,25 @@
4381
4444
  };
4382
4445
  };
4383
4446
 
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
- })));
4391
- };
4447
+ /* *
4448
+ * Licensed under the Apache License, Version 2.0 (the "License");
4449
+ * you may not use this file except in compliance with the License.
4450
+ * You may obtain a copy of the License at
4451
+ *
4452
+ * http://www.apache.org/licenses/LICENSE-2.0
4453
+ *
4454
+ * Unless required by applicable law or agreed to in writing, software
4455
+ * distributed under the License is distributed on an "AS IS" BASIS,
4456
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4457
+ * See the License for the specific language governing permissions and
4458
+ * limitations under the License.
4459
+ *
4460
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4461
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4462
+ * */
4463
+ var EditIcon = material.createSvgIcon( /*#__PURE__*/React__namespace.createElement("path", {
4464
+ 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"
4465
+ }), 'Edit');
4392
4466
 
4393
4467
  var StatusIcon = function StatusIcon(_a) {
4394
4468
  var timeSlot = _a.timeSlot,
@@ -4399,45 +4473,64 @@
4399
4473
  }
4400
4474
 
4401
4475
  if (status === 'EXPIRED') {
4402
- return /*#__PURE__*/React__namespace.createElement(iconsMaterial.Schedule, {
4476
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4477
+ title: "Expired",
4478
+ placement: "right"
4479
+ }, /*#__PURE__*/React__namespace.createElement(iconsMaterial.Schedule, {
4403
4480
  "data-testid": "status-expired",
4404
4481
  fontSize: "small",
4405
4482
  sx: {
4406
4483
  transform: 'scaleX(-1)',
4407
4484
  color: 'geowebColors.buttons.tertiary.disabled.color'
4408
4485
  }
4409
- });
4486
+ }));
4410
4487
  }
4411
4488
 
4412
4489
  if (status === 'CANCELLED') {
4413
- return /*#__PURE__*/React__namespace.createElement(DoDisturbIcon__default["default"], {
4490
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4491
+ title: "Cancelled",
4492
+ placement: "right"
4493
+ }, /*#__PURE__*/React__namespace.createElement(DoDisturbIcon__default["default"], {
4414
4494
  "data-testid": "status-cancelled",
4415
4495
  fontSize: "small",
4416
4496
  sx: {
4417
4497
  color: 'geowebColors.captions.captionError.rgba'
4418
4498
  }
4419
- });
4499
+ }));
4420
4500
  }
4421
4501
 
4422
4502
  if (status === 'DRAFT' || status === 'DRAFT_CORRECTED' || status === 'DRAFT_AMENDED') {
4423
- return /*#__PURE__*/React__namespace.createElement(EditIcon, {
4424
- "data-testid": "status-draft"
4425
- });
4503
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4504
+ title: "Draft",
4505
+ placement: "right"
4506
+ }, /*#__PURE__*/React__namespace.createElement(material.SvgIcon, {
4507
+ component: EditIcon,
4508
+ "data-testid": "status-draft",
4509
+ sx: {
4510
+ color: 'geowebColors.buttons.tertiary.default.color'
4511
+ }
4512
+ }));
4426
4513
  }
4427
4514
 
4428
- return timeSlot === 'ACTIVE' ? /*#__PURE__*/React__namespace.createElement(iconsMaterial.CheckCircle, {
4515
+ return timeSlot === 'ACTIVE' ? /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4516
+ title: "Active",
4517
+ placement: "right"
4518
+ }, /*#__PURE__*/React__namespace.createElement(iconsMaterial.CheckCircle, {
4429
4519
  "data-testid": "status-active",
4430
4520
  fontSize: "small",
4431
4521
  sx: {
4432
4522
  color: 'geowebColors.functional.success'
4433
4523
  }
4434
- }) : /*#__PURE__*/React__namespace.createElement(iconsMaterial.Schedule, {
4524
+ })) : /*#__PURE__*/React__namespace.createElement(material.Tooltip, {
4525
+ title: "Upcoming",
4526
+ placement: "right"
4527
+ }, /*#__PURE__*/React__namespace.createElement(iconsMaterial.Schedule, {
4435
4528
  "data-testid": "status-upcoming",
4436
4529
  fontSize: "small",
4437
4530
  sx: {
4438
4531
  color: 'geowebColors.functional.success'
4439
4532
  }
4440
- });
4533
+ }));
4441
4534
  };
4442
4535
 
4443
4536
  /* *
@@ -4727,7 +4820,13 @@
4727
4820
  var timeSlot = _a.timeSlot,
4728
4821
  _b = _a.onChangeTimeSlot,
4729
4822
  onChangeTimeSlot = _b === void 0 ? function () {} : _b,
4730
- tafFromBackend = _a.tafFromBackend;
4823
+ _c = _a.tafFromBackend,
4824
+ tafFromBackend = _c === void 0 ? {
4825
+ taf: {
4826
+ baseTime: '2022-01-06T12:00:00Z',
4827
+ location: 'EHAM'
4828
+ }
4829
+ } : _c;
4731
4830
 
4732
4831
  if (!tafFromBackend) {
4733
4832
  return null;
@@ -4735,9 +4834,9 @@
4735
4834
 
4736
4835
  var activeTab = timeSlot === 'UPCOMING' ? 0 : 1;
4737
4836
 
4738
- var _c = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location),
4739
- currentBaseTime = _c.currentBaseTime,
4740
- nextBaseTime = _c.nextBaseTime;
4837
+ var _d = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location),
4838
+ currentBaseTime = _d.currentBaseTime,
4839
+ nextBaseTime = _d.nextBaseTime;
4741
4840
 
4742
4841
  var tabs = [{
4743
4842
  title: "Upcoming " + formatBaseTime(nextBaseTime),
@@ -4755,12 +4854,13 @@
4755
4854
  value: activeTab,
4756
4855
  onChange: onChangeTab,
4757
4856
  "aria-label": "timeslot-tabs",
4857
+ "data-testid": "timeslot-tabs",
4758
4858
  variant: "fullWidth"
4759
4859
  }, tabs.map(function (tab, index) {
4760
4860
  return /*#__PURE__*/React__default["default"].createElement(material.Tab, __assign({
4761
4861
  key: tab.title,
4762
4862
  label: tab.title,
4763
- "data-testid": "tab-" + index,
4863
+ "data-testid": "toptab-" + index,
4764
4864
  sx: {
4765
4865
  fontSize: 16
4766
4866
  }
@@ -4885,16 +4985,26 @@
4885
4985
  activeTafIndex = _a.activeTafIndex,
4886
4986
  index = _a.index,
4887
4987
  _b = _a.onPostTaf,
4888
- onPostTaf = _b === void 0 ? function () {} : _b;
4988
+ onPostTaf = _b === void 0 ? function () {} : _b,
4989
+ _c = _a.onFormDirty,
4990
+ onFormDirty = _c === void 0 ? function () {
4991
+ return null;
4992
+ } : _c,
4993
+ _d = _a.isIssuesPaneOpen,
4994
+ isIssuesPaneOpen = _d === void 0 ? false : _d,
4995
+ _e = _a.setIsIssuesPaneOpen,
4996
+ setIsIssuesPaneOpen = _e === void 0 ? function () {
4997
+ return null;
4998
+ } : _e;
4889
4999
  var api$1 = api.useApiContext().api;
4890
5000
 
4891
- var _c = __read(React__default["default"].useState(false), 2),
4892
- isLoading = _c[0],
4893
- setLoading = _c[1];
5001
+ var _f = __read(React__default["default"].useState(false), 2),
5002
+ isLoading = _f[0],
5003
+ setLoading = _f[1];
4894
5004
 
4895
- var _d = __read(React__default["default"].useState(null), 2),
4896
- error = _d[0],
4897
- setError = _d[1]; // removes cancelled error message
5005
+ var _g = __read(React__default["default"].useState(null), 2),
5006
+ error = _g[0],
5007
+ setError = _g[1]; // removes cancelled error message
4898
5008
 
4899
5009
 
4900
5010
  React__default["default"].useEffect(function () {
@@ -4925,7 +5035,8 @@
4925
5035
  _a.sent();
4926
5036
 
4927
5037
  setLoading(false);
4928
- setError(null); // callback
5038
+ setError(null);
5039
+ onFormDirty(false); // callback
4929
5040
 
4930
5041
  onPostTaf();
4931
5042
  return [3
@@ -5071,42 +5182,86 @@
5071
5182
  title: error.title,
5072
5183
  info: error.message,
5073
5184
  dataTestId: "taf-error"
5074
- }), /*#__PURE__*/React__default["default"].createElement(TafFormWrapper, {
5075
- mode: getViewMode(tafFromBackend.taf.status),
5185
+ }), /*#__PURE__*/React__default["default"].createElement(TafForm, {
5186
+ isDisabled: getViewMode(tafFromBackend.taf.status) === 'view',
5076
5187
  tafFromBackend: tafFromBackend,
5077
- onFormAction: onTafAction
5188
+ onFormAction: onTafAction,
5189
+ onFormDirty: onFormDirty,
5190
+ isIssuesPaneOpen: isIssuesPaneOpen,
5191
+ setIsIssuesPaneOpen: setIsIssuesPaneOpen
5078
5192
  }));
5079
5193
  };
5080
5194
 
5195
+ var IssuesPaneWrapper = function IssuesPaneWrapper(props) {
5196
+ var errors = reactHookForm.useFormContext().formState.errors;
5197
+ var errorList = filterDuplicateErrors(getErrors(errors));
5198
+ return /*#__PURE__*/React__namespace.createElement(IssuesPane, __assign({
5199
+ errorList: errorList
5200
+ }, props));
5201
+ };
5202
+
5081
5203
  var TafLayout = function TafLayout(_a) {
5082
5204
  var _b = _a.tafList,
5083
5205
  tafList = _b === void 0 ? [] : _b,
5084
5206
  _c = _a.onPostTaf,
5085
5207
  onPostTaf = _c === void 0 ? function () {} : _c;
5208
+ var confirmDialog = shared.useConfirmationDialog();
5086
5209
 
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];
5093
-
5094
- var _f = __read(upcoming.slice(-1), 1),
5095
- lastUpcomingTaf = _f[0];
5096
-
5097
- var _g = __read(React__default["default"].useState('UPCOMING'), 2),
5098
- timeSlot = _g[0],
5099
- setTimeSlot = _g[1];
5100
-
5101
- var _h = __read(React__default["default"].useState(upcoming), 2),
5102
- locations = _h[0],
5103
- setLocations = _h[1];
5210
+ var _d = useIssuesPane(),
5211
+ isIssuesPaneOpen = _d.isIssuesPaneOpen,
5212
+ onToggleIssuesPane = _d.onToggleIssuesPane,
5213
+ onCloseIssuesPane = _d.onCloseIssuesPane,
5214
+ startPosition = _d.startPosition;
5215
+
5216
+ var _e = __read(React__default["default"].useState(sortTafTimeSlots(tafList)), 2),
5217
+ _f = _e[0],
5218
+ upcoming = _f.upcoming,
5219
+ current = _f.current,
5220
+ expired = _f.expired,
5221
+ updateSortedTafs = _e[1];
5222
+
5223
+ var _g = __read(current.slice(-1), 1),
5224
+ lastCurrentTaf = _g[0];
5225
+
5226
+ var _h = __read(React__default["default"].useState('UPCOMING'), 2),
5227
+ timeSlot = _h[0],
5228
+ setTimeSlot = _h[1];
5229
+
5230
+ var _j = __read(React__default["default"].useState(upcoming), 2),
5231
+ locations = _j[0],
5232
+ setLocations = _j[1];
5233
+
5234
+ var _k = __read(React__default["default"].useState(0), 2),
5235
+ activeTafIndex = _k[0],
5236
+ setActiveTafIndex = _k[1];
5237
+
5238
+ var _l = __read(React__default["default"].useState(false), 2),
5239
+ isFormDirty = _l[0],
5240
+ setIsFormDirty = _l[1];
5241
+
5242
+ function onChangeTab(action, value) {
5243
+ if (isFormDirty) {
5244
+ confirmDialog({
5245
+ title: 'Whoops',
5246
+ description: 'Do you want to leave this open TAF without saving it? All changes will be lost.',
5247
+ confirmLabel: 'Exit without saving'
5248
+ }).then(function () {
5249
+ action(value);
5250
+ });
5251
+ } else {
5252
+ action(value);
5253
+ }
5254
+ }
5104
5255
 
5105
- var _j = __read(React__default["default"].useState(0), 2),
5106
- activeTafIndex = _j[0],
5107
- setActiveTafIndex = _j[1];
5256
+ var onChangeLocationTab = function onChangeLocationTab(index) {
5257
+ onChangeTab(setActiveTafIndex, index);
5258
+ };
5108
5259
 
5109
5260
  var onChangeTimeSlot = function onChangeTimeSlot(newTimeSlot) {
5261
+ onChangeTab(changeTimeSlot, newTimeSlot);
5262
+ };
5263
+
5264
+ var changeTimeSlot = function changeTimeSlot(newTimeSlot) {
5110
5265
  setTimeSlot(newTimeSlot);
5111
5266
  setLocations(newTimeSlot === 'ACTIVE' ? current : upcoming);
5112
5267
  setActiveTafIndex(0);
@@ -5166,7 +5321,7 @@
5166
5321
  xs: 12,
5167
5322
  sm: 9
5168
5323
  }, /*#__PURE__*/React__default["default"].createElement(TopTabs, {
5169
- tafFromBackend: lastUpcomingTaf,
5324
+ tafFromBackend: lastCurrentTaf,
5170
5325
  timeSlot: timeSlot,
5171
5326
  onChangeTimeSlot: onChangeTimeSlot
5172
5327
  }))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
@@ -5190,7 +5345,7 @@
5190
5345
  }, /*#__PURE__*/React__default["default"].createElement(LocationTabs, {
5191
5346
  tafList: locations,
5192
5347
  activeIndex: activeTafIndex,
5193
- onChangeTab: setActiveTafIndex,
5348
+ onChangeTab: onChangeLocationTab,
5194
5349
  timeSlot: timeSlot
5195
5350
  })), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
5196
5351
  item: true,
@@ -5214,7 +5369,10 @@
5214
5369
  activeTafIndex: activeTafIndex,
5215
5370
  index: index,
5216
5371
  tafFromBackend: tafFromBackend,
5217
- onPostTaf: onPostTaf
5372
+ onPostTaf: onPostTaf,
5373
+ onFormDirty: setIsFormDirty,
5374
+ isIssuesPaneOpen: isIssuesPaneOpen,
5375
+ setIsIssuesPaneOpen: onToggleIssuesPane
5218
5376
  });
5219
5377
  }))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
5220
5378
  item: true,
@@ -5231,7 +5389,39 @@
5231
5389
  currentTafs: current,
5232
5390
  expiredTafs: expired,
5233
5391
  activeTaf: activeTaf
5234
- })))))));
5392
+ })))))), /*#__PURE__*/React__default["default"].createElement(IssuesPaneWrapper, {
5393
+ handleClose: onCloseIssuesPane,
5394
+ isOpen: isIssuesPaneOpen,
5395
+ startPosition: startPosition
5396
+ }));
5397
+ };
5398
+
5399
+ /* *
5400
+ * Licensed under the Apache License, Version 2.0 (the "License");
5401
+ * you may not use this file except in compliance with the License.
5402
+ * You may obtain a copy of the License at
5403
+ *
5404
+ * http://www.apache.org/licenses/LICENSE-2.0
5405
+ *
5406
+ * Unless required by applicable law or agreed to in writing, software
5407
+ * distributed under the License is distributed on an "AS IS" BASIS,
5408
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5409
+ * See the License for the specific language governing permissions and
5410
+ * limitations under the License.
5411
+ *
5412
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5413
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
5414
+ * */
5415
+
5416
+ var TafWrapper = function TafWrapper(_a) {
5417
+ var children = _a.children;
5418
+ return /*#__PURE__*/React__namespace.createElement(shared.ConfirmationServiceProvider, null, /*#__PURE__*/React__namespace.createElement(formFields.ReactHookFormProvider, {
5419
+ options: {
5420
+ mode: 'onTouched',
5421
+ reValidateMode: 'onChange',
5422
+ criteriaMode: 'all'
5423
+ }
5424
+ }, children));
5235
5425
  };
5236
5426
 
5237
5427
  var TafModule = function TafModule() {
@@ -5319,10 +5509,10 @@
5319
5509
  };
5320
5510
 
5321
5511
  var Wrapper = function Wrapper() {
5322
- return /*#__PURE__*/React__namespace.createElement(shared.ConfirmationServiceProvider, null, /*#__PURE__*/React__namespace.createElement(TafModule, null));
5512
+ return /*#__PURE__*/React__namespace.createElement(TafWrapper, null, /*#__PURE__*/React__namespace.createElement(TafModule, null));
5323
5513
  };
5324
5514
 
5325
- var createApi = function createApi(url, appUrl, auth, setAuth, authTokenUrl, authClientId) {
5515
+ var createApi$1 = function createApi(url, appUrl, auth, setAuth, authTokenUrl, authClientId) {
5326
5516
  var axiosInstance = api.createApiInstance(url, appUrl, auth, setAuth, authTokenUrl, authClientId);
5327
5517
  return {
5328
5518
  // api data
@@ -5338,9 +5528,974 @@
5338
5528
  };
5339
5529
  };
5340
5530
 
5341
- exports.TafFormWrapper = TafFormWrapper;
5531
+ var currentDate = moment__default["default"].utc().format('YYYY-MM-DD');
5532
+ var tomorrowDate = moment__default["default"].utc().add(1, 'day').format('YYYY-MM-DD');
5533
+ var airportPeriod = 6;
5534
+ var airportValidity = 40;
5535
+
5536
+ var validDateRange = function validDateRange(refHour, period) {
5537
+ var startHour = period * Math.floor(parseInt(refHour.format('HH'), 10) / period) % 24;
5538
+ var start = refHour.set({
5539
+ hour: startHour,
5540
+ minute: 0,
5541
+ second: 0
5542
+ });
5543
+ var end = start.clone().add(airportValidity, 'hours');
5544
+ return [start.format('YYYY-MM-DDTHH:mm:ss'), end.format('YYYY-MM-DDTHH:mm:ss')];
5545
+ };
5546
+
5547
+ var dateAdd = function dateAdd(refDateAsString, hours) {
5548
+ return moment__default["default"].utc(refDateAsString).add(hours, 'hours').format('YYYY-MM-DDTHH:mm:ss');
5549
+ };
5550
+
5551
+ var _a = __read(validDateRange(moment__default["default"].utc(), airportPeriod), 2),
5552
+ currentValidDateStart = _a[0],
5553
+ currentValidDateEnd = _a[1];
5554
+
5555
+ var _b = __read(validDateRange(moment__default["default"].utc().add(6, 'hours'), airportPeriod), 2),
5556
+ upcomingValidDateStart = _b[0],
5557
+ upcomingValidDateEnd = _b[1];
5558
+
5559
+ var _c = __read(validDateRange(moment__default["default"].utc().add(-6, 'hours'), airportPeriod), 2),
5560
+ expiredValidDateStart = _c[0],
5561
+ expiredValidDateEnd = _c[1];
5562
+
5563
+ var fakeTafList = [{
5564
+ creationDate: upcomingValidDateStart,
5565
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
5566
+ taf: {
5567
+ uuid: '5f9583fjdf0f337925',
5568
+ baseTime: upcomingValidDateStart,
5569
+ validDateStart: upcomingValidDateStart,
5570
+ validDateEnd: upcomingValidDateEnd,
5571
+ location: 'EHAM',
5572
+ status: 'NEW',
5573
+ type: 'NORMAL',
5574
+ messageType: 'ORG',
5575
+ baseForecast: {
5576
+ valid: {
5577
+ start: upcomingValidDateStart,
5578
+ end: upcomingValidDateEnd
5579
+ }
5580
+ }
5581
+ }
5582
+ }, {
5583
+ creationDate: upcomingValidDateStart,
5584
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
5585
+ taf: {
5586
+ uuid: '5f9583fjd111137925',
5587
+ baseTime: upcomingValidDateStart,
5588
+ validDateStart: upcomingValidDateStart,
5589
+ validDateEnd: upcomingValidDateEnd,
5590
+ location: 'EHRD',
5591
+ status: 'DRAFT',
5592
+ type: 'NORMAL',
5593
+ messageType: 'ORG',
5594
+ baseForecast: {
5595
+ valid: {
5596
+ start: upcomingValidDateStart,
5597
+ end: upcomingValidDateEnd
5598
+ },
5599
+ wind: {
5600
+ direction: 180,
5601
+ speed: 10,
5602
+ unit: 'KT'
5603
+ },
5604
+ cavOK: true
5605
+ }
5606
+ }
5607
+ }, {
5608
+ creationDate: upcomingValidDateStart,
5609
+ canbe: ['CANCELLED', 'AMENDED', 'DISCARDED'],
5610
+ taf: {
5611
+ uuid: '754905485',
5612
+ baseTime: upcomingValidDateStart,
5613
+ previousId: '5f9583fjdf45ff4330f337925',
5614
+ validDateStart: upcomingValidDateStart,
5615
+ validDateEnd: upcomingValidDateEnd,
5616
+ previousValidDateStart: upcomingValidDateStart,
5617
+ previousValidDateEnd: upcomingValidDateEnd,
5618
+ location: 'EHLE',
5619
+ status: 'DRAFT_AMENDED',
5620
+ type: 'NORMAL',
5621
+ messageType: 'AMD',
5622
+ baseForecast: {
5623
+ valid: {
5624
+ start: upcomingValidDateStart,
5625
+ end: upcomingValidDateEnd
5626
+ },
5627
+ visibility: {
5628
+ range: 600,
5629
+ unit: 'M'
5630
+ },
5631
+ wind: {
5632
+ direction: 180,
5633
+ speed: 10,
5634
+ unit: 'KT'
5635
+ },
5636
+ weather: {
5637
+ weather1: 'SN'
5638
+ },
5639
+ cloud: {
5640
+ cloud1: {
5641
+ coverage: 'BKN',
5642
+ height: 35
5643
+ }
5644
+ }
5645
+ },
5646
+ changeGroups: [{
5647
+ change: 'TEMPO',
5648
+ probability: 'PROB30',
5649
+ valid: {
5650
+ start: dateAdd(upcomingValidDateStart, 3),
5651
+ end: dateAdd(upcomingValidDateStart, 4)
5652
+ },
5653
+ visibility: {
5654
+ range: 100,
5655
+ unit: 'M'
5656
+ },
5657
+ cloud: {
5658
+ cloud1: {
5659
+ verticalVisibility: 5
5660
+ }
5661
+ }
5662
+ }]
5663
+ }
5664
+ }, {
5665
+ creationDate: upcomingValidDateStart,
5666
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
5667
+ taf: {
5668
+ uuid: '43545345345',
5669
+ issueDate: upcomingValidDateStart,
5670
+ baseTime: currentDate + "T18:00:00Z",
5671
+ validDateStart: currentDate + "T18:00:00Z",
5672
+ validDateEnd: upcomingValidDateEnd,
5673
+ previousId: 'jkdjkdfjkgdf',
5674
+ previousValidDateStart: upcomingValidDateStart,
5675
+ previousValidDateEnd: upcomingValidDateEnd,
5676
+ location: 'EHLE',
5677
+ status: 'CORRECTED',
5678
+ type: 'NORMAL',
5679
+ messageType: 'COR',
5680
+ baseForecast: {
5681
+ valid: {
5682
+ start: upcomingValidDateStart,
5683
+ end: upcomingValidDateEnd
5684
+ },
5685
+ wind: {
5686
+ direction: 350,
5687
+ speed: 46,
5688
+ gust: 67,
5689
+ unit: 'KT'
5690
+ },
5691
+ cavOK: true
5692
+ },
5693
+ changeGroups: [{
5694
+ change: 'BECMG',
5695
+ valid: {
5696
+ start: dateAdd(upcomingValidDateStart, 1),
5697
+ end: dateAdd(upcomingValidDateStart, 2)
5698
+ },
5699
+ visibility: {
5700
+ range: 1000,
5701
+ unit: 'M'
5702
+ },
5703
+ weather: {
5704
+ weather1: 'MIFG'
5705
+ },
5706
+ cloud: {
5707
+ cloud1: 'NSC'
5708
+ }
5709
+ }, {
5710
+ change: 'FM',
5711
+ valid: {
5712
+ start: dateAdd(upcomingValidDateStart, 2)
5713
+ },
5714
+ visibility: {
5715
+ range: 6000,
5716
+ unit: 'M'
5717
+ },
5718
+ weather: {
5719
+ weather1: '+SHRA'
5720
+ },
5721
+ cloud: {
5722
+ cloud1: {
5723
+ coverage: 'BKN',
5724
+ height: 40
5725
+ },
5726
+ cloud2: {
5727
+ coverage: 'OVC',
5728
+ height: 60,
5729
+ type: 'CB'
5730
+ }
5731
+ }
5732
+ }]
5733
+ }
5734
+ }, {
5735
+ creationDate: upcomingValidDateStart,
5736
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
5737
+ taf: {
5738
+ uuid: '5f9583fjdf45ff4330f337925',
5739
+ issueDate: upcomingValidDateStart,
5740
+ baseTime: upcomingValidDateStart,
5741
+ validDateStart: upcomingValidDateStart,
5742
+ validDateEnd: upcomingValidDateEnd,
5743
+ location: 'EHGG',
5744
+ status: 'PUBLISHED',
5745
+ type: 'NORMAL',
5746
+ messageType: 'ORG',
5747
+ baseForecast: {
5748
+ valid: {
5749
+ start: upcomingValidDateEnd,
5750
+ end: upcomingValidDateEnd
5751
+ },
5752
+ visibility: {
5753
+ range: 600,
5754
+ unit: 'M'
5755
+ },
5756
+ wind: {
5757
+ direction: 180,
5758
+ speed: 10,
5759
+ unit: 'KT'
5760
+ },
5761
+ weather: {
5762
+ weather1: 'SN'
5763
+ },
5764
+ cloud: {
5765
+ cloud1: {
5766
+ coverage: 'BKN',
5767
+ height: 35
5768
+ }
5769
+ }
5770
+ },
5771
+ changeGroups: [{
5772
+ change: 'TEMPO',
5773
+ probability: 'PROB30',
5774
+ valid: {
5775
+ start: dateAdd(upcomingValidDateStart, 1),
5776
+ end: dateAdd(upcomingValidDateStart, 2)
5777
+ },
5778
+ visibility: {
5779
+ range: 200,
5780
+ unit: 'M'
5781
+ },
5782
+ cloud: {
5783
+ cloud1: {
5784
+ verticalVisibility: 5
5785
+ }
5786
+ }
5787
+ }]
5788
+ }
5789
+ }, {
5790
+ creationDate: upcomingValidDateStart,
5791
+ canbe: ['AMENDED'],
5792
+ taf: {
5793
+ uuid: '5464565464',
5794
+ previousId: '5445fghrfg3546456',
5795
+ issueDate: upcomingValidDateStart,
5796
+ baseTime: upcomingValidDateStart,
5797
+ validDateStart: upcomingValidDateStart,
5798
+ validDateEnd: upcomingValidDateEnd,
5799
+ previousValidDateStart: upcomingValidDateStart,
5800
+ previousValidDateEnd: upcomingValidDateEnd,
5801
+ location: 'EHBK',
5802
+ status: 'CANCELLED',
5803
+ type: 'NORMAL',
5804
+ messageType: 'CNL',
5805
+ baseForecast: {
5806
+ valid: {
5807
+ start: upcomingValidDateStart,
5808
+ end: upcomingValidDateEnd
5809
+ },
5810
+ visibility: {
5811
+ range: 600,
5812
+ unit: 'M'
5813
+ },
5814
+ wind: {
5815
+ direction: 180,
5816
+ speed: 10,
5817
+ unit: 'KT'
5818
+ },
5819
+ weather: {
5820
+ weather1: 'SN'
5821
+ },
5822
+ cloud: {
5823
+ cloud1: {
5824
+ coverage: 'BKN',
5825
+ height: 35
5826
+ }
5827
+ }
5828
+ }
5829
+ }
5830
+ }, {
5831
+ creationDate: upcomingValidDateStart,
5832
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
5833
+ taf: {
5834
+ uuid: 'gh56734fghfgh',
5835
+ previousId: '8574jnf93475',
5836
+ issueDate: currentDate + "T16:16:00Z",
5837
+ baseTime: upcomingValidDateStart,
5838
+ validDateStart: upcomingValidDateStart,
5839
+ validDateEnd: upcomingValidDateEnd,
5840
+ previousValidDateStart: upcomingValidDateStart,
5841
+ previousValidDateEnd: upcomingValidDateEnd,
5842
+ location: 'TNCB',
5843
+ status: 'AMENDED',
5844
+ type: 'NORMAL',
5845
+ messageType: 'AMD',
5846
+ baseForecast: {
5847
+ valid: {
5848
+ start: currentDate + "T16:12:00Z",
5849
+ end: upcomingValidDateEnd
5850
+ },
5851
+ visibility: {
5852
+ range: 600,
5853
+ unit: 'M'
5854
+ },
5855
+ wind: {
5856
+ direction: 180,
5857
+ speed: 10,
5858
+ unit: 'KT'
5859
+ },
5860
+ weather: {
5861
+ weather1: 'SN'
5862
+ },
5863
+ cloud: {
5864
+ cloud1: {
5865
+ coverage: 'BKN',
5866
+ height: 35
5867
+ }
5868
+ }
5869
+ }
5870
+ }
5871
+ }, {
5872
+ creationDate: currentValidDateStart,
5873
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
5874
+ taf: {
5875
+ uuid: 'giskdj09845872039',
5876
+ issueDate: currentValidDateStart,
5877
+ baseTime: currentValidDateStart,
5878
+ validDateStart: currentValidDateStart,
5879
+ validDateEnd: currentValidDateEnd,
5880
+ location: 'EHAM',
5881
+ status: 'PUBLISHED',
5882
+ type: 'NORMAL',
5883
+ messageType: 'ORG',
5884
+ baseForecast: {
5885
+ valid: {
5886
+ start: currentValidDateStart,
5887
+ end: currentValidDateEnd
5888
+ },
5889
+ visibility: {
5890
+ range: 500,
5891
+ unit: 'M'
5892
+ },
5893
+ wind: {
5894
+ direction: 200,
5895
+ speed: 20,
5896
+ gust: 35,
5897
+ unit: 'KT'
5898
+ },
5899
+ weather: {
5900
+ weather1: 'SN'
5901
+ },
5902
+ cloud: {
5903
+ cloud1: {
5904
+ coverage: 'BKN',
5905
+ height: 40
5906
+ }
5907
+ }
5908
+ }
5909
+ }
5910
+ }, {
5911
+ creationDate: currentValidDateStart,
5912
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
5913
+ taf: {
5914
+ uuid: 'ghskdj09845872039',
5915
+ baseTime: currentValidDateStart,
5916
+ validDateStart: currentValidDateStart,
5917
+ validDateEnd: currentValidDateEnd,
5918
+ location: 'EHRD',
5919
+ status: 'NEW',
5920
+ type: 'NORMAL',
5921
+ messageType: 'ORG',
5922
+ baseForecast: {
5923
+ valid: {
5924
+ start: currentValidDateStart,
5925
+ end: currentValidDateEnd
5926
+ }
5927
+ }
5928
+ }
5929
+ }, {
5930
+ creationDate: currentValidDateStart,
5931
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
5932
+ taf: {
5933
+ uuid: 'ghskdj09845872040',
5934
+ issueDate: currentValidDateStart,
5935
+ baseTime: currentValidDateStart,
5936
+ validDateStart: currentValidDateStart,
5937
+ validDateEnd: currentValidDateEnd,
5938
+ location: 'EHLE',
5939
+ status: 'NEW',
5940
+ type: 'NORMAL',
5941
+ messageType: 'ORG',
5942
+ baseForecast: {
5943
+ valid: {
5944
+ start: currentValidDateStart,
5945
+ end: currentValidDateEnd
5946
+ }
5947
+ }
5948
+ }
5949
+ }, {
5950
+ creationDate: currentDate + "T06:00:00Z",
5951
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
5952
+ taf: {
5953
+ uuid: 'ghskdj09845872041',
5954
+ issueDate: currentValidDateStart,
5955
+ baseTime: currentValidDateStart,
5956
+ validDateStart: currentValidDateStart,
5957
+ validDateEnd: currentValidDateEnd,
5958
+ location: 'EHGG',
5959
+ status: 'NEW',
5960
+ type: 'NORMAL',
5961
+ messageType: 'ORG',
5962
+ baseForecast: {
5963
+ valid: {
5964
+ start: currentValidDateStart,
5965
+ end: currentValidDateEnd
5966
+ }
5967
+ }
5968
+ }
5969
+ }, {
5970
+ creationDate: currentDate + "T06:00:00Z",
5971
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
5972
+ taf: {
5973
+ uuid: 'ghskdj09845872042',
5974
+ issueDate: currentValidDateStart,
5975
+ baseTime: currentValidDateStart,
5976
+ validDateStart: currentValidDateStart,
5977
+ validDateEnd: currentValidDateEnd,
5978
+ location: 'EHBK',
5979
+ status: 'NEW',
5980
+ type: 'NORMAL',
5981
+ messageType: 'ORG',
5982
+ baseForecast: {
5983
+ valid: {
5984
+ start: currentValidDateStart,
5985
+ end: currentValidDateEnd
5986
+ }
5987
+ }
5988
+ }
5989
+ }, {
5990
+ creationDate: currentDate + "T06:00:00Z",
5991
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
5992
+ taf: {
5993
+ uuid: 'ghskdj09845872043',
5994
+ issueDate: currentValidDateStart,
5995
+ baseTime: currentValidDateStart,
5996
+ validDateStart: currentValidDateStart,
5997
+ validDateEnd: currentValidDateEnd,
5998
+ location: 'TNCB',
5999
+ status: 'NEW',
6000
+ type: 'NORMAL',
6001
+ messageType: 'ORG',
6002
+ baseForecast: {
6003
+ valid: {
6004
+ start: currentValidDateStart,
6005
+ end: currentValidDateEnd
6006
+ }
6007
+ }
6008
+ }
6009
+ }, {
6010
+ creationDate: expiredValidDateStart,
6011
+ canbe: [],
6012
+ taf: {
6013
+ uuid: 'sdkjhsdf90845890',
6014
+ issueDate: expiredValidDateStart,
6015
+ baseTime: expiredValidDateStart,
6016
+ validDateStart: expiredValidDateStart,
6017
+ validDateEnd: expiredValidDateEnd,
6018
+ location: 'EHAM',
6019
+ status: 'EXPIRED',
6020
+ type: 'NORMAL',
6021
+ messageType: 'ORG',
6022
+ baseForecast: {
6023
+ valid: {
6024
+ start: expiredValidDateStart,
6025
+ end: expiredValidDateEnd
6026
+ },
6027
+ cavOK: true,
6028
+ wind: {
6029
+ direction: 50,
6030
+ speed: 5,
6031
+ unit: 'KT'
6032
+ }
6033
+ },
6034
+ changeGroups: [{
6035
+ change: 'BECMG',
6036
+ valid: {
6037
+ start: dateAdd(expiredValidDateStart, 1),
6038
+ end: dateAdd(expiredValidDateStart, 4)
6039
+ },
6040
+ visibility: {
6041
+ range: 1000,
6042
+ unit: 'M'
6043
+ },
6044
+ weather: {
6045
+ weather1: 'MIFG'
6046
+ }
6047
+ }, {
6048
+ change: 'FM',
6049
+ valid: {
6050
+ start: dateAdd(expiredValidDateStart, 5)
6051
+ },
6052
+ visibility: {
6053
+ range: 6000,
6054
+ unit: 'M'
6055
+ },
6056
+ weather: {
6057
+ weather1: '+SHRA'
6058
+ },
6059
+ cloud: {
6060
+ cloud1: {
6061
+ coverage: 'BKN',
6062
+ height: 40
6063
+ },
6064
+ cloud2: {
6065
+ coverage: 'OVC',
6066
+ height: 60,
6067
+ type: 'CB'
6068
+ }
6069
+ }
6070
+ }]
6071
+ }
6072
+ }];
6073
+ var fakeNewTaf = {
6074
+ creationDate: currentDate + "T12:00:00Z",
6075
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6076
+ taf: {
6077
+ type: 'NORMAL',
6078
+ messageType: 'ORG',
6079
+ status: 'NEW',
6080
+ uuid: '5f9583fjdf0445332f337925',
6081
+ baseTime: currentDate + "T12:00:00Z",
6082
+ validDateStart: currentDate + "T12:00:00Z",
6083
+ validDateEnd: tomorrowDate + "T18:00:00Z",
6084
+ location: 'EHBK',
6085
+ baseForecast: {
6086
+ valid: {
6087
+ start: currentDate + "T12:00:00Z",
6088
+ end: tomorrowDate + "T18:00:00Z"
6089
+ }
6090
+ }
6091
+ }
6092
+ };
6093
+ ({
6094
+ creationDate: "2022-01-06T12:00:00Z",
6095
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6096
+ taf: __assign(__assign({}, fakeNewTaf.taf), {
6097
+ baseTime: "2022-01-06T12:00:00Z",
6098
+ validDateStart: "2022-01-06T12:00:00Z",
6099
+ validDateEnd: "2022-01-07T18:00:00Z",
6100
+ baseForecast: {
6101
+ valid: {
6102
+ start: "2022-01-06T12:00:00Z",
6103
+ end: "2022-01-07T18:00:00Z"
6104
+ }
6105
+ }
6106
+ })
6107
+ });
6108
+ var fakePublishedTaf = {
6109
+ creationDate: currentDate + "T12:00:00Z",
6110
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6111
+ taf: {
6112
+ uuid: 'slsdkjg-023895',
6113
+ issueDate: currentDate + "T12:00:00Z",
6114
+ baseTime: currentDate + "T12:00:00Z",
6115
+ validDateStart: currentDate + "T12:00:00Z",
6116
+ validDateEnd: tomorrowDate + "T18:00:00Z",
6117
+ location: 'EHLE',
6118
+ status: 'PUBLISHED',
6119
+ type: 'NORMAL',
6120
+ messageType: 'ORG',
6121
+ baseForecast: {
6122
+ valid: {
6123
+ start: currentDate + "T12:00:00Z",
6124
+ end: tomorrowDate + "T18:00:00Z"
6125
+ },
6126
+ wind: {
6127
+ direction: 50,
6128
+ speed: 5,
6129
+ unit: 'KT'
6130
+ },
6131
+ cavOK: true
6132
+ },
6133
+ changeGroups: [{
6134
+ change: 'FM',
6135
+ valid: {
6136
+ start: currentDate + "T12:00:00Z"
6137
+ },
6138
+ visibility: {
6139
+ range: 6000,
6140
+ unit: 'M'
6141
+ },
6142
+ weather: {
6143
+ weather1: '+SHRA'
6144
+ },
6145
+ wind: {
6146
+ direction: 10,
6147
+ speed: 10,
6148
+ unit: 'KT',
6149
+ gust: 35
6150
+ },
6151
+ cloud: {
6152
+ cloud1: {
6153
+ coverage: 'BKN',
6154
+ height: 40
6155
+ },
6156
+ cloud2: {
6157
+ coverage: 'OVC',
6158
+ height: 60,
6159
+ type: 'CB'
6160
+ }
6161
+ }
6162
+ }, {
6163
+ change: 'BECMG',
6164
+ valid: {
6165
+ start: currentDate + "T23:00:00Z",
6166
+ end: tomorrowDate + "T00:00:00Z"
6167
+ },
6168
+ wind: {
6169
+ direction: 150,
6170
+ speed: 5,
6171
+ unit: 'KT'
6172
+ },
6173
+ visibility: {
6174
+ range: 1000,
6175
+ unit: 'M'
6176
+ },
6177
+ weather: {
6178
+ weather1: 'MIFG'
6179
+ }
6180
+ }]
6181
+ }
6182
+ };
6183
+ ({
6184
+ creationDate: "2022-01-06T12:00:00Z",
6185
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
6186
+ taf: __assign(__assign({}, fakePublishedTaf.taf), {
6187
+ location: 'EHGG',
6188
+ baseTime: "2022-01-06T12:00:00Z",
6189
+ issueDate: "2022-01-06T12:00:00Z",
6190
+ validDateStart: "2022-01-06T12:00:00Z",
6191
+ validDateEnd: "2022-01-07T18:00:00Z",
6192
+ baseForecast: __assign(__assign({}, fakePublishedTaf.taf.baseForecast), {
6193
+ valid: {
6194
+ start: "2022-01-06T12:00:00Z",
6195
+ end: "2022-01-07T18:00:00Z"
6196
+ }
6197
+ }),
6198
+ changeGroups: [{
6199
+ change: 'FM',
6200
+ valid: {
6201
+ start: "2022-01-06T12:00:00Z"
6202
+ },
6203
+ visibility: {
6204
+ range: 6000,
6205
+ unit: 'M'
6206
+ },
6207
+ weather: {
6208
+ weather1: '+SHRA'
6209
+ },
6210
+ wind: {
6211
+ direction: 10,
6212
+ speed: 10,
6213
+ unit: 'KT',
6214
+ gust: 35
6215
+ },
6216
+ cloud: {
6217
+ cloud1: {
6218
+ coverage: 'BKN',
6219
+ height: 40
6220
+ },
6221
+ cloud2: {
6222
+ coverage: 'OVC',
6223
+ height: 60,
6224
+ type: 'CB'
6225
+ }
6226
+ }
6227
+ }, {
6228
+ change: 'BECMG',
6229
+ valid: {
6230
+ start: "2022-01-06T23:00:00Z",
6231
+ end: "2022-01-07T00:00:00Z"
6232
+ },
6233
+ wind: {
6234
+ direction: 150,
6235
+ speed: 5,
6236
+ unit: 'KT'
6237
+ },
6238
+ visibility: {
6239
+ range: 1000,
6240
+ unit: 'M'
6241
+ },
6242
+ weather: {
6243
+ weather1: 'MIFG'
6244
+ }
6245
+ }]
6246
+ })
6247
+ });
6248
+ var fakeDraftTaf = {
6249
+ creationDate: currentDate + "T18:00:00Z",
6250
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6251
+ taf: {
6252
+ uuid: '5f9583fjdf0f337925',
6253
+ baseTime: currentDate + "T18:00:00Z",
6254
+ validDateStart: currentDate + "T18:00:00Z",
6255
+ validDateEnd: tomorrowDate + "T23:59:00Z",
6256
+ location: 'EHLE',
6257
+ status: 'DRAFT',
6258
+ type: 'NORMAL',
6259
+ messageType: 'ORG',
6260
+ baseForecast: {
6261
+ valid: {
6262
+ start: currentDate + "T18:00:00Z",
6263
+ end: tomorrowDate + "T23:59:00Z"
6264
+ },
6265
+ wind: {
6266
+ direction: 150,
6267
+ speed: 5,
6268
+ unit: 'KT'
6269
+ },
6270
+ visibility: {
6271
+ range: 1000,
6272
+ unit: 'M'
6273
+ },
6274
+ weather: {
6275
+ weather1: 'BCFG'
6276
+ },
6277
+ cloud: {
6278
+ cloud1: {
6279
+ coverage: 'FEW',
6280
+ height: 15
6281
+ }
6282
+ }
6283
+ }
6284
+ }
6285
+ };
6286
+ ({
6287
+ creationDate: "2022-01-06T18:00:00Z",
6288
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6289
+ taf: __assign(__assign({}, fakeDraftTaf.taf), {
6290
+ baseTime: "2022-01-06T18:00:00Z",
6291
+ validDateStart: "2022-01-06T18:00:00Z",
6292
+ validDateEnd: "2022-01-07T23:59:00Z",
6293
+ baseForecast: __assign(__assign({}, fakeDraftTaf.taf.baseForecast), {
6294
+ valid: {
6295
+ start: "2022-01-06T18:00:00Z",
6296
+ end: "2022-01-07T23:59:00Z"
6297
+ }
6298
+ })
6299
+ })
6300
+ });
6301
+ var fakeDraftAmendmentTaf = {
6302
+ creationDate: currentDate + "T14:00:00Z",
6303
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6304
+ taf: {
6305
+ uuid: '954905487',
6306
+ previousId: '5f9583fjdf45ff4330f337925',
6307
+ issueDate: currentDate + "T14:00:00Z",
6308
+ baseTime: currentDate + "T12:00:00Z",
6309
+ validDateStart: currentDate + "T14:00:00Z",
6310
+ validDateEnd: tomorrowDate + "T18:00:00Z",
6311
+ previousValidDateStart: currentDate + "T12:00:00Z",
6312
+ previousValidDateEnd: tomorrowDate + "T18:00:00Z",
6313
+ location: 'EHAM',
6314
+ status: 'DRAFT_AMENDED',
6315
+ type: 'NORMAL',
6316
+ messageType: 'AMD',
6317
+ baseForecast: {
6318
+ valid: {
6319
+ start: currentDate + "T14:00:00Z",
6320
+ end: tomorrowDate + "T18:00:00Z"
6321
+ },
6322
+ visibility: {
6323
+ range: 600,
6324
+ unit: 'M'
6325
+ },
6326
+ wind: {
6327
+ direction: 180,
6328
+ speed: 10,
6329
+ unit: 'KT'
6330
+ },
6331
+ weather: {
6332
+ weather1: 'SN'
6333
+ },
6334
+ cloud: {
6335
+ cloud1: {
6336
+ coverage: 'BKN',
6337
+ height: 35
6338
+ }
6339
+ }
6340
+ },
6341
+ changeGroups: [{
6342
+ change: 'TEMPO',
6343
+ probability: 'PROB30',
6344
+ valid: {
6345
+ start: currentDate + "T15:00:00Z",
6346
+ end: currentDate + "T16:00:00Z"
6347
+ },
6348
+ visibility: {
6349
+ range: 100,
6350
+ unit: 'M'
6351
+ },
6352
+ cloud: {
6353
+ cloud1: {
6354
+ verticalVisibility: 5
6355
+ }
6356
+ }
6357
+ }]
6358
+ }
6359
+ };
6360
+
6361
+ ({
6362
+ creationDate: "2022-01-06T14:00:00Z",
6363
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
6364
+ taf: __assign(__assign({}, fakeDraftAmendmentTaf.taf), {
6365
+ location: 'EHRD',
6366
+ issueDate: "2022-01-06T14:00:00Z",
6367
+ baseTime: "2022-01-06T12:00:00Z",
6368
+ validDateStart: "2022-01-06T14:00:00Z",
6369
+ validDateEnd: "2022-01-07T18:00:00Z",
6370
+ previousValidDateStart: "2022-01-06T12:00:00Z",
6371
+ previousValidDateEnd: "2022-01-07T18:00:00Z",
6372
+ baseForecast: __assign(__assign({}, fakeDraftAmendmentTaf.taf.baseForecast), {
6373
+ valid: {
6374
+ start: "2022-01-06T14:00:00Z",
6375
+ end: "2022-01-07T18:00:00Z"
6376
+ }
6377
+ }),
6378
+ changeGroups: []
6379
+ })
6380
+ });
6381
+ var fakeAmendmentTaf = {
6382
+ creationDate: currentDate + "T14:00:00Z",
6383
+ canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
6384
+ taf: {
6385
+ uuid: '754905486',
6386
+ previousId: '5f9583fjdf45ff4330f337925',
6387
+ issueDate: currentDate + "T14:00:00Z",
6388
+ baseTime: currentDate + "T12:00:00Z",
6389
+ validDateStart: currentDate + "T14:00:00Z",
6390
+ validDateEnd: tomorrowDate + "T18:00:00Z",
6391
+ previousValidDateStart: currentDate + "T12:00:00Z",
6392
+ previousValidDateEnd: tomorrowDate + "T18:00:00Z",
6393
+ location: 'EHAM',
6394
+ status: 'AMENDED',
6395
+ type: 'NORMAL',
6396
+ messageType: 'AMD',
6397
+ baseForecast: {
6398
+ valid: {
6399
+ start: currentDate + "T14:00:00Z",
6400
+ end: tomorrowDate + "T18:00:00Z"
6401
+ },
6402
+ visibility: {
6403
+ range: 600,
6404
+ unit: 'M'
6405
+ },
6406
+ wind: {
6407
+ direction: 180,
6408
+ speed: 10,
6409
+ unit: 'KT'
6410
+ },
6411
+ weather: {
6412
+ weather1: 'SN'
6413
+ },
6414
+ cloud: {
6415
+ cloud1: {
6416
+ coverage: 'BKN',
6417
+ height: 35
6418
+ }
6419
+ }
6420
+ }
6421
+ }
6422
+ }; // Only use for display purposes in the list!
6423
+
6424
+ ({
6425
+ creationDate: "2022-01-06T14:00:00Z",
6426
+ canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
6427
+ taf: __assign(__assign({}, fakeAmendmentTaf.taf), {
6428
+ uuid: '7549058980',
6429
+ issueDate: "2022-01-06T14:00:00Z",
6430
+ baseTime: "2022-01-06T12:00:00Z",
6431
+ validDateStart: "2022-01-06T14:00:00Z",
6432
+ validDateEnd: "2022-01-07T18:00:00Z",
6433
+ previousValidDateStart: "2022-01-06T12:00:00Z",
6434
+ previousValidDateEnd: "2022-01-07T18:00:00Z",
6435
+ baseForecast: __assign(__assign({}, fakeAmendmentTaf.taf.baseForecast), {
6436
+ valid: {
6437
+ start: "2022-01-06T14:00:00Z",
6438
+ end: "2022-01-07T18:00:00Z"
6439
+ }
6440
+ })
6441
+ })
6442
+ });
6443
+
6444
+ var fakeTafTac = 'TAF EHAM 0812/0918 20020G35KT 0500 SN BKN040\nBECMG 0814/0816 0700 BKN001=';
6445
+
6446
+ var fakePromise = function fakePromise(withRandomError) {
6447
+ return new Promise(function (resolve, reject) {
6448
+ setTimeout(function () {
6449
+ if (!withRandomError) return resolve();
6450
+ var randomError = Math.floor(Math.random() * 4) + 1;
6451
+ return randomError === 4 ? reject(new Error('something went wrong')) : resolve();
6452
+ }, 300);
6453
+ });
6454
+ };
6455
+
6456
+ var fakeAxiosInstance = {
6457
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6458
+ get: function get(_url, _params) {
6459
+ return fakePromise(false);
6460
+ },
6461
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
6462
+ post: function post(_url, _params) {
6463
+ return fakePromise(false);
6464
+ }
6465
+ };
6466
+ var createApi = function createApi() {
6467
+ return {
6468
+ getTafList: function getTafList() {
6469
+ // eslint-disable-next-line no-console
6470
+ console.log('Retrieving new TAF list');
6471
+ return fakeAxiosInstance.get('/taflist').then(function () {
6472
+ return {
6473
+ data: __spreadArray([], __read(fakeTafList))
6474
+ };
6475
+ });
6476
+ },
6477
+ getTAC: function getTAC() {
6478
+ // eslint-disable-next-line no-console
6479
+ return fakeAxiosInstance.post('/taf2tac').then(function () {
6480
+ return {
6481
+ data: fakeTafTac
6482
+ };
6483
+ });
6484
+ },
6485
+ postTaf: function postTaf(_postTaf) {
6486
+ // eslint-disable-next-line no-console
6487
+ console.log("The new status of the taf will be " + _postTaf.changeStatusTo); // eslint-disable-next-line no-console
6488
+
6489
+ console.log('form has been posted with following values:', _postTaf.taf);
6490
+ return fakeAxiosInstance.post('/taf', _postTaf);
6491
+ }
6492
+ };
6493
+ };
6494
+
6495
+ exports.TafForm = TafForm;
5342
6496
  exports.TafModule = Wrapper;
5343
- exports.createApi = createApi;
6497
+ exports.createApi = createApi$1;
6498
+ exports.createFakeApi = createApi;
5344
6499
 
5345
6500
  Object.defineProperty(exports, '__esModule', { value: true });
5346
6501