@opengeoweb/taf 15.0.0 → 15.2.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.
package/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { Chip, Box, Typography, Grid, Button, TextField, MenuList, MenuItem, LinearProgress, Card, Tabs, Tab, Backdrop, CircularProgress } from '@mui/material';
2
+ import { Chip, Box, Typography, Grid, Button, TextField, LinearProgress, MenuList, MenuItem, Card, Tabs, Tab, Backdrop, CircularProgress } from '@mui/material';
3
3
  import React, { useState, useEffect } from 'react';
4
4
  import { useFormContext, useFieldArray, Controller } from 'react-hook-form';
5
5
  import { useDispatch } from 'react-redux';
@@ -7,7 +7,7 @@ import { ReactSortable } from 'react-sortablejs';
7
7
  import Sortable from 'sortablejs';
8
8
  import { useAuthenticationContext as useAuthenticationContext$1 } from '@opengeoweb/authentication';
9
9
  import { HIDDEN_INPUT_HELPER_IS_DRAFT, getDeepProperty, useDraftFormHelpers, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
10
- import { SHARED_NAMESPACE, CustomTooltip, ToolContainerDraggable, Avatar, getInitials, CustomIconButton, dateUtils, sessionStorageProvider, getErrorMessage as getErrorMessage$1, getWarningMessage, ToggleMenu, useConfirmationDialog, usePreventBrowserClose, SwitchButton, AlertBanner, CustomDialog, ToolHeader, LastUpdateTime, ErrorBoundary } from '@opengeoweb/shared';
10
+ import { SHARED_NAMESPACE, CustomTooltip, ToolContainerDraggable, Avatar, getInitials, CustomIconButton, dateUtils, sessionStorageProvider, getErrorMessage as getErrorMessage$1, getWarningMessage, AlertBanner, ToggleMenu, useConfirmationDialog, usePreventBrowserClose, SwitchButton, CustomDialog, ToolHeader, LastUpdateTime, ErrorBoundary } from '@opengeoweb/shared';
11
11
  import { snackbarActions, snackbarTypes } from '@opengeoweb/snackbar';
12
12
  import 'i18next';
13
13
  import { useTranslation } from 'react-i18next';
@@ -103,7 +103,9 @@ var en = {
103
103
  autotaf: "Autotaf",
104
104
  "autotaf-no-data": "No autoTAFs available",
105
105
  "autotaf-no-location": "No data available for this location",
106
- "autotaf-no-config": "Missing config key: autoTAFlocations"
106
+ "autotaf-no-config": "Missing config key: autoTAFlocations",
107
+ remark: "RMK",
108
+ "no-locations-message": "No locations available for this timeslot"
107
109
  };
108
110
  var fi = {
109
111
  "issues-button-title": "Näkymän yksityiskohdat",
@@ -355,7 +357,8 @@ var nl = {
355
357
  autotaf: "Autotaf",
356
358
  "autotaf-no-data": "Geen autoTAFs beschikbaar",
357
359
  "autotaf-no-location": "Geen data beschikbaar voor deze locatie",
358
- "autotaf-no-config": "Ontbrekende configuratie: autoTAFlocations"
360
+ "autotaf-no-config": "Ontbrekende configuratie: autoTAFlocations",
361
+ "no-locations-message": "Geen locaties beschikbaar voor dit tijdslot"
359
362
  };
360
363
  var tafTranslations = {
361
364
  en: en,
@@ -2923,20 +2926,23 @@ var DATE_FORMAT_BASE_TIME = 'HH:mm dd MMM';
2923
2926
  var config = sessionStorageProvider.getConfig();
2924
2927
  var tafBaseUrl = config.GW_TAF_BASE_URL || '';
2925
2928
  var getTafList = /*#__PURE__*/function () {
2926
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(auth) {
2929
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(auth, type) {
2927
2930
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2928
2931
  while (1) switch (_context.prev = _context.next) {
2929
2932
  case 0:
2930
- return _context.abrupt("return", fetch(tafBaseUrl + "/taflist", {
2933
+ if (type === void 0) {
2934
+ type = 'TAF';
2935
+ }
2936
+ return _context.abrupt("return", fetch(tafBaseUrl + "/taflist?type=" + type, {
2931
2937
  headers: getHeaders(auth)
2932
2938
  }).then(handleResponse));
2933
- case 1:
2939
+ case 2:
2934
2940
  case "end":
2935
2941
  return _context.stop();
2936
2942
  }
2937
2943
  }, _callee);
2938
2944
  }));
2939
- return function getTafList(_x) {
2945
+ return function getTafList(_x, _x2) {
2940
2946
  return _ref.apply(this, arguments);
2941
2947
  };
2942
2948
  }();
@@ -2956,7 +2962,7 @@ var postTaf = /*#__PURE__*/function () {
2956
2962
  }
2957
2963
  }, _callee2);
2958
2964
  }));
2959
- return function postTaf(_x2, _x3) {
2965
+ return function postTaf(_x3, _x4) {
2960
2966
  return _ref2.apply(this, arguments);
2961
2967
  };
2962
2968
  }();
@@ -2976,7 +2982,7 @@ var patchTaf = /*#__PURE__*/function () {
2976
2982
  }
2977
2983
  }, _callee3);
2978
2984
  }));
2979
- return function patchTaf(_x4, _x5, _x6) {
2985
+ return function patchTaf(_x5, _x6, _x7) {
2980
2986
  return _ref3.apply(this, arguments);
2981
2987
  };
2982
2988
  }();
@@ -2996,25 +3002,28 @@ var getTAC = /*#__PURE__*/function () {
2996
3002
  }
2997
3003
  }, _callee4);
2998
3004
  }));
2999
- return function getTAC(_x7, _x8) {
3005
+ return function getTAC(_x8, _x9) {
3000
3006
  return _ref4.apply(this, arguments);
3001
3007
  };
3002
3008
  }();
3003
3009
  var getTafConfig = /*#__PURE__*/function () {
3004
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(auth) {
3010
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(auth, type) {
3005
3011
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3006
3012
  while (1) switch (_context5.prev = _context5.next) {
3007
3013
  case 0:
3008
- return _context5.abrupt("return", fetch(tafBaseUrl + "/taf-config", {
3014
+ if (type === void 0) {
3015
+ type = 'TAF';
3016
+ }
3017
+ return _context5.abrupt("return", fetch(tafBaseUrl + "/taf-config?type=" + type, {
3009
3018
  headers: getHeaders(auth)
3010
3019
  }).then(handleResponse));
3011
- case 1:
3020
+ case 2:
3012
3021
  case "end":
3013
3022
  return _context5.stop();
3014
3023
  }
3015
3024
  }, _callee5);
3016
3025
  }));
3017
- return function getTafConfig(_x9) {
3026
+ return function getTafConfig(_x0, _x1) {
3018
3027
  return _ref5.apply(this, arguments);
3019
3028
  };
3020
3029
  }();
@@ -3036,6 +3045,9 @@ var getTafConfig = /*#__PURE__*/function () {
3036
3045
  * Copyright 2022 - Finnish Meteorological Institute (FMI)
3037
3046
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3038
3047
  * */
3048
+ var isTafConfigLocationFixedPeriod = function isTafConfigLocationFixedPeriod(location) {
3049
+ return location.activity_period !== undefined;
3050
+ };
3039
3051
  var getLocationSetting = function getLocationSetting(location, locationSettings) {
3040
3052
  return locationSettings[location];
3041
3053
  };
@@ -3066,16 +3078,89 @@ var sortTafsOnIssueDate = function sortTafsOnIssueDate(tafList) {
3066
3078
  });
3067
3079
  };
3068
3080
  var getBaseTime = function getBaseTime(baseTime, location, tafConfig) {
3069
- var currentBaseTime = dateUtils.utc(baseTime);
3070
- var activityPeriod = getLocationSetting(location, tafConfig.locations).activity_period;
3071
- var nextBaseTime = dateUtils.add(dateUtils.utc(baseTime), {
3072
- hours: activityPeriod
3073
- });
3081
+ var configLocation = getLocationSetting(location, tafConfig.locations);
3082
+ var currentBaseTime;
3083
+ var nextBaseTime;
3084
+ if (isTafConfigLocationFixedPeriod(configLocation)) {
3085
+ var activityPeriod = configLocation.activity_period;
3086
+ currentBaseTime = dateUtils.utc(baseTime);
3087
+ nextBaseTime = dateUtils.add(dateUtils.utc(baseTime), {
3088
+ hours: activityPeriod
3089
+ });
3090
+ } else {
3091
+ currentBaseTime = dateUtils.utc(baseTime);
3092
+ var startTimeIndex = configLocation.valid_start_times.findLastIndex(function (hour) {
3093
+ return currentBaseTime.getUTCHours() >= hour;
3094
+ });
3095
+ // when current hour is lower than then first item in valid_start_times. we need to move to the last hour of the previous day
3096
+ if (startTimeIndex === -1) {
3097
+ var lastStartTimeIndex = configLocation.valid_start_times.length - 1;
3098
+ currentBaseTime = dateUtils.sub(currentBaseTime, {
3099
+ days: 1
3100
+ });
3101
+ currentBaseTime = dateUtils.set(currentBaseTime, {
3102
+ hours: configLocation.valid_start_times[lastStartTimeIndex],
3103
+ minutes: 0,
3104
+ seconds: 0
3105
+ });
3106
+ } else {
3107
+ // We make sure that the hours match the value in valid_start_times
3108
+ // or should we just assume that the baseTime aligns with the config here?
3109
+ currentBaseTime = dateUtils.set(currentBaseTime, {
3110
+ hours: configLocation.valid_start_times[startTimeIndex],
3111
+ minutes: 0,
3112
+ seconds: 0
3113
+ });
3114
+ }
3115
+ var nextStartTimeIndex = (startTimeIndex + 1) % configLocation.valid_start_times.length;
3116
+ var nextStartTimeHour = configLocation.valid_start_times[nextStartTimeIndex];
3117
+ nextBaseTime = dateUtils.set(currentBaseTime, {
3118
+ hours: nextStartTimeHour,
3119
+ minutes: 0,
3120
+ seconds: 0
3121
+ });
3122
+ // If next start time is earlier than or equal to current start time, it means we've wrapped to the next day
3123
+ if (nextStartTimeHour <= configLocation.valid_start_times[startTimeIndex]) {
3124
+ nextBaseTime = dateUtils.add(nextBaseTime, {
3125
+ days: 1
3126
+ });
3127
+ }
3128
+ }
3074
3129
  return {
3075
3130
  currentBaseTime: currentBaseTime,
3076
3131
  nextBaseTime: nextBaseTime
3077
3132
  };
3078
3133
  };
3134
+ /**
3135
+ * If we don't have a taf to get the baseTime from, we calculate it based on the current time and the activity_period from the config.
3136
+ * @param tafConfig
3137
+ * @returns
3138
+ */
3139
+ var calculateBaseTime = function calculateBaseTime(tafConfig) {
3140
+ var currentTime = dateUtils.utc();
3141
+ var currentHour = dateUtils.getHours(currentTime);
3142
+ // take the first location from config (via locationOrder)
3143
+ var firstLocation = tafConfig.locationOrder[0];
3144
+ var configLocation = getLocationSetting(firstLocation, tafConfig.locations);
3145
+ if (isTafConfigLocationFixedPeriod(configLocation)) {
3146
+ var activityPeriod = configLocation.activity_period;
3147
+ var baseHour = Math.floor(currentHour / activityPeriod) * activityPeriod;
3148
+ var currentBaseTime = dateUtils.set(currentTime, {
3149
+ hours: baseHour,
3150
+ minutes: 0,
3151
+ seconds: 0,
3152
+ milliseconds: 0
3153
+ });
3154
+ var nextBaseTime = dateUtils.add(currentBaseTime, {
3155
+ hours: activityPeriod
3156
+ });
3157
+ return {
3158
+ currentBaseTime: currentBaseTime,
3159
+ nextBaseTime: nextBaseTime
3160
+ };
3161
+ }
3162
+ return getBaseTime(currentTime.toUTCString(), firstLocation, tafConfig);
3163
+ };
3079
3164
  var getTafTimeSlot = function getTafTimeSlot(baseTime, location, status, tafConfig) {
3080
3165
  var now = dateUtils.utc();
3081
3166
  var _getBaseTime = getBaseTime(baseTime, location, tafConfig),
@@ -3219,17 +3304,53 @@ var parseErrorMessage = function parseErrorMessage(error, params, t) {
3219
3304
  };
3220
3305
  };
3221
3306
 
3222
- var useTafList = function useTafList(disabled) {
3307
+ var useTafList = function useTafList(type, disabled) {
3308
+ if (type === void 0) {
3309
+ type = 'TAF';
3310
+ }
3223
3311
  if (disabled === void 0) {
3224
3312
  disabled = false;
3225
3313
  }
3226
- return useAuthQuery(['taf-list'], getTafList, disabled, 1000 * 60 * 5);
3314
+ return useAuthQuery(['taf-list', type], /*#__PURE__*/function () {
3315
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(auth) {
3316
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3317
+ while (1) switch (_context.prev = _context.next) {
3318
+ case 0:
3319
+ return _context.abrupt("return", getTafList(auth, type));
3320
+ case 1:
3321
+ case "end":
3322
+ return _context.stop();
3323
+ }
3324
+ }, _callee);
3325
+ }));
3326
+ return function (_x) {
3327
+ return _ref.apply(this, arguments);
3328
+ };
3329
+ }(), disabled, 1000 * 60 * 5);
3227
3330
  };
3228
- var useTafConfig = function useTafConfig(disabled) {
3331
+ var useTafConfig = function useTafConfig(type, disabled) {
3332
+ if (type === void 0) {
3333
+ type = 'TAF';
3334
+ }
3229
3335
  if (disabled === void 0) {
3230
3336
  disabled = false;
3231
3337
  }
3232
- return useAuthQuery(['taf-config'], getTafConfig, disabled, false);
3338
+ return useAuthQuery(['taf-config', type], /*#__PURE__*/function () {
3339
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(auth) {
3340
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3341
+ while (1) switch (_context2.prev = _context2.next) {
3342
+ case 0:
3343
+ return _context2.abrupt("return", getTafConfig(auth, type));
3344
+ case 1:
3345
+ case "end":
3346
+ return _context2.stop();
3347
+ }
3348
+ }, _callee2);
3349
+ }));
3350
+ return function (_x2) {
3351
+ return _ref2.apply(this, arguments);
3352
+ };
3353
+ }(), disabled, false);
3233
3354
  };
3234
3355
  var usePostTaf = function usePostTaf() {
3235
3356
  var queryClient = useQueryClient();
@@ -3240,83 +3361,83 @@ var usePostTaf = function usePostTaf() {
3240
3361
  var dispatch = useDispatch();
3241
3362
  return useMutation({
3242
3363
  mutationFn: function () {
3243
- var _mutationFn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
3364
+ var _mutationFn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
3244
3365
  var tafData, setError;
3245
- return _regeneratorRuntime().wrap(function _callee$(_context) {
3246
- while (1) switch (_context.prev = _context.next) {
3366
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3367
+ while (1) switch (_context3.prev = _context3.next) {
3247
3368
  case 0:
3248
- tafData = _ref.tafData, setError = _ref.setError;
3369
+ tafData = _ref3.tafData, setError = _ref3.setError;
3249
3370
  if (auth) {
3250
- _context.next = 3;
3371
+ _context3.next = 3;
3251
3372
  break;
3252
3373
  }
3253
3374
  throw new Error('Authentication context not found');
3254
3375
  case 3:
3255
3376
  setError(null);
3256
- return _context.abrupt("return", postTaf(auth, tafData));
3377
+ return _context3.abrupt("return", postTaf(auth, tafData));
3257
3378
  case 5:
3258
3379
  case "end":
3259
- return _context.stop();
3380
+ return _context3.stop();
3260
3381
  }
3261
- }, _callee);
3382
+ }, _callee3);
3262
3383
  }));
3263
- function mutationFn(_x) {
3384
+ function mutationFn(_x3) {
3264
3385
  return _mutationFn.apply(this, arguments);
3265
3386
  }
3266
3387
  return mutationFn;
3267
3388
  }(),
3268
3389
  onSuccess: function () {
3269
- var _onSuccess = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_data, _ref2) {
3390
+ var _onSuccess = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_data, _ref4) {
3270
3391
  var tafData, isAutoSaved, message;
3271
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3272
- while (1) switch (_context2.prev = _context2.next) {
3392
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3393
+ while (1) switch (_context4.prev = _context4.next) {
3273
3394
  case 0:
3274
- tafData = _ref2.tafData, isAutoSaved = _ref2.isAutoSaved;
3395
+ tafData = _ref4.tafData, isAutoSaved = _ref4.isAutoSaved;
3275
3396
  message = getSnackbarMessage(tafData, isAutoSaved, t);
3276
3397
  dispatch(snackbarActions.openSnackbar({
3277
3398
  type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
3278
3399
  message: message
3279
3400
  }));
3280
3401
  // trigger refetch for the list
3281
- _context2.next = 5;
3402
+ _context4.next = 5;
3282
3403
  return queryClient.invalidateQueries({
3283
3404
  queryKey: ['taf-list']
3284
3405
  });
3285
3406
  case 5:
3286
3407
  case "end":
3287
- return _context2.stop();
3408
+ return _context4.stop();
3288
3409
  }
3289
- }, _callee2);
3410
+ }, _callee4);
3290
3411
  }));
3291
- function onSuccess(_x2, _x3) {
3412
+ function onSuccess(_x4, _x5) {
3292
3413
  return _onSuccess.apply(this, arguments);
3293
3414
  }
3294
3415
  return onSuccess;
3295
3416
  }(),
3296
3417
  onError: function () {
3297
- var _onError = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error, _ref3) {
3418
+ var _onError = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(error, _ref5) {
3298
3419
  var tafData, setError, tafError;
3299
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3300
- while (1) switch (_context3.prev = _context3.next) {
3420
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3421
+ while (1) switch (_context5.prev = _context5.next) {
3301
3422
  case 0:
3302
- tafData = _ref3.tafData, setError = _ref3.setError;
3423
+ tafData = _ref5.tafData, setError = _ref5.setError;
3303
3424
  tafError = parseErrorMessage(error, tafData, t);
3304
3425
  setError(tafError);
3305
3426
  if (!isWarning(tafError)) {
3306
- _context3.next = 6;
3427
+ _context5.next = 6;
3307
3428
  break;
3308
3429
  }
3309
- _context3.next = 6;
3430
+ _context5.next = 6;
3310
3431
  return queryClient.invalidateQueries({
3311
3432
  queryKey: ['taf-list']
3312
3433
  });
3313
3434
  case 6:
3314
3435
  case "end":
3315
- return _context3.stop();
3436
+ return _context5.stop();
3316
3437
  }
3317
- }, _callee3);
3438
+ }, _callee5);
3318
3439
  }));
3319
- function onError(_x4, _x5) {
3440
+ function onError(_x6, _x7) {
3320
3441
  return _onError.apply(this, arguments);
3321
3442
  }
3322
3443
  return onError;
@@ -3331,45 +3452,45 @@ var usePatchTaf = function usePatchTaf() {
3331
3452
  t = _useTafTranslation2.t;
3332
3453
  return useMutation({
3333
3454
  mutationFn: function () {
3334
- var _mutationFn2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref4) {
3455
+ var _mutationFn2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref6) {
3335
3456
  var tafData, setError, force;
3336
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3337
- while (1) switch (_context4.prev = _context4.next) {
3457
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
3458
+ while (1) switch (_context6.prev = _context6.next) {
3338
3459
  case 0:
3339
- tafData = _ref4.tafData, setError = _ref4.setError, force = _ref4.force;
3460
+ tafData = _ref6.tafData, setError = _ref6.setError, force = _ref6.force;
3340
3461
  if (auth) {
3341
- _context4.next = 3;
3462
+ _context6.next = 3;
3342
3463
  break;
3343
3464
  }
3344
3465
  throw new Error('Authentication context not found');
3345
3466
  case 3:
3346
3467
  setError(null);
3347
- return _context4.abrupt("return", patchTaf(auth, tafData, force));
3468
+ return _context6.abrupt("return", patchTaf(auth, tafData, force));
3348
3469
  case 5:
3349
3470
  case "end":
3350
- return _context4.stop();
3471
+ return _context6.stop();
3351
3472
  }
3352
- }, _callee4);
3473
+ }, _callee6);
3353
3474
  }));
3354
- function mutationFn(_x6) {
3475
+ function mutationFn(_x8) {
3355
3476
  return _mutationFn2.apply(this, arguments);
3356
3477
  }
3357
3478
  return mutationFn;
3358
3479
  }(),
3359
3480
  onSuccess: function () {
3360
- var _onSuccess2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
3361
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3362
- while (1) switch (_context5.prev = _context5.next) {
3481
+ var _onSuccess2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
3482
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
3483
+ while (1) switch (_context7.prev = _context7.next) {
3363
3484
  case 0:
3364
- _context5.next = 2;
3485
+ _context7.next = 2;
3365
3486
  return queryClient.invalidateQueries({
3366
3487
  queryKey: ['taf-list']
3367
3488
  });
3368
3489
  case 2:
3369
3490
  case "end":
3370
- return _context5.stop();
3491
+ return _context7.stop();
3371
3492
  }
3372
- }, _callee5);
3493
+ }, _callee7);
3373
3494
  }));
3374
3495
  function onSuccess() {
3375
3496
  return _onSuccess2.apply(this, arguments);
@@ -3377,22 +3498,22 @@ var usePatchTaf = function usePatchTaf() {
3377
3498
  return onSuccess;
3378
3499
  }(),
3379
3500
  onError: function () {
3380
- var _onError2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(error, _ref5) {
3501
+ var _onError2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(error, _ref7) {
3381
3502
  var tafData, setError, newError;
3382
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
3383
- while (1) switch (_context6.prev = _context6.next) {
3503
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
3504
+ while (1) switch (_context8.prev = _context8.next) {
3384
3505
  case 0:
3385
- tafData = _ref5.tafData, setError = _ref5.setError;
3506
+ tafData = _ref7.tafData, setError = _ref7.setError;
3386
3507
  if (!(error.cause === 409)) {
3387
- _context6.next = 6;
3508
+ _context8.next = 6;
3388
3509
  break;
3389
3510
  }
3390
- _context6.next = 4;
3511
+ _context8.next = 4;
3391
3512
  return queryClient.invalidateQueries({
3392
3513
  queryKey: ['taf-list']
3393
3514
  });
3394
3515
  case 4:
3395
- _context6.next = 8;
3516
+ _context8.next = 8;
3396
3517
  break;
3397
3518
  case 6:
3398
3519
  // no refetch, show error message
@@ -3400,11 +3521,11 @@ var usePatchTaf = function usePatchTaf() {
3400
3521
  setError(newError);
3401
3522
  case 8:
3402
3523
  case "end":
3403
- return _context6.stop();
3524
+ return _context8.stop();
3404
3525
  }
3405
- }, _callee6);
3526
+ }, _callee8);
3406
3527
  }));
3407
- function onError(_x7, _x8) {
3528
+ function onError(_x9, _x0) {
3408
3529
  return _onError2.apply(this, arguments);
3409
3530
  }
3410
3531
  return onError;
@@ -3416,26 +3537,26 @@ var useGetTAC = function useGetTAC() {
3416
3537
  auth = _useAuthenticationCon3.auth;
3417
3538
  return useMutation({
3418
3539
  mutationFn: function () {
3419
- var _mutationFn3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref6) {
3540
+ var _mutationFn3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref8) {
3420
3541
  var tafData;
3421
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
3422
- while (1) switch (_context7.prev = _context7.next) {
3542
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
3543
+ while (1) switch (_context9.prev = _context9.next) {
3423
3544
  case 0:
3424
- tafData = _ref6.tafData;
3545
+ tafData = _ref8.tafData;
3425
3546
  if (auth) {
3426
- _context7.next = 3;
3547
+ _context9.next = 3;
3427
3548
  break;
3428
3549
  }
3429
3550
  throw new Error('Authentication context not found');
3430
3551
  case 3:
3431
- return _context7.abrupt("return", getTAC(auth, tafData));
3552
+ return _context9.abrupt("return", getTAC(auth, tafData));
3432
3553
  case 4:
3433
3554
  case "end":
3434
- return _context7.stop();
3555
+ return _context9.stop();
3435
3556
  }
3436
- }, _callee7);
3557
+ }, _callee9);
3437
3558
  }));
3438
- function mutationFn(_x9) {
3559
+ function mutationFn(_x1) {
3439
3560
  return _mutationFn3.apply(this, arguments);
3440
3561
  }
3441
3562
  return mutationFn;
@@ -3947,11 +4068,14 @@ var createChangeGroup = function createChangeGroup(changeGroup) {
3947
4068
  cloud: Object.assign({}, emptyChangegroup.cloud, changeGroup.cloud)
3948
4069
  });
3949
4070
  };
3950
- var prepareTafValues = function prepareTafValues(_taf, tafAction, addEmptyChangeGroups) {
4071
+ var prepareTafValues = function prepareTafValues(_taf, tafAction, addEmptyChangeGroups, shouldEnableRemark) {
3951
4072
  var _taf$changeGroups, _Object$assign2;
3952
4073
  if (addEmptyChangeGroups === void 0) {
3953
4074
  addEmptyChangeGroups = false;
3954
4075
  }
4076
+ if (shouldEnableRemark === void 0) {
4077
+ shouldEnableRemark = false;
4078
+ }
3955
4079
  // If action is AMEND/CORRECT/DRAFT_AMEND/DRAFT_CORRECTION - add previous valid start and end
3956
4080
  // If action is AMEND/DRAFT_AMEND - update validity start time to current time
3957
4081
  var taf = tafAction === 'AMEND' || tafAction === 'DRAFT_AMEND' || tafAction === 'CORRECT' || tafAction === 'DRAFT_CORRECT' ? getAmendedCorrectedTafTimes(_taf, tafAction) : _taf;
@@ -3973,18 +4097,24 @@ var prepareTafValues = function prepareTafValues(_taf, tafAction, addEmptyChange
3973
4097
  }
3974
4098
  return Object.assign({
3975
4099
  issueDate: '',
4100
+ type: 'TAF',
3976
4101
  previousId: null,
3977
4102
  previousValidDateStart: null,
3978
4103
  previousValidDateEnd: null
4104
+ }, shouldEnableRemark && {
4105
+ remark: ''
3979
4106
  }, taf, (_Object$assign2 = {
3980
4107
  messageType: getMessageType(taf, tafAction),
3981
4108
  baseForecast: baseForecast,
3982
4109
  changeGroups: changeGroups
3983
4110
  }, _Object$assign2[HIDDEN_INPUT_HELPER_IS_DRAFT] = true, _Object$assign2));
3984
4111
  };
3985
- var prepareTafExportValues = function prepareTafExportValues(tafToCopy, currentTaf) {
4112
+ var prepareTafExportValues = function prepareTafExportValues(tafToCopy, currentTaf, shouldEnableRemark) {
3986
4113
  var _currentTaf$baseForec;
3987
- var convertedCopy = prepareTafValues(tafToCopy, undefined, false);
4114
+ if (shouldEnableRemark === void 0) {
4115
+ shouldEnableRemark = false;
4116
+ }
4117
+ var convertedCopy = prepareTafValues(tafToCopy, undefined, false, shouldEnableRemark);
3988
4118
  var baseForecast = convertedCopy.baseForecast,
3989
4119
  _convertedCopy$change = convertedCopy.changeGroups,
3990
4120
  changeGroups = _convertedCopy$change === void 0 ? [] : _convertedCopy$change;
@@ -4122,7 +4252,9 @@ var ResponsiveWrapper = function ResponsiveWrapper(_ref) {
4122
4252
  });
4123
4253
  };
4124
4254
 
4125
- var _excluded$4 = ["shouldPreventUppercase"];
4255
+ var _excluded$4 = ["shouldPreventUppercase", "textAlign", "sx"];
4256
+ var TEXTFIELD_WIDTH_PERCENTAGE = 100 / 13;
4257
+ var TEXTFIELD_MIN_WIDTH = '60px';
4126
4258
  var textFieldStyle = function textFieldStyle(theme, shouldPreventUppercase) {
4127
4259
  var _ref;
4128
4260
  return _ref = {
@@ -4145,6 +4277,10 @@ var textFieldStyle = function textFieldStyle(theme, shouldPreventUppercase) {
4145
4277
  WebkitTransitionDelay: '86400s' // 1 day delay
4146
4278
  }
4147
4279
  },
4280
+ '&[data-text-align="left"] input': {
4281
+ textAlign: 'left',
4282
+ paddingLeft: '12px'
4283
+ },
4148
4284
  label: {
4149
4285
  transformOrigin: 'center top',
4150
4286
  right: 0,
@@ -4157,12 +4293,20 @@ var textFieldStyle = function textFieldStyle(theme, shouldPreventUppercase) {
4157
4293
  maxWidth: '100%',
4158
4294
  transform: 'translate(0px, 16px) scale(1)'
4159
4295
  },
4296
+ '&[data-text-align="left"] label': {
4297
+ transformOrigin: 'left top',
4298
+ transform: 'translate(12px, 16px) scale(1)',
4299
+ textAlign: 'left'
4300
+ },
4160
4301
  // shrink
4161
4302
  ' .MuiInputLabel-shrink': {
4162
4303
  transform: 'translate(2px, 10px) scale(0.75) !important',
4163
4304
  letterSpacing: '0.33px',
4164
4305
  textAlign: 'left'
4165
4306
  },
4307
+ '&[data-text-align="left"] .MuiInputLabel-shrink': {
4308
+ transform: 'translate(12px, 10px) scale(0.75) !important'
4309
+ },
4166
4310
  // root
4167
4311
  '&': {
4168
4312
  '.Mui-disabled:before': {
@@ -4203,16 +4347,19 @@ var getDisplayValue = function getDisplayValue(value, disabled) {
4203
4347
  var BaseTextField = /*#__PURE__*/React.memo(function (_ref2) {
4204
4348
  var _ref2$shouldPreventUp = _ref2.shouldPreventUppercase,
4205
4349
  shouldPreventUppercase = _ref2$shouldPreventUp === void 0 ? false : _ref2$shouldPreventUp,
4350
+ textAlign = _ref2.textAlign,
4351
+ sx = _ref2.sx,
4206
4352
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$4);
4207
4353
  var theme = useTheme();
4208
4354
  var styling = textFieldStyle(theme, shouldPreventUppercase);
4209
4355
  return jsx(TextField, Object.assign({
4210
- sx: styling,
4356
+ "data-text-align": textAlign,
4357
+ sx: [styling].concat(Array.isArray(sx) ? sx : [sx]),
4211
4358
  type: "text",
4212
4359
  variant: "filled"
4213
4360
  }, props));
4214
4361
  }, function (prevProps, nextProps) {
4215
- return prevProps.value === nextProps.value && prevProps.error === nextProps.error && prevProps.name === nextProps.name && prevProps.disabled === nextProps.disabled;
4362
+ return prevProps.value === nextProps.value && prevProps.error === nextProps.error && prevProps.name === nextProps.name && prevProps.disabled === nextProps.disabled && prevProps.textAlign === nextProps.textAlign;
4216
4363
  });
4217
4364
  var TafFormTextField = function TafFormTextField(_ref3) {
4218
4365
  var label = _ref3.label,
@@ -4291,8 +4438,8 @@ var TafFormTextField = function TafFormTextField(_ref3) {
4291
4438
  var hasError = !!fieldErrors;
4292
4439
  return jsx(Grid, {
4293
4440
  sx: {
4294
- width: 100 / 13 + "%",
4295
- minWidth: 60
4441
+ width: TEXTFIELD_WIDTH_PERCENTAGE + "%",
4442
+ minWidth: TEXTFIELD_MIN_WIDTH
4296
4443
  },
4297
4444
  children: jsx(Controller, {
4298
4445
  control: control,
@@ -4331,6 +4478,78 @@ var TafFormTextField = function TafFormTextField(_ref3) {
4331
4478
  });
4332
4479
  };
4333
4480
 
4481
+ var TafRemarkField = function TafRemarkField(_ref) {
4482
+ var disabled = _ref.disabled,
4483
+ isEditor = _ref.isEditor;
4484
+ var _useTafTranslation = useTafTranslation(),
4485
+ t = _useTafTranslation.t;
4486
+ var _useFormContext = useFormContext(),
4487
+ control = _useFormContext.control,
4488
+ setValue = _useFormContext.setValue,
4489
+ trigger = _useFormContext.trigger;
4490
+ return jsx(Box, {
4491
+ sx: {
4492
+ display: 'flex',
4493
+ flexDirection: 'row',
4494
+ justifyContent: 'flex-end',
4495
+ marginTop: '8px',
4496
+ marginRight: 'max(28px, 3.5%)',
4497
+ paddingLeft: {
4498
+ xs: '2px',
4499
+ lg: '10px'
4500
+ },
4501
+ paddingRight: {
4502
+ xs: '2px',
4503
+ lg: '10px'
4504
+ }
4505
+ },
4506
+ children: jsx(Controller, {
4507
+ control: control,
4508
+ name: "remark",
4509
+ render: function render(_ref2) {
4510
+ var field = _ref2.field;
4511
+ return jsx(BaseTextField, {
4512
+ disabled: disabled,
4513
+ inputRef: field.ref,
4514
+ label: t('remark'),
4515
+ name: "remark",
4516
+ onBlur: function onBlur() {
4517
+ void trigger();
4518
+ field.onBlur();
4519
+ },
4520
+ onChange: function onChange(event) {
4521
+ field.onChange(event.currentTarget.value.toUpperCase());
4522
+ },
4523
+ onKeyDown: function onKeyDown(event) {
4524
+ if (event.key.toUpperCase() === 'D' && !field.value) {
4525
+ event.preventDefault();
4526
+ setValue('remark', 'DUE TO LACK OF DATA NO ');
4527
+ }
4528
+ },
4529
+ size: "small",
4530
+ slotProps: {
4531
+ htmlInput: {
4532
+ 'aria-label': 'remark'
4533
+ }
4534
+ },
4535
+ sx: {
4536
+ // the size of a taf textfield
4537
+ '--taf-textfield-size': "max(" + TEXTFIELD_WIDTH_PERCENTAGE + "%, " + TEXTFIELD_MIN_WIDTH + ")",
4538
+ // the width of the row minus the drag thingie
4539
+ '--total-row-size': 'calc(100% - 62px)',
4540
+ // calculates the size of the taf remark field so that it nicely aligns with the taf textfield rows
4541
+ // even when these rows are wrapped.
4542
+ width: isEditor ? "round(down, var(--total-row-size), var(--taf-textfield-size))" : '100%',
4543
+ marginLeft: 'auto'
4544
+ },
4545
+ textAlign: "left",
4546
+ value: field.value || ''
4547
+ });
4548
+ }
4549
+ })
4550
+ });
4551
+ };
4552
+
4334
4553
  /* *
4335
4554
  * Licensed under the Apache License, Version 2.0 (the "License");
4336
4555
  * you may not use this file except in compliance with the License.
@@ -4392,6 +4611,96 @@ var validateProbabilityField = function validateProbabilityField(value) {
4392
4611
  return isValid ? true : invalidProbabilityMessage;
4393
4612
  };
4394
4613
 
4614
+ var TafConfigContext = /*#__PURE__*/React.createContext({
4615
+ tafConfig: null
4616
+ });
4617
+ var useTafConfigContext = function useTafConfigContext() {
4618
+ return React.useContext(TafConfigContext);
4619
+ };
4620
+ var TafConfigWrapper = function TafConfigWrapper(_ref) {
4621
+ var children = _ref.children,
4622
+ _ref$type = _ref.type,
4623
+ type = _ref$type === void 0 ? 'TAF' : _ref$type;
4624
+ var _useTafTranslation = useTafTranslation(),
4625
+ t = _useTafTranslation.t;
4626
+ var _React$useState = React.useState(null),
4627
+ errorMessage = _React$useState[0],
4628
+ setErrorMessage = _React$useState[1];
4629
+ var ERROR_CONFIG = t('error-config');
4630
+ var ERROR_CONFIG_MESSAGE = t('error-config-message');
4631
+ var _useAuthenticationCon = useAuthenticationContext$1(),
4632
+ isLoggedIn = _useAuthenticationCon.isLoggedIn;
4633
+ var ERROR_AUTH = t('error-auth');
4634
+ var ERROR_AUTH_MESSAGE = t('error-auth-message');
4635
+ var _useTafConfig = useTafConfig(type),
4636
+ isFetching = _useTafConfig.isFetching,
4637
+ tafConfigError = _useTafConfig.error,
4638
+ tafConfig = _useTafConfig.data,
4639
+ fetchConfig = _useTafConfig.refetch;
4640
+ var onFetchConfig = /*#__PURE__*/function () {
4641
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
4642
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
4643
+ while (1) switch (_context.prev = _context.next) {
4644
+ case 0:
4645
+ _context.next = 2;
4646
+ return fetchConfig();
4647
+ case 2:
4648
+ case "end":
4649
+ return _context.stop();
4650
+ }
4651
+ }, _callee);
4652
+ }));
4653
+ return function onFetchConfig() {
4654
+ return _ref2.apply(this, arguments);
4655
+ };
4656
+ }();
4657
+ React.useEffect(function () {
4658
+ if (!isLoggedIn) {
4659
+ setErrorMessage({
4660
+ title: ERROR_AUTH,
4661
+ info: ERROR_AUTH_MESSAGE
4662
+ });
4663
+ } else if (tafConfigError) {
4664
+ setErrorMessage({
4665
+ title: ERROR_CONFIG,
4666
+ info: tafConfigError.message
4667
+ });
4668
+ } else {
4669
+ setErrorMessage(null);
4670
+ }
4671
+ }, [t, isLoggedIn, tafConfigError, ERROR_CONFIG, ERROR_AUTH, ERROR_AUTH_MESSAGE]);
4672
+ var contextValue = React.useMemo(function () {
4673
+ return {
4674
+ tafConfig: tafConfig
4675
+ };
4676
+ }, [tafConfig]);
4677
+ if (isLoggedIn && isFetching) {
4678
+ return jsx(LinearProgress, {
4679
+ color: "secondary",
4680
+ "data-testid": "tafconfig-loading-bar",
4681
+ sx: {
4682
+ marginBottom: '-4px'
4683
+ }
4684
+ });
4685
+ }
4686
+ if (errorMessage || !tafConfig) {
4687
+ return jsx(AlertBanner, {
4688
+ actionButtonProps: !errorMessage || (errorMessage == null ? void 0 : errorMessage.title) !== ERROR_AUTH ? {
4689
+ title: t('error-title-retry'),
4690
+ onClick: onFetchConfig
4691
+ } : undefined,
4692
+ "data-testid": "error-message",
4693
+ info: errorMessage ? errorMessage.info : ERROR_CONFIG_MESSAGE,
4694
+ severity: "error",
4695
+ title: errorMessage ? errorMessage.title : ERROR_CONFIG
4696
+ });
4697
+ }
4698
+ return jsx(TafConfigContext.Provider, {
4699
+ value: contextValue,
4700
+ children: children
4701
+ });
4702
+ };
4703
+
4395
4704
  var TafFormOptionsButton = function TafFormOptionsButton(_ref) {
4396
4705
  var isChangeGroup = _ref.isChangeGroup,
4397
4706
  addChangeGroupBelow = _ref.addChangeGroupBelow,
@@ -4473,6 +4782,8 @@ var TafFormRow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
4473
4782
  var _useFormContext = useFormContext(),
4474
4783
  getValues = _useFormContext.getValues,
4475
4784
  trigger = _useFormContext.trigger;
4785
+ var _useTafConfigContext = useTafConfigContext(),
4786
+ tafConfig = _useTafConfigContext.tafConfig;
4476
4787
  // cross-field required validation
4477
4788
  var _getRequiredCrossFiel = getRequiredCrossFields(fieldNames),
4478
4789
  mainFields = _getRequiredCrossFiel[0],
@@ -4499,8 +4810,13 @@ var TafFormRow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
4499
4810
  var _validateRequiredMainFields = function validateRequiredMainFields(value, fieldName) {
4500
4811
  var changeField = getValues(namePrefix + ".change");
4501
4812
  var visibilityField = getValues(namePrefix + ".visibility");
4502
- var isFM = changeField && changeField.trim() === 'FM';
4503
- var isCAVOK = visibilityField && visibilityField.trim() === 'CAVOK';
4813
+ var isFM = (changeField == null ? void 0 : changeField.trim()) === 'FM';
4814
+ var isCAVOK = (visibilityField == null ? void 0 : visibilityField.trim()) === 'CAVOK';
4815
+ // it is possible to send a empty row when the remark field has "DUE TO LACK OF DATA NO NAF" in it
4816
+ var remark = getValues('remark');
4817
+ if ((tafConfig == null ? void 0 : tafConfig.type) === 'NAF' && (remark == null ? void 0 : remark.toUpperCase()) === 'DUE TO LACK OF DATA NO NAF') {
4818
+ return true;
4819
+ }
4504
4820
  if (isNotRequiredForAction(value) !== true && !value.length) {
4505
4821
  if (isChangeGroup && isFM || !isChangeGroup) {
4506
4822
  // exception for CavOK
@@ -5019,7 +5335,9 @@ var TafForm = /*#__PURE__*/React.memo(function (_ref) {
5019
5335
  }, _callee2);
5020
5336
  })) : _ref$onSwitchEditor,
5021
5337
  _ref$previousTaf = _ref.previousTaf,
5022
- previousTaf = _ref$previousTaf === void 0 ? null : _ref$previousTaf;
5338
+ previousTaf = _ref$previousTaf === void 0 ? null : _ref$previousTaf,
5339
+ _ref$shouldEnableRema = _ref.shouldEnableRemark,
5340
+ shouldEnableRemark = _ref$shouldEnableRema === void 0 ? false : _ref$shouldEnableRema;
5023
5341
  var _useTafTranslation = useTafTranslation(),
5024
5342
  t = _useTafTranslation.t;
5025
5343
  var formRef = React.useRef(null);
@@ -5066,7 +5384,7 @@ var TafForm = /*#__PURE__*/React.memo(function (_ref) {
5066
5384
  onPreventCloseView(isFormDirty);
5067
5385
  // eslint-disable-next-line react-hooks/exhaustive-deps
5068
5386
  }, [isFormDirty]);
5069
- var hiddenInputFields = ['baseTime', 'issueDate', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd', HIDDEN_INPUT_HELPER_IS_DRAFT];
5387
+ var hiddenInputFields = ['baseTime', 'issueDate', 'uuid', 'validDateStart', 'validDateEnd', 'status', 'previousId', 'previousValidDateStart', 'previousValidDateEnd', 'type', HIDDEN_INPUT_HELPER_IS_DRAFT];
5070
5388
  var onSubmit = function onSubmit(data) {
5071
5389
  // eslint-disable-next-line no-console
5072
5390
  console.log('submit:', convertTafValuesToObject(data));
@@ -5120,7 +5438,7 @@ var TafForm = /*#__PURE__*/React.memo(function (_ref) {
5120
5438
  tafToReset = originalTaf;
5121
5439
  }
5122
5440
  var shouldAddEmptyChangGroup = !resetDisabled;
5123
- var newTaf = prepareTafValues(tafToReset, action, shouldAddEmptyChangGroup);
5441
+ var newTaf = prepareTafValues(tafToReset, action, shouldAddEmptyChangGroup, shouldEnableRemark);
5124
5442
  resetFormValues(newTaf);
5125
5443
  setIsDisabled(resetDisabled);
5126
5444
  setTafAction(action);
@@ -5273,7 +5591,7 @@ var TafForm = /*#__PURE__*/React.memo(function (_ref) {
5273
5591
  while (1) switch (_context7.prev = _context7.next) {
5274
5592
  case 0:
5275
5593
  _context7.next = 2;
5276
- return onFormAction(action, convertTafValuesToObject(prepareTafValues(originalTaf, action)));
5594
+ return onFormAction(action, convertTafValuesToObject(prepareTafValues(originalTaf, action, false, shouldEnableRemark)));
5277
5595
  case 2:
5278
5596
  case "end":
5279
5597
  return _context7.stop();
@@ -5404,7 +5722,9 @@ var TafForm = /*#__PURE__*/React.memo(function (_ref) {
5404
5722
  // eslint-disable-next-line react-hooks/exhaustive-deps
5405
5723
  }, []);
5406
5724
  React.useEffect(function () {
5407
- var newValues = prepareTafValues(originalTaf, undefined, !isDefaultDisabled);
5725
+ var newValues = prepareTafValues(originalTaf, undefined, !isDefaultDisabled,
5726
+ // Only add empty changegroup rows if not yet published
5727
+ shouldEnableRemark);
5408
5728
  // set new form values when taf values changed
5409
5729
  resetFormValues(newValues);
5410
5730
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -5501,7 +5821,10 @@ var TafForm = /*#__PURE__*/React.memo(function (_ref) {
5501
5821
  onRemoveChangeGroup: onRemoverow
5502
5822
  }, item.id);
5503
5823
  })
5504
- }), !isDisabled && isEditor ? jsx(Grid, {
5824
+ }), shouldEnableRemark ? jsx(TafRemarkField, {
5825
+ disabled: isDisabled,
5826
+ isEditor: isEditor
5827
+ }) : null, !isDisabled && isEditor ? jsx(Grid, {
5505
5828
  container: true,
5506
5829
  sx: {
5507
5830
  justifyContent: 'space-between',
@@ -5759,97 +6082,9 @@ var AdverseWeatherTACMessage = function AdverseWeatherTACMessage(_ref) {
5759
6082
  });
5760
6083
  };
5761
6084
 
5762
- var TafConfigContext = /*#__PURE__*/React.createContext({
5763
- tafConfig: null
5764
- });
5765
- var useTafConfigContext = function useTafConfigContext() {
5766
- return React.useContext(TafConfigContext);
5767
- };
5768
- var TafConfigWrapper = function TafConfigWrapper(_ref) {
5769
- var children = _ref.children;
5770
- var _useTafTranslation = useTafTranslation(),
5771
- t = _useTafTranslation.t;
5772
- var _React$useState = React.useState(null),
5773
- errorMessage = _React$useState[0],
5774
- setErrorMessage = _React$useState[1];
5775
- var ERROR_CONFIG = t('error-config');
5776
- var ERROR_CONFIG_MESSAGE = t('error-config-message');
5777
- var _useAuthenticationCon = useAuthenticationContext$1(),
5778
- isLoggedIn = _useAuthenticationCon.isLoggedIn;
5779
- var ERROR_AUTH = t('error-auth');
5780
- var ERROR_AUTH_MESSAGE = t('error-auth-message');
5781
- var _useTafConfig = useTafConfig(),
5782
- isFetching = _useTafConfig.isFetching,
5783
- tafConfigError = _useTafConfig.error,
5784
- tafConfig = _useTafConfig.data,
5785
- fetchConfig = _useTafConfig.refetch;
5786
- var onFetchConfig = /*#__PURE__*/function () {
5787
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5788
- return _regeneratorRuntime().wrap(function _callee$(_context) {
5789
- while (1) switch (_context.prev = _context.next) {
5790
- case 0:
5791
- _context.next = 2;
5792
- return fetchConfig();
5793
- case 2:
5794
- case "end":
5795
- return _context.stop();
5796
- }
5797
- }, _callee);
5798
- }));
5799
- return function onFetchConfig() {
5800
- return _ref2.apply(this, arguments);
5801
- };
5802
- }();
5803
- React.useEffect(function () {
5804
- if (!isLoggedIn) {
5805
- setErrorMessage({
5806
- title: ERROR_AUTH,
5807
- info: ERROR_AUTH_MESSAGE
5808
- });
5809
- } else if (tafConfigError) {
5810
- setErrorMessage({
5811
- title: ERROR_CONFIG,
5812
- info: tafConfigError.message
5813
- });
5814
- } else {
5815
- setErrorMessage(null);
5816
- }
5817
- }, [t, isLoggedIn, tafConfigError, ERROR_CONFIG, ERROR_AUTH, ERROR_AUTH_MESSAGE]);
5818
- var contextValue = React.useMemo(function () {
5819
- return {
5820
- tafConfig: tafConfig
5821
- };
5822
- }, [tafConfig]);
5823
- if (isLoggedIn && isFetching) {
5824
- return jsx(LinearProgress, {
5825
- color: "secondary",
5826
- "data-testid": "tafconfig-loading-bar",
5827
- sx: {
5828
- marginBottom: '-4px'
5829
- }
5830
- });
5831
- }
5832
- if (errorMessage || !tafConfig) {
5833
- return jsx(AlertBanner, {
5834
- actionButtonProps: !errorMessage || errorMessage.title !== ERROR_AUTH ? {
5835
- title: t('error-title-retry'),
5836
- onClick: onFetchConfig
5837
- } : undefined,
5838
- "data-testid": "error-message",
5839
- info: errorMessage ? errorMessage.info : ERROR_CONFIG_MESSAGE,
5840
- severity: "error",
5841
- title: errorMessage ? errorMessage.title : ERROR_CONFIG
5842
- });
5843
- }
5844
- return jsx(TafConfigContext.Provider, {
5845
- value: contextValue,
5846
- children: children
5847
- });
5848
- };
5849
-
5850
- var ExportButton = function ExportButton(_ref) {
5851
- var onClick = _ref.onClick,
5852
- isHidden = _ref.isHidden;
6085
+ var ExportButton = function ExportButton(_ref) {
6086
+ var onClick = _ref.onClick,
6087
+ isHidden = _ref.isHidden;
5853
6088
  var _useTafTranslation = useTafTranslation(),
5854
6089
  t = _useTafTranslation.t;
5855
6090
  return isHidden ? null : jsx(CustomIconButton, {
@@ -5914,7 +6149,7 @@ var TacContainer = function TacContainer(_ref2) {
5914
6149
  }, [dispatch]);
5915
6150
  var handleExport = function handleExport() {
5916
6151
  var currentTaf = getValues();
5917
- var newTaf = prepareTafExportValues(taf, currentTaf);
6152
+ var newTaf = prepareTafExportValues(taf, currentTaf, tafConfig == null ? void 0 : tafConfig.shouldEnableRemark);
5918
6153
  reset(newTaf, {
5919
6154
  keepDefaultValues: true,
5920
6155
  keepValues: false,
@@ -6447,7 +6682,9 @@ var TafPanel = function TafPanel(_ref) {
6447
6682
  error = _ref.error,
6448
6683
  _ref$previousTaf = _ref.previousTaf,
6449
6684
  previousTaf = _ref$previousTaf === void 0 ? null : _ref$previousTaf,
6450
- tafAction = _ref.tafAction;
6685
+ tafAction = _ref.tafAction,
6686
+ _ref$shouldEnableRema = _ref.shouldEnableRemark,
6687
+ shouldEnableRemark = _ref$shouldEnableRema === void 0 ? false : _ref$shouldEnableRema;
6451
6688
  var _useTafTranslation = useTafTranslation(),
6452
6689
  t = _useTafTranslation.t;
6453
6690
  var severity = isWarning(error) ? 'warning' : 'error';
@@ -6525,6 +6762,7 @@ var TafPanel = function TafPanel(_ref) {
6525
6762
  previousTaf: previousTaf,
6526
6763
  setIsDisabled: setIsFormDisabled,
6527
6764
  setIsIssuesPaneOpen: setIsIssuesPaneOpen,
6765
+ shouldEnableRemark: shouldEnableRemark,
6528
6766
  tafFromBackend: tafFromBackend
6529
6767
  })
6530
6768
  })]
@@ -6533,28 +6771,19 @@ var TafPanel = function TafPanel(_ref) {
6533
6771
 
6534
6772
  var TopTabs = function TopTabs(_ref) {
6535
6773
  var timeSlot = _ref.timeSlot,
6774
+ tafFromBackend = _ref.tafFromBackend,
6536
6775
  _ref$onChangeTimeSlot = _ref.onChangeTimeSlot,
6537
- onChangeTimeSlot = _ref$onChangeTimeSlot === void 0 ? function () {} : _ref$onChangeTimeSlot,
6538
- _ref$tafFromBackend = _ref.tafFromBackend,
6539
- tafFromBackend = _ref$tafFromBackend === void 0 ? {
6540
- taf: {
6541
- baseTime: '2022-01-06T12:00:00Z',
6542
- location: 'EHAM'
6543
- }
6544
- } : _ref$tafFromBackend;
6776
+ onChangeTimeSlot = _ref$onChangeTimeSlot === void 0 ? function () {} : _ref$onChangeTimeSlot;
6545
6777
  var _useTafTranslation = useTafTranslation(),
6546
6778
  t = _useTafTranslation.t;
6547
6779
  var _useFormContext = useFormContext(),
6548
6780
  isDirty = _useFormContext.formState.isDirty;
6549
6781
  var _useTafConfigContext = useTafConfigContext(),
6550
6782
  tafConfig = _useTafConfigContext.tafConfig;
6551
- if (!tafFromBackend) {
6552
- return null;
6553
- }
6554
6783
  var activeTab = timeSlot === 'UPCOMING' ? 0 : 1;
6555
- var _getBaseTime = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location, tafConfig),
6556
- currentBaseTime = _getBaseTime.currentBaseTime,
6557
- nextBaseTime = _getBaseTime.nextBaseTime;
6784
+ var _ref2 = tafFromBackend ? getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location, tafConfig) : calculateBaseTime(tafConfig),
6785
+ currentBaseTime = _ref2.currentBaseTime,
6786
+ nextBaseTime = _ref2.nextBaseTime;
6558
6787
  var tabs = [{
6559
6788
  title: t('top-tabs-upcoming') + " " + formatBaseTime(nextBaseTime),
6560
6789
  timeSlot: 'UPCOMING'
@@ -6650,8 +6879,7 @@ var TafLayout = function TafLayout(_ref) {
6650
6879
  current = _React$useState$.current,
6651
6880
  expired = _React$useState$.expired,
6652
6881
  updateSortedTafs = _React$useState[1];
6653
- var _current$slice = current.slice(-1),
6654
- lastCurrentTaf = _current$slice[0];
6882
+ var lastCurrentTaf = current.length > 0 ? current[current.length - 1] : undefined;
6655
6883
  var _React$useState2 = React.useState('UPCOMING'),
6656
6884
  timeSlot = _React$useState2[0],
6657
6885
  setTimeSlot = _React$useState2[1];
@@ -6824,7 +7052,7 @@ var TafLayout = function TafLayout(_ref) {
6824
7052
  // eslint-disable-next-line react-hooks/exhaustive-deps
6825
7053
  }, [tafList, setLocations]);
6826
7054
  React.useEffect(function () {
6827
- var cancelErrorTimeout = error && error.type === 'CANCELLED' ? setTimeout(function () {
7055
+ var cancelErrorTimeout = (error == null ? void 0 : error.type) === 'CANCELLED' ? setTimeout(function () {
6828
7056
  setError(null);
6829
7057
  }, 10000) : null;
6830
7058
  return function () {
@@ -6889,94 +7117,94 @@ var TafLayout = function TafLayout(_ref) {
6889
7117
  onPressRefresh: onUpdateTaf
6890
7118
  }) : null
6891
7119
  })]
6892
- }), jsx(Grid, {
7120
+ }), jsxs(Grid, {
6893
7121
  container: true,
7122
+ spacing: 2,
6894
7123
  sx: {
6895
- flexGrow: 1,
6896
- overflow: 'hidden'
7124
+ height: '100%',
7125
+ paddingLeft: 1,
7126
+ paddingRight: 1,
7127
+ paddingTop: 2,
7128
+ overflow: 'auto'
6897
7129
  },
6898
- children: jsxs(Grid, {
6899
- container: true,
6900
- spacing: 2,
6901
- sx: {
6902
- height: '100%',
6903
- paddingLeft: 1,
6904
- paddingRight: 1,
6905
- paddingTop: 2,
6906
- overflow: 'auto'
7130
+ children: [jsx(Grid, {
7131
+ size: {
7132
+ xs: 3,
7133
+ sm: 1
6907
7134
  },
6908
- children: [jsx(Grid, {
6909
- size: {
6910
- xs: 3,
6911
- sm: 1
6912
- },
6913
- children: jsx(LocationTabs, {
6914
- activeIndex: activeTafIndex,
6915
- onChangeTab: onChangeLocationTab,
6916
- tafList: locations,
6917
- timeSlot: timeSlot
6918
- })
6919
- }), jsx(Grid, {
6920
- size: "grow",
6921
- children: jsxs(Card, {
6922
- sx: {
6923
- marginBottom: '12px',
6924
- position: 'relative',
6925
- minHeight: locations.length * 62 + 32
6926
- },
6927
- variant: "outlined",
6928
- children: [jsx(TacOverviewMobile, Object.assign({
6929
- activeTaf: activeTaf,
6930
- currentTafs: current,
6931
- expiredTafs: expired,
6932
- upcomingTafs: upcoming
6933
- }, isAutoTafEnabled && {
6934
- autoTafs: autoTafList
6935
- })), locations.map(function (tafFromBackend, index) {
6936
- return jsx(TafPanel, {
6937
- activeTafIndex: activeTafIndex,
6938
- error: error,
6939
- index: index,
6940
- isFormDisabled: isFormDisabled,
6941
- isIssuesPaneOpen: isIssuesPaneOpen,
6942
- isLoading: isPostTafPending,
6943
- patchTaf: patchTaf,
6944
- postTaf: postTaf,
6945
- previousTaf: getPreviousTaf(tafList, tafFromBackend),
6946
- setIsFormDisabled: setIsFormDisabled,
6947
- setIsIssuesPaneOpen: onToggleIssuesPane,
6948
- tafAction: tafAction,
6949
- tafFromBackend: tafFromBackend
6950
- }, tafFromBackend.taf.uuid);
6951
- })]
6952
- })
6953
- }), jsxs(Grid, {
6954
- size: {
6955
- xs: 0,
6956
- sm: 3
7135
+ children: jsx(LocationTabs, {
7136
+ activeIndex: activeTafIndex,
7137
+ onChangeTab: onChangeLocationTab,
7138
+ tafList: locations,
7139
+ timeSlot: timeSlot
7140
+ })
7141
+ }), jsx(Grid, {
7142
+ size: "grow",
7143
+ children: jsxs(Card, {
7144
+ sx: {
7145
+ marginBottom: '12px',
7146
+ position: 'relative',
7147
+ minHeight: locations.length * 62 + 32
6957
7148
  },
6958
- sx: Object.assign({
6959
- height: {
6960
- xs: 0,
6961
- sm: '100%'
6962
- }
6963
- }, isAutoTafEnabled && {
6964
- display: 'flex',
6965
- flexDirection: 'column'
6966
- }),
6967
- children: [jsx(TacOverview, {
7149
+ variant: "outlined",
7150
+ children: [jsx(TacOverviewMobile, Object.assign({
6968
7151
  activeTaf: activeTaf,
6969
7152
  currentTafs: current,
6970
7153
  expiredTafs: expired,
6971
- isFormDisabled: isFormDisabled,
6972
7154
  upcomingTafs: upcoming
6973
- }), isAutoTafEnabled ? jsx(AutoTaf, {
6974
- activeTaf: activeTaf,
6975
- isFormDisabled: isFormDisabled,
6976
- tafList: autoTafList
6977
- }) : null]
6978
- })]
6979
- })
7155
+ }, isAutoTafEnabled && {
7156
+ autoTafs: autoTafList
7157
+ })), locations.length > 0 ? locations.map(function (tafFromBackend, index) {
7158
+ return jsx(TafPanel, {
7159
+ activeTafIndex: activeTafIndex,
7160
+ error: error,
7161
+ index: index,
7162
+ isFormDisabled: isFormDisabled,
7163
+ isIssuesPaneOpen: isIssuesPaneOpen,
7164
+ isLoading: isPostTafPending,
7165
+ patchTaf: patchTaf,
7166
+ postTaf: postTaf,
7167
+ previousTaf: getPreviousTaf(tafList, tafFromBackend),
7168
+ setIsFormDisabled: setIsFormDisabled,
7169
+ setIsIssuesPaneOpen: onToggleIssuesPane,
7170
+ shouldEnableRemark: tafConfig == null ? void 0 : tafConfig.shouldEnableRemark,
7171
+ tafAction: tafAction,
7172
+ tafFromBackend: tafFromBackend
7173
+ }, tafFromBackend.taf.uuid);
7174
+ }) : jsx(Typography, {
7175
+ sx: {
7176
+ margin: 1
7177
+ },
7178
+ variant: "body1",
7179
+ children: t('no-locations-message')
7180
+ })]
7181
+ })
7182
+ }), jsxs(Grid, {
7183
+ size: {
7184
+ xs: 0,
7185
+ sm: 3
7186
+ },
7187
+ sx: Object.assign({
7188
+ height: {
7189
+ xs: 0,
7190
+ sm: '100%'
7191
+ }
7192
+ }, isAutoTafEnabled && {
7193
+ display: 'flex',
7194
+ flexDirection: 'column'
7195
+ }),
7196
+ children: [jsx(TacOverview, {
7197
+ activeTaf: activeTaf,
7198
+ currentTafs: current,
7199
+ expiredTafs: expired,
7200
+ isFormDisabled: isFormDisabled,
7201
+ upcomingTafs: upcoming
7202
+ }), isAutoTafEnabled ? jsx(AutoTaf, {
7203
+ activeTaf: activeTaf,
7204
+ isFormDisabled: isFormDisabled,
7205
+ tafList: autoTafList
7206
+ }) : null]
7207
+ })]
6980
7208
  })]
6981
7209
  })
6982
7210
  }), jsx(IssuesPaneWrapper, {
@@ -7011,6 +7239,7 @@ var TafWrapper = function TafWrapper(_ref) {
7011
7239
  uuid: '',
7012
7240
  issueDate: '',
7013
7241
  status: '',
7242
+ type: 'TAF',
7014
7243
  IS_DRAFT: false
7015
7244
  }
7016
7245
  },
@@ -7020,15 +7249,16 @@ var TafWrapper = function TafWrapper(_ref) {
7020
7249
  });
7021
7250
  };
7022
7251
 
7023
- var _excluded = ["isAutoTafEnabled"];
7252
+ var _excluded = ["isAutoTafEnabled", "type"];
7024
7253
  var TafModule = function TafModule(_ref) {
7025
- var isAutoTafEnabled = _ref.isAutoTafEnabled;
7254
+ var isAutoTafEnabled = _ref.isAutoTafEnabled,
7255
+ type = _ref.type;
7026
7256
  var _useTafTranslation = useTafTranslation(),
7027
7257
  t = _useTafTranslation.t;
7028
7258
  var _useState = useState(null),
7029
7259
  errorMessage = _useState[0],
7030
7260
  setErrorMessage = _useState[1];
7031
- var _useTafList = useTafList(),
7261
+ var _useTafList = useTafList(type),
7032
7262
  isFetching = _useTafList.isFetching,
7033
7263
  tafListError = _useTafList.error,
7034
7264
  tafList = _useTafList.data,
@@ -7097,11 +7327,15 @@ var TafModule = function TafModule(_ref) {
7097
7327
  var Wrapper = function Wrapper(_ref3) {
7098
7328
  var _ref3$isAutoTafEnable = _ref3.isAutoTafEnabled,
7099
7329
  isAutoTafEnabled = _ref3$isAutoTafEnable === void 0 ? false : _ref3$isAutoTafEnable,
7330
+ _ref3$type = _ref3.type,
7331
+ type = _ref3$type === void 0 ? 'TAF' : _ref3$type,
7100
7332
  props = _objectWithoutPropertiesLoose(_ref3, _excluded);
7101
7333
  return jsx(TafWrapper, Object.assign({}, props, {
7102
7334
  children: jsx(TafConfigWrapper, {
7335
+ type: type,
7103
7336
  children: jsx(TafModule, {
7104
- isAutoTafEnabled: isAutoTafEnabled
7337
+ isAutoTafEnabled: isAutoTafEnabled,
7338
+ type: type
7105
7339
  })
7106
7340
  })
7107
7341
  }));
@@ -7130,7 +7364,8 @@ var TafApiWrapper = function TafApiWrapper(_ref) {
7130
7364
  return config ? jsx(ErrorBoundary, {
7131
7365
  children: jsx(Wrapper, {
7132
7366
  isAutoTafEnabled: initialProps == null ? void 0 : initialProps.isAutoTafEnabled,
7133
- onPreventCloseView: onPreventCloseView
7367
+ onPreventCloseView: onPreventCloseView,
7368
+ type: initialProps == null ? void 0 : initialProps.type
7134
7369
  })
7135
7370
  }) : null;
7136
7371
  };
@@ -7174,9 +7409,94 @@ ConnectedModuleWrapper) {
7174
7409
  }
7175
7410
  };
7176
7411
 
7412
+ var fakeTafConfig = {
7413
+ type: 'TAF',
7414
+ location_indicator_mwo: 'EHDB',
7415
+ locations: {
7416
+ EHAM: {
7417
+ validity_duration: 30,
7418
+ activity_period: 6,
7419
+ label: 'Schiphol'
7420
+ },
7421
+ EHRD: {
7422
+ validity_duration: 30,
7423
+ activity_period: 6,
7424
+ label: 'Rotterdam'
7425
+ },
7426
+ EHGG: {
7427
+ validity_duration: 30,
7428
+ activity_period: 6,
7429
+ label: 'Eelde'
7430
+ },
7431
+ EHBK: {
7432
+ validity_duration: 30,
7433
+ activity_period: 6,
7434
+ label: 'Maastricht'
7435
+ },
7436
+ EHLE: {
7437
+ validity_duration: 30,
7438
+ activity_period: 6,
7439
+ label: 'Lelystad'
7440
+ },
7441
+ TNCB: {
7442
+ validity_duration: 30,
7443
+ activity_period: 6,
7444
+ label: 'Bonaire'
7445
+ },
7446
+ EHAK: {
7447
+ validity_duration: 30,
7448
+ activity_period: 6,
7449
+ label: 'Akureyri'
7450
+ },
7451
+ EHFD: {
7452
+ validity_duration: 30,
7453
+ activity_period: 6,
7454
+ label: 'Farnborough'
7455
+ },
7456
+ EHDV: {
7457
+ validity_duration: 30,
7458
+ activity_period: 6,
7459
+ label: 'De Vries'
7460
+ },
7461
+ EHHW: {
7462
+ validity_duration: 30,
7463
+ activity_period: 6,
7464
+ label: 'Holland'
7465
+ },
7466
+ EHKV: {
7467
+ validity_duration: 30,
7468
+ activity_period: 6,
7469
+ label: 'Kavala'
7470
+ },
7471
+ EHMG: {
7472
+ validity_duration: 30,
7473
+ activity_period: 6,
7474
+ label: 'München'
7475
+ },
7476
+ EHMA: {
7477
+ validity_duration: 30,
7478
+ activity_period: 6,
7479
+ label: 'Maastricht'
7480
+ },
7481
+ EHPG: {
7482
+ validity_duration: 30,
7483
+ activity_period: 6,
7484
+ label: 'Petersburg'
7485
+ },
7486
+ EHQN: {
7487
+ validity_duration: 30,
7488
+ activity_period: 6,
7489
+ label: 'Queenstown'
7490
+ }
7491
+ },
7492
+ locationOrder: ['EHAM', 'EHRD', 'EHLE', 'EHGG', 'EHBK', 'TNCB', 'EHAK', 'EHFD', 'EHDV', 'EHHW', 'EHKV', 'EHMG', 'EHMA', 'EHPG', 'EHQN'],
7493
+ autoTAFlocations: ['EHAM', 'EHRD', 'EHLE', 'EHGG', 'EHBK'],
7494
+ shouldEnableRemark: false
7495
+ };
7496
+
7177
7497
  // Used to mimic an authenticated user
7178
- var MOCK_USERNAME = 'user.name';
7179
- var currentDate = dateUtils.dateToString(dateUtils.utc(), dateUtils.DATE_FORMAT_YEAR);
7498
+ var MOCK_USERNAME$1 = 'user.name';
7499
+ var currentDate$1 = dateUtils.dateToString(dateUtils.utc(), dateUtils.DATE_FORMAT_YEAR);
7180
7500
  var tomorrowDate = dateUtils.dateToString(dateUtils.add(dateUtils.utc(), {
7181
7501
  days: 1
7182
7502
  }), dateUtils.DATE_FORMAT_YEAR);
@@ -7195,7 +7515,7 @@ var validDateRange = function validDateRange(refHour, period) {
7195
7515
  });
7196
7516
  return [dateUtils.dateToString(start, dateUtils.DATE_FORMAT_UTC, false), dateUtils.dateToString(end, dateUtils.DATE_FORMAT_UTC, false)];
7197
7517
  };
7198
- var dateAdd = function dateAdd(refDateAsString, hours) {
7518
+ var dateAdd$1 = function dateAdd(refDateAsString, hours) {
7199
7519
  var newDate = dateUtils.add(dateUtils.utc(refDateAsString), {
7200
7520
  hours: hours
7201
7521
  });
@@ -7218,7 +7538,7 @@ var _validDateRange3 = validDateRange(dateUtils.sub(dateUtils.utc(), {
7218
7538
  var fakeTafList = [{
7219
7539
  creationDate: upcomingValidDateStart,
7220
7540
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7221
- editor: MOCK_USERNAME,
7541
+ editor: MOCK_USERNAME$1,
7222
7542
  taf: {
7223
7543
  uuid: '5f9583fjdf0f337925',
7224
7544
  baseTime: upcomingValidDateStart,
@@ -7302,8 +7622,8 @@ var fakeTafList = [{
7302
7622
  change: 'TEMPO',
7303
7623
  probability: 'PROB30',
7304
7624
  valid: {
7305
- start: dateAdd(upcomingValidDateStart, 3),
7306
- end: dateAdd(upcomingValidDateStart, 4)
7625
+ start: dateAdd$1(upcomingValidDateStart, 3),
7626
+ end: dateAdd$1(upcomingValidDateStart, 4)
7307
7627
  },
7308
7628
  visibility: {
7309
7629
  range: 100,
@@ -7319,12 +7639,12 @@ var fakeTafList = [{
7319
7639
  }, {
7320
7640
  creationDate: upcomingValidDateStart,
7321
7641
  canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
7322
- editor: MOCK_USERNAME,
7642
+ editor: MOCK_USERNAME$1,
7323
7643
  taf: {
7324
7644
  uuid: '43545345345',
7325
7645
  issueDate: upcomingValidDateStart,
7326
- baseTime: currentDate + "T18:00:00Z",
7327
- validDateStart: currentDate + "T18:00:00Z",
7646
+ baseTime: currentDate$1 + "T18:00:00Z",
7647
+ validDateStart: currentDate$1 + "T18:00:00Z",
7328
7648
  validDateEnd: upcomingValidDateEnd,
7329
7649
  previousId: 'jkdjkdfjkgdf',
7330
7650
  previousValidDateStart: upcomingValidDateStart,
@@ -7348,8 +7668,8 @@ var fakeTafList = [{
7348
7668
  changeGroups: [{
7349
7669
  change: 'BECMG',
7350
7670
  valid: {
7351
- start: dateAdd(upcomingValidDateStart, 1),
7352
- end: dateAdd(upcomingValidDateStart, 2)
7671
+ start: dateAdd$1(upcomingValidDateStart, 1),
7672
+ end: dateAdd$1(upcomingValidDateStart, 2)
7353
7673
  },
7354
7674
  visibility: {
7355
7675
  range: 1000,
@@ -7364,7 +7684,7 @@ var fakeTafList = [{
7364
7684
  }, {
7365
7685
  change: 'FM',
7366
7686
  valid: {
7367
- start: dateAdd(upcomingValidDateStart, 2)
7687
+ start: dateAdd$1(upcomingValidDateStart, 2)
7368
7688
  },
7369
7689
  visibility: {
7370
7690
  range: 6000,
@@ -7427,8 +7747,8 @@ var fakeTafList = [{
7427
7747
  change: 'TEMPO',
7428
7748
  probability: 'PROB30',
7429
7749
  valid: {
7430
- start: dateAdd(upcomingValidDateStart, 1),
7431
- end: dateAdd(upcomingValidDateStart, 2)
7750
+ start: dateAdd$1(upcomingValidDateStart, 1),
7751
+ end: dateAdd$1(upcomingValidDateStart, 2)
7432
7752
  },
7433
7753
  visibility: {
7434
7754
  range: 200,
@@ -7489,7 +7809,7 @@ var fakeTafList = [{
7489
7809
  taf: {
7490
7810
  uuid: 'gh56734fghfgh',
7491
7811
  previousId: '8574jnf93475',
7492
- issueDate: currentDate + "T16:16:00Z",
7812
+ issueDate: currentDate$1 + "T16:16:00Z",
7493
7813
  baseTime: upcomingValidDateStart,
7494
7814
  validDateStart: upcomingValidDateStart,
7495
7815
  validDateEnd: upcomingValidDateEnd,
@@ -7500,7 +7820,7 @@ var fakeTafList = [{
7500
7820
  messageType: 'AMD',
7501
7821
  baseForecast: {
7502
7822
  valid: {
7503
- start: currentDate + "T16:12:00Z",
7823
+ start: currentDate$1 + "T16:12:00Z",
7504
7824
  end: upcomingValidDateEnd
7505
7825
  },
7506
7826
  visibility: {
@@ -7602,7 +7922,7 @@ var fakeTafList = [{
7602
7922
  }
7603
7923
  }
7604
7924
  }, {
7605
- creationDate: currentDate + "T06:00:00Z",
7925
+ creationDate: currentDate$1 + "T06:00:00Z",
7606
7926
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7607
7927
  editor: null,
7608
7928
  taf: {
@@ -7622,7 +7942,7 @@ var fakeTafList = [{
7622
7942
  }
7623
7943
  }
7624
7944
  }, {
7625
- creationDate: currentDate + "T06:00:00Z",
7945
+ creationDate: currentDate$1 + "T06:00:00Z",
7626
7946
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7627
7947
  editor: null,
7628
7948
  taf: {
@@ -7642,7 +7962,7 @@ var fakeTafList = [{
7642
7962
  }
7643
7963
  }
7644
7964
  }, {
7645
- creationDate: currentDate + "T06:00:00Z",
7965
+ creationDate: currentDate$1 + "T06:00:00Z",
7646
7966
  canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
7647
7967
  editor: null,
7648
7968
  taf: {
@@ -7689,8 +8009,8 @@ var fakeTafList = [{
7689
8009
  changeGroups: [{
7690
8010
  change: 'BECMG',
7691
8011
  valid: {
7692
- start: dateAdd(expiredValidDateStart, 1),
7693
- end: dateAdd(expiredValidDateStart, 4)
8012
+ start: dateAdd$1(expiredValidDateStart, 1),
8013
+ end: dateAdd$1(expiredValidDateStart, 4)
7694
8014
  },
7695
8015
  visibility: {
7696
8016
  range: 1000,
@@ -7702,7 +8022,7 @@ var fakeTafList = [{
7702
8022
  }, {
7703
8023
  change: 'FM',
7704
8024
  valid: {
7705
- start: dateAdd(expiredValidDateStart, 5)
8025
+ start: dateAdd$1(expiredValidDateStart, 5)
7706
8026
  },
7707
8027
  visibility: {
7708
8028
  range: 6000,
@@ -7810,8 +8130,8 @@ var fakeTafList = [{
7810
8130
  change: 'TEMPO',
7811
8131
  probability: 'PROB30',
7812
8132
  valid: {
7813
- start: dateAdd(upcomingValidDateStart, 3),
7814
- end: dateAdd(upcomingValidDateStart, 4)
8133
+ start: dateAdd$1(upcomingValidDateStart, 3),
8134
+ end: dateAdd$1(upcomingValidDateStart, 4)
7815
8135
  },
7816
8136
  visibility: {
7817
8137
  range: 100,
@@ -7831,8 +8151,8 @@ var fakeTafList = [{
7831
8151
  taf: {
7832
8152
  uuid: '4354545345345',
7833
8153
  issueDate: upcomingValidDateStart,
7834
- baseTime: currentDate + "T18:00:00Z",
7835
- validDateStart: currentDate + "T18:00:00Z",
8154
+ baseTime: currentDate$1 + "T18:00:00Z",
8155
+ validDateStart: currentDate$1 + "T18:00:00Z",
7836
8156
  validDateEnd: upcomingValidDateEnd,
7837
8157
  location: 'EHLE',
7838
8158
  status: 'AUTO',
@@ -7853,8 +8173,8 @@ var fakeTafList = [{
7853
8173
  changeGroups: [{
7854
8174
  change: 'BECMG',
7855
8175
  valid: {
7856
- start: dateAdd(upcomingValidDateStart, 1),
7857
- end: dateAdd(upcomingValidDateStart, 2)
8176
+ start: dateAdd$1(upcomingValidDateStart, 1),
8177
+ end: dateAdd$1(upcomingValidDateStart, 2)
7858
8178
  },
7859
8179
  visibility: {
7860
8180
  range: 1000,
@@ -7869,7 +8189,7 @@ var fakeTafList = [{
7869
8189
  }, {
7870
8190
  change: 'FM',
7871
8191
  valid: {
7872
- start: dateAdd(upcomingValidDateStart, 2)
8192
+ start: dateAdd$1(upcomingValidDateStart, 2)
7873
8193
  },
7874
8194
  visibility: {
7875
8195
  range: 6000,
@@ -7932,8 +8252,8 @@ var fakeTafList = [{
7932
8252
  change: 'TEMPO',
7933
8253
  probability: 'PROB30',
7934
8254
  valid: {
7935
- start: dateAdd(upcomingValidDateStart, 1),
7936
- end: dateAdd(upcomingValidDateStart, 2)
8255
+ start: dateAdd$1(upcomingValidDateStart, 1),
8256
+ end: dateAdd$1(upcomingValidDateStart, 2)
7937
8257
  },
7938
8258
  visibility: {
7939
8259
  range: 200,
@@ -7952,13 +8272,13 @@ var fakeNewTaf = {
7952
8272
  messageType: 'ORG',
7953
8273
  status: 'NEW',
7954
8274
  uuid: '5f9583fjdf0445332f337925',
7955
- baseTime: currentDate + "T12:00:00Z",
7956
- validDateStart: currentDate + "T12:00:00Z",
8275
+ baseTime: currentDate$1 + "T12:00:00Z",
8276
+ validDateStart: currentDate$1 + "T12:00:00Z",
7957
8277
  validDateEnd: tomorrowDate + "T18:00:00Z",
7958
8278
  location: 'EHBK',
7959
8279
  baseForecast: {
7960
8280
  valid: {
7961
- start: currentDate + "T12:00:00Z",
8281
+ start: currentDate$1 + "T12:00:00Z",
7962
8282
  end: tomorrowDate + "T18:00:00Z"
7963
8283
  }
7964
8284
  }
@@ -7980,16 +8300,16 @@ var fakeNewTaf = {
7980
8300
  var fakePublishedTaf = {
7981
8301
  taf: {
7982
8302
  uuid: 'slsdkjg-023895',
7983
- issueDate: currentDate + "T12:00:00Z",
7984
- baseTime: currentDate + "T12:00:00Z",
7985
- validDateStart: currentDate + "T12:00:00Z",
8303
+ issueDate: currentDate$1 + "T12:00:00Z",
8304
+ baseTime: currentDate$1 + "T12:00:00Z",
8305
+ validDateStart: currentDate$1 + "T12:00:00Z",
7986
8306
  validDateEnd: tomorrowDate + "T18:00:00Z",
7987
8307
  location: 'EHLE',
7988
8308
  status: 'PUBLISHED',
7989
8309
  messageType: 'ORG',
7990
8310
  baseForecast: {
7991
8311
  valid: {
7992
- start: currentDate + "T12:00:00Z",
8312
+ start: currentDate$1 + "T12:00:00Z",
7993
8313
  end: tomorrowDate + "T18:00:00Z"
7994
8314
  },
7995
8315
  wind: {
@@ -8002,7 +8322,7 @@ var fakePublishedTaf = {
8002
8322
  changeGroups: [{
8003
8323
  change: 'FM',
8004
8324
  valid: {
8005
- start: currentDate + "T12:00:00Z"
8325
+ start: currentDate$1 + "T12:00:00Z"
8006
8326
  },
8007
8327
  visibility: {
8008
8328
  range: 6000,
@@ -8031,7 +8351,7 @@ var fakePublishedTaf = {
8031
8351
  }, {
8032
8352
  change: 'BECMG',
8033
8353
  valid: {
8034
- start: currentDate + "T23:00:00Z",
8354
+ start: currentDate$1 + "T23:00:00Z",
8035
8355
  end: tomorrowDate + "T01:00:00Z"
8036
8356
  },
8037
8357
  wind: {
@@ -8116,15 +8436,15 @@ var fakePublishedTaf = {
8116
8436
  var fakeDraftTaf = {
8117
8437
  taf: {
8118
8438
  uuid: '5f9583fjdf0f337925',
8119
- baseTime: currentDate + "T18:00:00Z",
8120
- validDateStart: currentDate + "T18:00:00Z",
8439
+ baseTime: currentDate$1 + "T18:00:00Z",
8440
+ validDateStart: currentDate$1 + "T18:00:00Z",
8121
8441
  validDateEnd: tomorrowDate + "T23:59:00Z",
8122
8442
  location: 'EHLE',
8123
8443
  status: 'DRAFT',
8124
8444
  messageType: 'ORG',
8125
8445
  baseForecast: {
8126
8446
  valid: {
8127
- start: currentDate + "T18:00:00Z",
8447
+ start: currentDate$1 + "T18:00:00Z",
8128
8448
  end: tomorrowDate + "T23:59:00Z"
8129
8449
  },
8130
8450
  wind: {
@@ -8165,17 +8485,17 @@ var fakeDraftAmendmentTaf = {
8165
8485
  taf: {
8166
8486
  uuid: '954905487',
8167
8487
  previousId: '5f9583fjdf45ff4330f337925',
8168
- baseTime: currentDate + "T12:00:00Z",
8169
- validDateStart: currentDate + "T14:00:00Z",
8488
+ baseTime: currentDate$1 + "T12:00:00Z",
8489
+ validDateStart: currentDate$1 + "T14:00:00Z",
8170
8490
  validDateEnd: tomorrowDate + "T18:00:00Z",
8171
- previousValidDateStart: currentDate + "T12:00:00Z",
8491
+ previousValidDateStart: currentDate$1 + "T12:00:00Z",
8172
8492
  previousValidDateEnd: tomorrowDate + "T18:00:00Z",
8173
8493
  location: 'EHAM',
8174
8494
  status: 'DRAFT_AMENDED',
8175
8495
  messageType: 'AMD',
8176
8496
  baseForecast: {
8177
8497
  valid: {
8178
- start: currentDate + "T14:00:00Z",
8498
+ start: currentDate$1 + "T14:00:00Z",
8179
8499
  end: tomorrowDate + "T18:00:00Z"
8180
8500
  },
8181
8501
  visibility: {
@@ -8201,8 +8521,8 @@ var fakeDraftAmendmentTaf = {
8201
8521
  change: 'TEMPO',
8202
8522
  probability: 'PROB30',
8203
8523
  valid: {
8204
- start: currentDate + "T15:00:00Z",
8205
- end: currentDate + "T16:00:00Z"
8524
+ start: currentDate$1 + "T15:00:00Z",
8525
+ end: currentDate$1 + "T16:00:00Z"
8206
8526
  },
8207
8527
  visibility: {
8208
8528
  range: 100,
@@ -8264,18 +8584,18 @@ var fakeAmendmentTaf = {
8264
8584
  taf: {
8265
8585
  uuid: '754905486',
8266
8586
  previousId: '5f9583fjdf45ff4330f337925',
8267
- issueDate: currentDate + "T14:00:00Z",
8268
- baseTime: currentDate + "T12:00:00Z",
8269
- validDateStart: currentDate + "T14:00:00Z",
8587
+ issueDate: currentDate$1 + "T14:00:00Z",
8588
+ baseTime: currentDate$1 + "T12:00:00Z",
8589
+ validDateStart: currentDate$1 + "T14:00:00Z",
8270
8590
  validDateEnd: tomorrowDate + "T18:00:00Z",
8271
- previousValidDateStart: currentDate + "T12:00:00Z",
8591
+ previousValidDateStart: currentDate$1 + "T12:00:00Z",
8272
8592
  previousValidDateEnd: tomorrowDate + "T18:00:00Z",
8273
8593
  location: 'EHAM',
8274
8594
  status: 'AMENDED',
8275
8595
  messageType: 'AMD',
8276
8596
  baseForecast: {
8277
8597
  valid: {
8278
- start: currentDate + "T14:00:00Z",
8598
+ start: currentDate$1 + "T14:00:00Z",
8279
8599
  end: tomorrowDate + "T18:00:00Z"
8280
8600
  },
8281
8601
  visibility: {
@@ -8318,13 +8638,630 @@ var fakeAmendmentTaf = {
8318
8638
  })
8319
8639
  });
8320
8640
 
8641
+ var fakeNafConfig = {
8642
+ type: 'NAF',
8643
+ location_indicator_mwo: 'EHAK',
8644
+ locations: {
8645
+ EHAK: {
8646
+ valid_durations: [9, 9, 9, 6],
8647
+ valid_start_times: [5, 8, 11, 14],
8648
+ label: 'A12-CPP'
8649
+ },
8650
+ EHFD: {
8651
+ valid_durations: [9, 9, 9, 6],
8652
+ valid_start_times: [5, 8, 11, 14],
8653
+ label: 'F3-FB-1'
8654
+ },
8655
+ EHDV: {
8656
+ valid_durations: [9, 9, 9, 6],
8657
+ valid_start_times: [5, 8, 11, 14],
8658
+ label: 'D15-FA-1'
8659
+ },
8660
+ EHHW: {
8661
+ valid_durations: [9, 9, 9, 6],
8662
+ valid_start_times: [5, 8, 11, 14],
8663
+ label: 'BG-OHVS2'
8664
+ },
8665
+ EHKV: {
8666
+ valid_durations: [9, 9, 9, 6],
8667
+ valid_start_times: [5, 8, 11, 14],
8668
+ label: 'K14-FA-1C'
8669
+ },
8670
+ EHMG: {
8671
+ valid_durations: [9, 9, 9, 6],
8672
+ valid_start_times: [5, 8, 11, 14],
8673
+ label: 'L9-FF-1'
8674
+ },
8675
+ EHMA: {
8676
+ valid_durations: [9, 9, 9, 6],
8677
+ valid_start_times: [5, 8, 11, 14],
8678
+ label: 'AWG-1'
8679
+ },
8680
+ EHQN: {
8681
+ valid_durations: [9, 9, 9, 6],
8682
+ valid_start_times: [5, 8, 11, 14],
8683
+ label: 'HKN'
8684
+ },
8685
+ EHPG: {
8686
+ valid_durations: [9, 9, 9, 6],
8687
+ valid_start_times: [5, 8, 11, 14],
8688
+ label: 'P11-B'
8689
+ }
8690
+ },
8691
+ locationOrder: ['EHAK', 'EHFD', 'EHDV', 'EHHW', 'EHKV', 'EHMG', 'EHMA', 'EHQN', 'EHPG'],
8692
+ autoTAFlocations: ['EHAK', 'EHFD', 'EHDV', 'EHHW', 'EHKV', 'EHMG', 'EHMA', 'EHQN', 'EHPG'],
8693
+ shouldEnableRemark: true
8694
+ };
8695
+
8696
+ /* *
8697
+ * Licensed under the Apache License, Version 2.0 (the "License");
8698
+ * you may not use this file except in compliance with the License.
8699
+ * You may obtain a copy of the License at
8700
+ *
8701
+ * http://www.apache.org/licenses/LICENSE-2.0
8702
+ *
8703
+ * Unless required by applicable law or agreed to in writing, software
8704
+ * distributed under the License is distributed on an "AS IS" BASIS,
8705
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8706
+ * See the License for the specific language governing permissions and
8707
+ * limitations under the License.
8708
+ *
8709
+ * Copyright 2026 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
8710
+ * Copyright 2026 - Finnish Meteorological Institute (FMI)
8711
+ * Copyright 2026 - The Norwegian Meteorological Institute (MET Norway)
8712
+ * */
8713
+ // Used to mimic an authenticated user
8714
+ var MOCK_USERNAME = 'user.name';
8715
+ var now = dateUtils.utc();
8716
+ var currentDate = dateUtils.dateToString(dateUtils.utc(), dateUtils.DATE_FORMAT_YEAR);
8717
+ var dateAdd = function dateAdd(refDateAsString, hours) {
8718
+ var newDate = dateUtils.add(dateUtils.utc(refDateAsString), {
8719
+ hours: hours
8720
+ });
8721
+ var formattedDate = dateUtils.dateToString(newDate, dateUtils.DATE_FORMAT_UTC);
8722
+ return formattedDate;
8723
+ };
8724
+ function getDateRange(locationConfig, index, addDays) {
8725
+ if (addDays === void 0) {
8726
+ addDays = 0;
8727
+ }
8728
+ var baseDate = dateUtils.add(now, {
8729
+ days: addDays
8730
+ });
8731
+ var start = dateUtils.set(baseDate, {
8732
+ hours: locationConfig.valid_start_times[index],
8733
+ minutes: 0,
8734
+ seconds: 0
8735
+ }, true);
8736
+ var end = dateUtils.add(start, {
8737
+ hours: locationConfig.valid_durations[index]
8738
+ });
8739
+ return [dateUtils.dateToString(start, dateUtils.DATE_FORMAT_UTC, false), dateUtils.dateToString(end, dateUtils.DATE_FORMAT_UTC, false)];
8740
+ }
8741
+ function withLocationDates(location, cb) {
8742
+ var locationConfig = fakeNafConfig.locations[location];
8743
+ var currentIndex = locationConfig.valid_start_times.findLastIndex(function (startTime) {
8744
+ return now.getUTCHours() >= startTime;
8745
+ });
8746
+ var currentIsYesterday = currentIndex === -1;
8747
+ if (currentIsYesterday) {
8748
+ currentIndex = locationConfig.valid_start_times.length - 1;
8749
+ }
8750
+ var upcomingIndex = (currentIndex + 1) % locationConfig.valid_start_times.length;
8751
+ // If upcoming start time is earlier than or equal to current start time, we've wrapped to the next day
8752
+ var upcomingWrapsToNextDay = locationConfig.valid_start_times[upcomingIndex] <= locationConfig.valid_start_times[currentIndex];
8753
+ var _getDateRange = getDateRange(locationConfig, currentIndex, currentIsYesterday ? -1 : 0),
8754
+ currentValidDateStart = _getDateRange[0],
8755
+ currentValidDateEnd = _getDateRange[1];
8756
+ var _getDateRange2 = getDateRange(locationConfig, upcomingIndex, upcomingWrapsToNextDay ? 1 : 0),
8757
+ upcomingValidDateStart = _getDateRange2[0],
8758
+ upcomingValidDateEnd = _getDateRange2[1];
8759
+ return cb({
8760
+ currentValidDateStart: currentValidDateStart,
8761
+ currentValidDateEnd: currentValidDateEnd,
8762
+ upcomingValidDateStart: upcomingValidDateStart,
8763
+ upcomingValidDateEnd: upcomingValidDateEnd
8764
+ });
8765
+ }
8766
+ var fakeNafList = [withLocationDates('EHAK', function (_ref) {
8767
+ var upcomingValidDateStart = _ref.upcomingValidDateStart,
8768
+ upcomingValidDateEnd = _ref.upcomingValidDateEnd;
8769
+ return {
8770
+ creationDate: upcomingValidDateStart,
8771
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
8772
+ editor: MOCK_USERNAME,
8773
+ taf: {
8774
+ uuid: '5f9583fjdf0f337925',
8775
+ type: 'NAF',
8776
+ baseTime: upcomingValidDateStart,
8777
+ validDateStart: upcomingValidDateStart,
8778
+ validDateEnd: upcomingValidDateEnd,
8779
+ location: 'EHAK',
8780
+ status: 'NEW',
8781
+ messageType: 'ORG',
8782
+ baseForecast: {
8783
+ valid: {
8784
+ start: upcomingValidDateStart,
8785
+ end: upcomingValidDateEnd
8786
+ }
8787
+ },
8788
+ remark: 'THIS IS A REMARK'
8789
+ }
8790
+ };
8791
+ }), withLocationDates('EHFD', function (_ref2) {
8792
+ var upcomingValidDateStart = _ref2.upcomingValidDateStart,
8793
+ upcomingValidDateEnd = _ref2.upcomingValidDateEnd;
8794
+ return {
8795
+ creationDate: upcomingValidDateStart,
8796
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
8797
+ editor: null,
8798
+ taf: {
8799
+ uuid: '5f9583fjd111137925',
8800
+ type: 'NAF',
8801
+ baseTime: upcomingValidDateStart,
8802
+ validDateStart: upcomingValidDateStart,
8803
+ validDateEnd: upcomingValidDateEnd,
8804
+ location: 'EHFD',
8805
+ status: 'DRAFT',
8806
+ messageType: 'ORG',
8807
+ baseForecast: {
8808
+ valid: {
8809
+ start: upcomingValidDateStart,
8810
+ end: upcomingValidDateEnd
8811
+ },
8812
+ wind: {
8813
+ direction: 180,
8814
+ speed: 10,
8815
+ unit: 'KT'
8816
+ },
8817
+ cavOK: true
8818
+ }
8819
+ }
8820
+ };
8821
+ }), withLocationDates('EHKV', function (_ref3) {
8822
+ var upcomingValidDateStart = _ref3.upcomingValidDateStart,
8823
+ upcomingValidDateEnd = _ref3.upcomingValidDateEnd;
8824
+ return {
8825
+ creationDate: upcomingValidDateStart,
8826
+ canbe: ['CANCELLED', 'AMENDED', 'DISCARDED'],
8827
+ editor: null,
8828
+ taf: {
8829
+ uuid: '754905485',
8830
+ type: 'NAF',
8831
+ baseTime: upcomingValidDateStart,
8832
+ previousId: '5f9583fjdf45ff4330f337925',
8833
+ validDateStart: upcomingValidDateStart,
8834
+ validDateEnd: upcomingValidDateEnd,
8835
+ previousValidDateStart: upcomingValidDateStart,
8836
+ previousValidDateEnd: upcomingValidDateEnd,
8837
+ location: 'EHKV',
8838
+ status: 'DRAFT_AMENDED',
8839
+ messageType: 'AMD',
8840
+ baseForecast: {
8841
+ valid: {
8842
+ start: upcomingValidDateStart,
8843
+ end: upcomingValidDateEnd
8844
+ },
8845
+ visibility: {
8846
+ range: 600,
8847
+ unit: 'M'
8848
+ },
8849
+ wind: {
8850
+ direction: 180,
8851
+ speed: 10,
8852
+ unit: 'KT'
8853
+ },
8854
+ weather: {
8855
+ weather1: 'SN'
8856
+ },
8857
+ cloud: {
8858
+ cloud1: {
8859
+ coverage: 'BKN',
8860
+ height: 35
8861
+ }
8862
+ }
8863
+ },
8864
+ changeGroups: [{
8865
+ change: 'TEMPO',
8866
+ probability: 'PROB30',
8867
+ valid: {
8868
+ start: dateAdd(upcomingValidDateStart, 3),
8869
+ end: dateAdd(upcomingValidDateStart, 4)
8870
+ },
8871
+ visibility: {
8872
+ range: 100,
8873
+ unit: 'M'
8874
+ },
8875
+ cloud: {
8876
+ cloud1: {
8877
+ verticalVisibility: 5
8878
+ }
8879
+ }
8880
+ }]
8881
+ }
8882
+ };
8883
+ }), withLocationDates('EHKV', function (_ref4) {
8884
+ var upcomingValidDateStart = _ref4.upcomingValidDateStart,
8885
+ upcomingValidDateEnd = _ref4.upcomingValidDateEnd;
8886
+ return {
8887
+ creationDate: upcomingValidDateStart,
8888
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
8889
+ editor: MOCK_USERNAME,
8890
+ taf: {
8891
+ uuid: '43545345345',
8892
+ type: 'NAF',
8893
+ issueDate: upcomingValidDateStart,
8894
+ baseTime: currentDate + "T18:00:00Z",
8895
+ validDateStart: currentDate + "T18:00:00Z",
8896
+ validDateEnd: upcomingValidDateEnd,
8897
+ previousId: 'jkdjkdfjkgdf',
8898
+ previousValidDateStart: upcomingValidDateStart,
8899
+ previousValidDateEnd: upcomingValidDateEnd,
8900
+ location: 'EHKV',
8901
+ status: 'CORRECTED',
8902
+ messageType: 'COR',
8903
+ baseForecast: {
8904
+ valid: {
8905
+ start: upcomingValidDateStart,
8906
+ end: upcomingValidDateEnd
8907
+ },
8908
+ wind: {
8909
+ direction: 350,
8910
+ speed: 46,
8911
+ gust: 67,
8912
+ unit: 'KT'
8913
+ },
8914
+ cavOK: true
8915
+ },
8916
+ changeGroups: [{
8917
+ change: 'BECMG',
8918
+ valid: {
8919
+ start: dateAdd(upcomingValidDateStart, 1),
8920
+ end: dateAdd(upcomingValidDateStart, 2)
8921
+ },
8922
+ visibility: {
8923
+ range: 1000,
8924
+ unit: 'M'
8925
+ },
8926
+ weather: {
8927
+ weather1: 'MIFG'
8928
+ },
8929
+ cloud: {
8930
+ cloud1: 'NSC'
8931
+ }
8932
+ }, {
8933
+ change: 'FM',
8934
+ valid: {
8935
+ start: dateAdd(upcomingValidDateStart, 2)
8936
+ },
8937
+ visibility: {
8938
+ range: 6000,
8939
+ unit: 'M'
8940
+ },
8941
+ weather: {
8942
+ weather1: '+SHRA'
8943
+ },
8944
+ cloud: {
8945
+ cloud1: {
8946
+ coverage: 'BKN',
8947
+ height: 40
8948
+ },
8949
+ cloud2: {
8950
+ coverage: 'OVC',
8951
+ height: 60,
8952
+ type: 'CB'
8953
+ }
8954
+ }
8955
+ }]
8956
+ }
8957
+ };
8958
+ }), withLocationDates('EHFD', function (_ref5) {
8959
+ var upcomingValidDateStart = _ref5.upcomingValidDateStart,
8960
+ upcomingValidDateEnd = _ref5.upcomingValidDateEnd;
8961
+ return {
8962
+ creationDate: upcomingValidDateStart,
8963
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
8964
+ editor: null,
8965
+ taf: {
8966
+ uuid: '5f9583fjdf45ff4330f337925',
8967
+ type: 'NAF',
8968
+ issueDate: upcomingValidDateStart,
8969
+ baseTime: upcomingValidDateStart,
8970
+ validDateStart: upcomingValidDateStart,
8971
+ validDateEnd: upcomingValidDateEnd,
8972
+ location: 'EHFD',
8973
+ status: 'PUBLISHED',
8974
+ messageType: 'ORG',
8975
+ baseForecast: {
8976
+ valid: {
8977
+ start: upcomingValidDateStart,
8978
+ end: upcomingValidDateEnd
8979
+ },
8980
+ visibility: {
8981
+ range: 600,
8982
+ unit: 'M'
8983
+ },
8984
+ wind: {
8985
+ direction: 180,
8986
+ speed: 10,
8987
+ unit: 'KT'
8988
+ },
8989
+ weather: {
8990
+ weather1: 'SN'
8991
+ },
8992
+ cloud: {
8993
+ cloud1: {
8994
+ coverage: 'BKN',
8995
+ height: 35
8996
+ }
8997
+ }
8998
+ },
8999
+ changeGroups: [{
9000
+ change: 'TEMPO',
9001
+ probability: 'PROB30',
9002
+ valid: {
9003
+ start: dateAdd(upcomingValidDateStart, 1),
9004
+ end: dateAdd(upcomingValidDateStart, 2)
9005
+ },
9006
+ visibility: {
9007
+ range: 200,
9008
+ unit: 'M'
9009
+ },
9010
+ cloud: {
9011
+ cloud1: {
9012
+ verticalVisibility: 5
9013
+ }
9014
+ }
9015
+ }]
9016
+ }
9017
+ };
9018
+ }), withLocationDates('EHHW', function (_ref6) {
9019
+ var upcomingValidDateStart = _ref6.upcomingValidDateStart,
9020
+ upcomingValidDateEnd = _ref6.upcomingValidDateEnd;
9021
+ return {
9022
+ creationDate: upcomingValidDateStart,
9023
+ canbe: ['AMENDED'],
9024
+ editor: null,
9025
+ taf: {
9026
+ uuid: '5464565464',
9027
+ type: 'NAF',
9028
+ previousId: '5445fghrfg3546456',
9029
+ issueDate: upcomingValidDateStart,
9030
+ baseTime: upcomingValidDateStart,
9031
+ validDateStart: upcomingValidDateStart,
9032
+ validDateEnd: upcomingValidDateEnd,
9033
+ previousValidDateStart: upcomingValidDateStart,
9034
+ previousValidDateEnd: upcomingValidDateEnd,
9035
+ location: 'EHHW',
9036
+ status: 'CANCELLED',
9037
+ messageType: 'CNL',
9038
+ baseForecast: {
9039
+ valid: {
9040
+ start: upcomingValidDateStart,
9041
+ end: upcomingValidDateEnd
9042
+ },
9043
+ visibility: {
9044
+ range: 600,
9045
+ unit: 'M'
9046
+ },
9047
+ wind: {
9048
+ direction: 180,
9049
+ speed: 10,
9050
+ unit: 'KT'
9051
+ },
9052
+ weather: {
9053
+ weather1: 'SN'
9054
+ },
9055
+ cloud: {
9056
+ cloud1: {
9057
+ coverage: 'BKN',
9058
+ height: 35
9059
+ }
9060
+ }
9061
+ }
9062
+ }
9063
+ };
9064
+ }), withLocationDates('EHMA', function (_ref7) {
9065
+ var upcomingValidDateStart = _ref7.upcomingValidDateStart,
9066
+ upcomingValidDateEnd = _ref7.upcomingValidDateEnd;
9067
+ return {
9068
+ creationDate: upcomingValidDateStart,
9069
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
9070
+ editor: 'max.jansen',
9071
+ taf: {
9072
+ uuid: 'gh56734fghfgh',
9073
+ type: 'NAF',
9074
+ previousId: '8574jnf93475',
9075
+ issueDate: currentDate + "T16:16:00Z",
9076
+ baseTime: upcomingValidDateStart,
9077
+ validDateStart: upcomingValidDateStart,
9078
+ validDateEnd: upcomingValidDateEnd,
9079
+ previousValidDateStart: upcomingValidDateStart,
9080
+ previousValidDateEnd: upcomingValidDateEnd,
9081
+ location: 'EHMA',
9082
+ status: 'AMENDED',
9083
+ messageType: 'AMD',
9084
+ baseForecast: {
9085
+ valid: {
9086
+ start: currentDate + "T16:12:00Z",
9087
+ end: upcomingValidDateEnd
9088
+ },
9089
+ visibility: {
9090
+ range: 600,
9091
+ unit: 'M'
9092
+ },
9093
+ wind: {
9094
+ direction: 180,
9095
+ speed: 10,
9096
+ unit: 'KT'
9097
+ },
9098
+ weather: {
9099
+ weather1: 'SN'
9100
+ },
9101
+ cloud: {
9102
+ cloud1: {
9103
+ coverage: 'BKN',
9104
+ height: 35
9105
+ }
9106
+ }
9107
+ }
9108
+ }
9109
+ };
9110
+ }), withLocationDates('EHQN', function (_ref8) {
9111
+ var currentValidDateStart = _ref8.currentValidDateStart,
9112
+ currentValidDateEnd = _ref8.currentValidDateEnd;
9113
+ return {
9114
+ creationDate: currentValidDateStart,
9115
+ canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
9116
+ editor: null,
9117
+ taf: {
9118
+ uuid: 'giskdj09845872039',
9119
+ type: 'NAF',
9120
+ issueDate: currentValidDateStart,
9121
+ baseTime: currentValidDateStart,
9122
+ validDateStart: currentValidDateStart,
9123
+ validDateEnd: currentValidDateEnd,
9124
+ location: 'EHQN',
9125
+ status: 'PUBLISHED',
9126
+ messageType: 'ORG',
9127
+ baseForecast: {
9128
+ valid: {
9129
+ start: currentValidDateStart,
9130
+ end: currentValidDateEnd
9131
+ },
9132
+ visibility: {
9133
+ range: 500,
9134
+ unit: 'M'
9135
+ },
9136
+ wind: {
9137
+ direction: 200,
9138
+ speed: 20,
9139
+ gust: 35,
9140
+ unit: 'KT'
9141
+ },
9142
+ weather: {
9143
+ weather1: 'SN'
9144
+ },
9145
+ cloud: {
9146
+ cloud1: {
9147
+ coverage: 'BKN',
9148
+ height: 40
9149
+ }
9150
+ }
9151
+ }
9152
+ }
9153
+ };
9154
+ }), withLocationDates('EHPG', function (_ref9) {
9155
+ var currentValidDateStart = _ref9.currentValidDateStart,
9156
+ currentValidDateEnd = _ref9.currentValidDateEnd;
9157
+ return {
9158
+ creationDate: currentValidDateStart,
9159
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
9160
+ editor: null,
9161
+ taf: {
9162
+ uuid: 'ghskdj09845872039',
9163
+ type: 'NAF',
9164
+ baseTime: currentValidDateStart,
9165
+ validDateStart: currentValidDateStart,
9166
+ validDateEnd: currentValidDateEnd,
9167
+ location: 'EHPG',
9168
+ status: 'NEW',
9169
+ messageType: 'ORG',
9170
+ baseForecast: {
9171
+ valid: {
9172
+ start: currentValidDateStart,
9173
+ end: currentValidDateEnd
9174
+ }
9175
+ }
9176
+ }
9177
+ };
9178
+ }), withLocationDates('EHDV', function (_ref0) {
9179
+ var currentValidDateStart = _ref0.currentValidDateStart,
9180
+ currentValidDateEnd = _ref0.currentValidDateEnd;
9181
+ return {
9182
+ creationDate: currentValidDateStart,
9183
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
9184
+ editor: null,
9185
+ taf: {
9186
+ uuid: 'eHDV123456789',
9187
+ type: 'NAF',
9188
+ baseTime: currentValidDateStart,
9189
+ validDateStart: currentValidDateStart,
9190
+ validDateEnd: currentValidDateEnd,
9191
+ location: 'EHDV',
9192
+ status: 'NEW',
9193
+ messageType: 'ORG',
9194
+ baseForecast: {
9195
+ valid: {
9196
+ start: currentValidDateStart,
9197
+ end: currentValidDateEnd
9198
+ },
9199
+ wind: {
9200
+ direction: 270,
9201
+ speed: 15,
9202
+ unit: 'KT'
9203
+ },
9204
+ cavOK: true
9205
+ }
9206
+ }
9207
+ };
9208
+ }),
9209
+ // Added missing NafLocation: EHMG
9210
+ withLocationDates('EHMG', function (_ref1) {
9211
+ var currentValidDateStart = _ref1.currentValidDateStart,
9212
+ currentValidDateEnd = _ref1.currentValidDateEnd;
9213
+ return {
9214
+ creationDate: currentValidDateStart,
9215
+ canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
9216
+ editor: null,
9217
+ taf: {
9218
+ uuid: 'eHMG987654321',
9219
+ type: 'NAF',
9220
+ baseTime: currentValidDateStart,
9221
+ validDateStart: currentValidDateStart,
9222
+ validDateEnd: currentValidDateEnd,
9223
+ location: 'EHMG',
9224
+ status: 'NEW',
9225
+ messageType: 'ORG',
9226
+ baseForecast: {
9227
+ valid: {
9228
+ start: currentValidDateStart,
9229
+ end: currentValidDateEnd
9230
+ },
9231
+ visibility: {
9232
+ range: 8000,
9233
+ unit: 'M'
9234
+ },
9235
+ wind: {
9236
+ direction: 90,
9237
+ speed: 8,
9238
+ unit: 'KT'
9239
+ },
9240
+ cloud: {
9241
+ cloud1: {
9242
+ coverage: 'SCT',
9243
+ height: 25
9244
+ }
9245
+ }
9246
+ }
9247
+ }
9248
+ };
9249
+ })];
9250
+
8321
9251
  var fakeUpdatedTafList = [].concat(fakeTafList);
8322
- var setFakeUpdatedList = function setFakeUpdatedList(newList) {
9252
+ var setFakeUpdatedTafList = function setFakeUpdatedTafList(newList) {
8323
9253
  fakeUpdatedTafList = newList;
8324
9254
  };
8325
- var getFakeUpdatedList = function getFakeUpdatedList() {
9255
+ var getFakeUpdatedTafList = function getFakeUpdatedTafList() {
8326
9256
  return fakeUpdatedTafList;
8327
9257
  };
9258
+ var fakeUpdatedNafList = [].concat(fakeNafList);
9259
+ var setFakeUpdatedNafList = function setFakeUpdatedNafList(newList) {
9260
+ fakeUpdatedNafList = newList;
9261
+ };
9262
+ var getFakeUpdatedNafList = function getFakeUpdatedNafList() {
9263
+ return fakeUpdatedNafList;
9264
+ };
8328
9265
  var fakeTafTacJson = {
8329
9266
  tac: [[{
8330
9267
  text: 'TAF'
@@ -8357,45 +9294,13 @@ var fakeTafTacJson = {
8357
9294
  text: '='
8358
9295
  }]]
8359
9296
  };
8360
- var fakeTafConfig = {
8361
- location_indicator_mwo: 'EHDB',
8362
- locations: {
8363
- EHAM: {
8364
- validity_duration: 30,
8365
- activity_period: 6,
8366
- label: 'Schiphol'
8367
- },
8368
- EHRD: {
8369
- validity_duration: 30,
8370
- activity_period: 6,
8371
- label: 'Rotterdam'
8372
- },
8373
- EHGG: {
8374
- validity_duration: 30,
8375
- activity_period: 6,
8376
- label: 'Eelde'
8377
- },
8378
- EHBK: {
8379
- validity_duration: 30,
8380
- activity_period: 6,
8381
- label: 'Maastricht'
8382
- },
8383
- EHLE: {
8384
- validity_duration: 30,
8385
- activity_period: 6,
8386
- label: 'Lelystad'
8387
- },
8388
- TNCB: {
8389
- validity_duration: 30,
8390
- activity_period: 6,
8391
- label: 'Bonaire'
8392
- }
8393
- },
8394
- locationOrder: ['EHAM', 'EHRD', 'EHLE', 'EHGG', 'EHBK', 'TNCB'],
8395
- autoTAFlocations: ['EHAM', 'EHRD', 'EHLE', 'EHGG', 'EHBK']
8396
- };
8397
- var tafEndPoints = [http.get(/^.*\/taflist$/, function () {
8398
- return HttpResponse.json(getFakeUpdatedList());
9297
+ var tafEndPoints = [http.get(/^.*\/taflist$/, function (_ref) {
9298
+ var request = _ref.request;
9299
+ var url = new URL(request.url);
9300
+ if (url.searchParams.get('type') === 'NAF') {
9301
+ return HttpResponse.json(getFakeUpdatedNafList());
9302
+ }
9303
+ return HttpResponse.json(getFakeUpdatedTafList());
8399
9304
  }), http.post(/^.*\/taf$/, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8400
9305
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8401
9306
  while (1) switch (_context.prev = _context.next) {
@@ -8410,17 +9315,18 @@ var tafEndPoints = [http.get(/^.*\/taflist$/, function () {
8410
9315
  }
8411
9316
  }, _callee);
8412
9317
  }))), http.patch(/^.*\/taf$/, /*#__PURE__*/function () {
8413
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
8414
- var request, patchTaf, updatedList;
9318
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
9319
+ var request, patchTaf, items, updatedList;
8415
9320
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
8416
9321
  while (1) switch (_context2.prev = _context2.next) {
8417
9322
  case 0:
8418
- request = _ref2.request;
9323
+ request = _ref3.request;
8419
9324
  _context2.next = 3;
8420
9325
  return request.json();
8421
9326
  case 3:
8422
9327
  patchTaf = _context2.sent;
8423
- updatedList = getFakeUpdatedList().map(function (tafFromBackend) {
9328
+ items = patchTaf.taf.type === 'NAF' ? getFakeUpdatedNafList() : getFakeUpdatedTafList();
9329
+ updatedList = items.map(function (tafFromBackend) {
8424
9330
  if (tafFromBackend.taf.uuid === patchTaf.taf.uuid) {
8425
9331
  return Object.assign({}, tafFromBackend, {
8426
9332
  editor: patchTaf.editor
@@ -8428,19 +9334,23 @@ var tafEndPoints = [http.get(/^.*\/taflist$/, function () {
8428
9334
  }
8429
9335
  return tafFromBackend;
8430
9336
  });
8431
- setFakeUpdatedList(updatedList);
8432
- _context2.next = 8;
9337
+ if (patchTaf.taf.type === 'NAF') {
9338
+ setFakeUpdatedNafList(updatedList);
9339
+ } else {
9340
+ setFakeUpdatedTafList(updatedList);
9341
+ }
9342
+ _context2.next = 9;
8433
9343
  return delay();
8434
- case 8:
8435
- return _context2.abrupt("return", HttpResponse.json(null));
8436
9344
  case 9:
9345
+ return _context2.abrupt("return", HttpResponse.json(null));
9346
+ case 10:
8437
9347
  case "end":
8438
9348
  return _context2.stop();
8439
9349
  }
8440
9350
  }, _callee2);
8441
9351
  }));
8442
9352
  return function (_x) {
8443
- return _ref3.apply(this, arguments);
9353
+ return _ref4.apply(this, arguments);
8444
9354
  };
8445
9355
  }()), http.post(/^.*\/taf2tac$/, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
8446
9356
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
@@ -8455,7 +9365,12 @@ var tafEndPoints = [http.get(/^.*\/taflist$/, function () {
8455
9365
  return _context3.stop();
8456
9366
  }
8457
9367
  }, _callee3);
8458
- }))), http.get(/^.*\/taf-config$/, function () {
9368
+ }))), http.get(/^.*\/taf-config/, function (_ref6) {
9369
+ var request = _ref6.request;
9370
+ var url = new URL(request.url);
9371
+ if (url.searchParams.get('type') === 'NAF') {
9372
+ return HttpResponse.json(fakeNafConfig);
9373
+ }
8459
9374
  return HttpResponse.json(fakeTafConfig);
8460
9375
  })];
8461
9376