@opengeoweb/warnings 12.7.0 → 12.8.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
@@ -2227,6 +2227,9 @@ var slice$1 = createSlice({
2227
2227
  var warningId = action.payload.warningId;
2228
2228
  draft.selectedWarningId = warningId;
2229
2229
  draft.formState = 'edit';
2230
+ },
2231
+ setSelectedWarningId: function setSelectedWarningId(draft, action) {
2232
+ draft.selectedWarningId = action.payload;
2230
2233
  }
2231
2234
  },
2232
2235
  extraReducers: function extraReducers(builder) {
@@ -4538,6 +4541,15 @@ var usePostSigmet = function usePostSigmet() {
4538
4541
  }
4539
4542
  return postSigmet(auth, formData);
4540
4543
  },
4544
+ onError: function onError(error) {
4545
+ void queryClient.invalidateQueries({
4546
+ queryKey: ['sigmet']
4547
+ });
4548
+ var errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
4549
+ dispatch(publicWarningFormActions.setFormError({
4550
+ message: "Failed to save SIGMET: " + errorMessage
4551
+ }));
4552
+ },
4541
4553
  onSuccess: function () {
4542
4554
  var _onSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data, variables) {
4543
4555
  var snackbarKey, warningType;
@@ -4590,6 +4602,15 @@ var usePostAirmet = function usePostAirmet() {
4590
4602
  }
4591
4603
  return postAirmet(auth, formData);
4592
4604
  },
4605
+ onError: function onError(error) {
4606
+ void queryClient.invalidateQueries({
4607
+ queryKey: ['airmet']
4608
+ });
4609
+ var errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
4610
+ dispatch(publicWarningFormActions.setFormError({
4611
+ message: "Failed to save AIRMET: " + errorMessage
4612
+ }));
4613
+ },
4593
4614
  onSuccess: function () {
4594
4615
  var _onSuccess2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data, variables) {
4595
4616
  var snackbarKey, warningType;
@@ -5920,7 +5941,9 @@ var Form = function Form(_ref5) {
5920
5941
  });
5921
5942
  };
5922
5943
  var cancelAviationProduct = function cancelAviationProduct(warningType) {
5923
- return onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType, isVAPhenomenon(selectedAviationProduct, ProductAction.CANCEL) && watch('vaSigmetMoveToFIR'));
5944
+ return onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType, isVAPhenomenon(selectedAviationProduct, ProductAction.CANCEL) && watch('vaSigmetMoveToFIR')).then(function (result) {
5945
+ return result != null ? result : null;
5946
+ });
5924
5947
  };
5925
5948
  var getPublishButtonLabel = function getPublishButtonLabel() {
5926
5949
  if (isCancelling) {
@@ -5949,7 +5972,7 @@ var Form = function Form(_ref5) {
5949
5972
  return _context10.abrupt("return");
5950
5973
  case 2:
5951
5974
  _context10.t0 = action;
5952
- _context10.next = _context10.t0 === ProductAction.SAVE ? 5 : _context10.t0 === ProductAction.PUBLISH ? 14 : _context10.t0 === ProductAction.CANCEL ? 16 : _context10.t0 === ProductAction.AMEND ? 18 : _context10.t0 === ProductAction.RENEW ? 20 : _context10.t0 === ProductAction.DISCARD ? 20 : _context10.t0 === ProductAction.DUPLICATE ? 20 : _context10.t0 === ProductAction.CLOSE ? 20 : 21;
5975
+ _context10.next = _context10.t0 === ProductAction.SAVE ? 5 : _context10.t0 === ProductAction.PUBLISH ? 14 : _context10.t0 === ProductAction.CANCEL ? 17 : _context10.t0 === ProductAction.AMEND ? 19 : _context10.t0 === ProductAction.RENEW ? 21 : _context10.t0 === ProductAction.DISCARD ? 21 : _context10.t0 === ProductAction.DUPLICATE ? 21 : _context10.t0 === ProductAction.CLOSE ? 21 : 22;
5953
5976
  break;
5954
5977
  case 5:
5955
5978
  toggleIsDraft(true);
@@ -5960,11 +5983,17 @@ var Form = function Form(_ref5) {
5960
5983
  formValues = getValues();
5961
5984
  setIsSaving(true);
5962
5985
  _context10.next = 12;
5963
- return onSaveAviationForm(formValues, 'DRAFT', warningType)["catch"](function () {});
5986
+ return onSaveAviationForm(formValues, 'DRAFT', warningType, undefined, function (uuid) {
5987
+ setValue('uuid', uuid, {
5988
+ shouldValidate: true,
5989
+ shouldDirty: false
5990
+ });
5991
+ })["catch"](function () {});
5964
5992
  case 12:
5965
5993
  setIsSaving(false);
5966
- return _context10.abrupt("break", 22);
5994
+ return _context10.abrupt("break", 23);
5967
5995
  case 14:
5996
+ toggleIsDraft(false);
5968
5997
  void handleSubmit( /*#__PURE__*/function () {
5969
5998
  var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(formValues) {
5970
5999
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
@@ -5997,8 +6026,8 @@ var Form = function Form(_ref5) {
5997
6026
  return _ref12.apply(this, arguments);
5998
6027
  };
5999
6028
  }())();
6000
- return _context10.abrupt("break", 22);
6001
- case 16:
6029
+ return _context10.abrupt("break", 23);
6030
+ case 17:
6002
6031
  void showConfirmDialog(action).then(function () {
6003
6032
  setIsCancelling(true);
6004
6033
  void cancelAviationProduct(warningType)["finally"](function () {
@@ -6006,8 +6035,8 @@ var Form = function Form(_ref5) {
6006
6035
  onCloseForm();
6007
6036
  });
6008
6037
  });
6009
- return _context10.abrupt("break", 22);
6010
- case 18:
6038
+ return _context10.abrupt("break", 23);
6039
+ case 19:
6011
6040
  void handleSubmit( /*#__PURE__*/function () {
6012
6041
  var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(formValues) {
6013
6042
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
@@ -6041,12 +6070,12 @@ var Form = function Form(_ref5) {
6041
6070
  return _ref14.apply(this, arguments);
6042
6071
  };
6043
6072
  }())();
6044
- return _context10.abrupt("break", 22);
6045
- case 20:
6046
- return _context10.abrupt("break", 22);
6073
+ return _context10.abrupt("break", 23);
6047
6074
  case 21:
6048
- console.warn("Unhandled product action: " + action);
6075
+ return _context10.abrupt("break", 23);
6049
6076
  case 22:
6077
+ console.warn("Unhandled product action: " + action);
6078
+ case 23:
6050
6079
  case "end":
6051
6080
  return _context10.stop();
6052
6081
  }
@@ -6567,46 +6596,44 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
6567
6596
  return selectedProduct.airmet;
6568
6597
  };
6569
6598
  var saveAviationForm = /*#__PURE__*/function () {
6570
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType, vaSigmetMoveToFIR) {
6571
- var product, uuid, _postProductParam, postProductParam, errorMessage;
6599
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType, vaSigmetMoveToFIR, setSelectedUUID) {
6600
+ var _result;
6601
+ var product, uuid, result, postProductParam, _postProductParam;
6572
6602
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
6573
6603
  while (1) switch (_context2.prev = _context2.next) {
6574
6604
  case 0:
6575
- // if volcanic sigmet - add to which FIR it's moving
6576
6605
  product = newStatus === 'CANCELLED' && selectedBackendProduct ? getCancelSigmet(selectedBackendProduct, vaSigmetMoveToFIR) : productToPost;
6577
- _context2.prev = 1;
6578
6606
  uuid = (selectedAviationProduct == null ? void 0 : selectedAviationProduct.uuid) || null;
6579
6607
  if (!(warningType === 'sigmet')) {
6580
- _context2.next = 8;
6608
+ _context2.next = 9;
6581
6609
  break;
6582
6610
  }
6583
- _postProductParam = createSigmetPostParameter(product, newStatus, uuid);
6584
- _context2.next = 7;
6585
- return postSigmet(_postProductParam);
6586
- case 7:
6587
- return _context2.abrupt("return", _context2.sent);
6588
- case 8:
6589
- postProductParam = createAirmetPostParameter(product, newStatus, uuid);
6590
- _context2.next = 11;
6591
- return postAirmet(postProductParam);
6592
- case 11:
6593
- return _context2.abrupt("return", _context2.sent);
6594
- case 14:
6595
- _context2.prev = 14;
6596
- _context2.t0 = _context2["catch"](1);
6597
- errorMessage = _context2.t0 instanceof Error ? _context2.t0 : 'Unknown error occurred';
6598
- dispatch(snackbarActions.openSnackbar({
6599
- type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
6600
- message: "Failed to save " + warningType.toUpperCase() + ": " + errorMessage
6601
- }));
6602
- throw _context2.t0;
6603
- case 19:
6611
+ postProductParam = createSigmetPostParameter(product, newStatus, uuid);
6612
+ _context2.next = 6;
6613
+ return postSigmet(postProductParam);
6614
+ case 6:
6615
+ result = _context2.sent;
6616
+ _context2.next = 13;
6617
+ break;
6618
+ case 9:
6619
+ _postProductParam = createAirmetPostParameter(product, newStatus, uuid);
6620
+ _context2.next = 12;
6621
+ return postAirmet(_postProductParam);
6622
+ case 12:
6623
+ result = _context2.sent;
6624
+ case 13:
6625
+ if ((_result = result) != null && _result.uuid) {
6626
+ setSelectedUUID == null || setSelectedUUID(result.uuid);
6627
+ dispatch(publicWarningFormActions.setSelectedWarningId(result.uuid));
6628
+ }
6629
+ return _context2.abrupt("return", result);
6630
+ case 15:
6604
6631
  case "end":
6605
6632
  return _context2.stop();
6606
6633
  }
6607
- }, _callee2, null, [[1, 14]]);
6634
+ }, _callee2);
6608
6635
  }));
6609
- return function saveAviationForm(_x2, _x3, _x4, _x5) {
6636
+ return function saveAviationForm(_x2, _x3, _x4, _x5, _x6) {
6610
6637
  return _ref3.apply(this, arguments);
6611
6638
  };
6612
6639
  }();
@@ -6633,7 +6660,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
6633
6660
  }
6634
6661
  }, _callee3);
6635
6662
  }));
6636
- return function saveForm(_x6) {
6663
+ return function saveForm(_x7) {
6637
6664
  return _ref4.apply(this, arguments);
6638
6665
  };
6639
6666
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "12.7.0",
3
+ "version": "12.8.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,30 +8,31 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/api": "12.7.0",
12
- "@opengeoweb/shared": "12.7.0",
13
- "@opengeoweb/store": "12.7.0",
14
- "@opengeoweb/webmap-react": "12.7.0",
11
+ "@opengeoweb/api": "12.8.0",
12
+ "@opengeoweb/shared": "12.8.0",
13
+ "@opengeoweb/store": "12.8.0",
14
+ "@opengeoweb/webmap-react": "12.8.0",
15
15
  "@tanstack/react-query": "^5.69.2",
16
16
  "react-redux": "^9.2.0",
17
- "@opengeoweb/theme": "12.7.0",
18
- "@opengeoweb/form-fields": "12.7.0",
17
+ "@opengeoweb/theme": "12.8.0",
18
+ "@opengeoweb/form-fields": "12.8.0",
19
19
  "react-hook-form": "^7.50.1",
20
20
  "lodash": "^4.17.21",
21
21
  "@reduxjs/toolkit": "^2.6.1",
22
- "@opengeoweb/snackbar": "12.7.0",
22
+ "@opengeoweb/snackbar": "12.8.0",
23
23
  "react-window": "^1.8.10",
24
24
  "react-virtualized-auto-sizer": "^1.0.20",
25
25
  "axios": "^1.7.7",
26
- "@opengeoweb/core": "12.7.0",
27
- "@opengeoweb/webmap": "12.7.0",
28
- "@opengeoweb/authentication": "12.7.0",
29
- "@opengeoweb/sigmet-airmet": "12.7.0",
26
+ "@opengeoweb/core": "12.8.0",
27
+ "@opengeoweb/webmap": "12.8.0",
28
+ "@opengeoweb/authentication": "12.8.0",
29
+ "@opengeoweb/sigmet-airmet": "12.8.0",
30
30
  "react-i18next": "^15.1.1",
31
31
  "i18next": "^25.0.1",
32
32
  "@mui/material": "^7.0.1",
33
33
  "ol": "^10.4.0",
34
- "msw": "^2.7.3"
34
+ "msw": "^2.7.3",
35
+ "@types/geojson": "^7946.0.14"
35
36
  },
36
37
  "peerDependencies": {
37
38
  "react": "18",
@@ -41,5 +42,5 @@
41
42
  "module": "./index.esm.js",
42
43
  "type": "module",
43
44
  "main": "./index.esm.js",
44
- "types": "./index.esm.d.ts"
45
+ "types": "./index.d.ts"
45
46
  }
@@ -13,5 +13,5 @@ export declare const getAirmetTAC: (auth: Credentials, product: AviationProduct)
13
13
  export declare const getSigmetTAC: (auth: Credentials, product: AviationProduct) => Promise<{
14
14
  data: string;
15
15
  }>;
16
- export declare const postSigmet: (auth: Credentials, data: SigmetFromFrontend) => Promise<Headers | null>;
17
- export declare const postAirmet: (auth: Credentials, data: AirmetFromFrontend) => Promise<Headers | null>;
16
+ export declare const postSigmet: (auth: Credentials, data: SigmetFromFrontend) => Promise<SigmetFromBackend>;
17
+ export declare const postAirmet: (auth: Credentials, data: AirmetFromFrontend) => Promise<AirmetFromBackend>;
@@ -13,9 +13,6 @@ export declare const useTACApi: () => {
13
13
  fetchSigmetTAC: (product: AviationProduct) => FetchTACData;
14
14
  fetchAirmetTAC: (product: AviationProduct) => FetchTACData;
15
15
  };
16
- type MutationReturnType<T> = UseMutationResult<Headers | null, Error, T, {
17
- oldData: AirmetFromFrontend[] | SigmetFromFrontend[] | undefined;
18
- }>;
19
16
  /**
20
17
  * Hook for posting a SIGMET, with feedback.
21
18
  *
@@ -23,7 +20,7 @@ type MutationReturnType<T> = UseMutationResult<Headers | null, Error, T, {
23
20
  * @param onDialogClose - Optional callback to close a dialog.
24
21
  * @returns A mutation result for posting a SIGMET.
25
22
  */
26
- export declare const usePostSigmet: () => MutationReturnType<SigmetFromFrontend>;
23
+ export declare const usePostSigmet: () => UseMutationResult<SigmetFromBackend, Error, SigmetFromFrontend>;
27
24
  /**
28
25
  * Hook for posting an AIRMET, with feedback.
29
26
  *
@@ -31,5 +28,5 @@ export declare const usePostSigmet: () => MutationReturnType<SigmetFromFrontend>
31
28
  * @param onDialogClose - Optional callback to close a dialog.
32
29
  * @returns A mutation result for posting an AIRMET.
33
30
  */
34
- export declare const usePostAirmet: () => MutationReturnType<AirmetFromFrontend>;
31
+ export declare const usePostAirmet: () => UseMutationResult<AirmetFromBackend, Error, AirmetFromFrontend>;
35
32
  export {};
@@ -11,10 +11,10 @@ declare const _default: {
11
11
  onMouseDown?: (() => void) | undefined;
12
12
  isOpen: boolean;
13
13
  order?: number | undefined;
14
- source?: import("dist/libs/shared/src").Source | undefined;
15
- size?: import("dist/libs/shared/src").DraggableSize | undefined;
16
- startPosition?: import("dist/libs/shared/src").Position | undefined;
17
- headerSize?: import("dist/libs/shared/src").HeaderSize | undefined;
14
+ source?: import("@opengeoweb/shared").Source | undefined;
15
+ size?: import("@opengeoweb/shared").DraggableSize | undefined;
16
+ startPosition?: import("@opengeoweb/shared").Position | undefined;
17
+ headerSize?: import("@opengeoweb/shared").HeaderSize | undefined;
18
18
  drawingListItems: DrawingListItem[];
19
19
  onClickDrawing?: ((drawing: DrawingListItem) => void) | undefined;
20
20
  onEditDrawing?: ((drawingId: string) => void) | undefined;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
+ import { AirmetFromBackend, SigmetFromBackend } from '@opengeoweb/api';
2
3
  export interface ConfirmDialogProps {
3
4
  title: string;
4
5
  description: string;
5
- request: () => Promise<void> | Promise<Headers | null>;
6
+ request: () => Promise<void> | Promise<Headers | null> | Promise<SigmetFromBackend | AirmetFromBackend>;
6
7
  confirmLabel: string;
7
8
  callback?: (data?: unknown) => void;
8
9
  isLocked?: boolean;
@@ -2,6 +2,7 @@ import { AviationProduct, FormMode, ProductStatus } from '@opengeoweb/sigmet-air
2
2
  import * as React from 'react';
3
3
  import { MapPreset } from '@opengeoweb/store';
4
4
  import { FeatureCollection, GeoJsonProperties, Geometry } from 'geojson';
5
+ import { AirmetFromBackend, SigmetFromBackend } from '@opengeoweb/api';
5
6
  import { FormError } from '../../store/publicWarningForm/reducer';
6
7
  import { Area, PublicWarningDetail, WarningType } from '../../store/publicWarningForm/types';
7
8
  import { BaseDrawingListItem, DrawingListItem } from '../../store/warningsDrawings/types';
@@ -21,7 +22,7 @@ export interface FormProps {
21
22
  onPublishForm?: (formValues: PublicWarningDetail) => Promise<Headers | null>;
22
23
  onClearForm?: () => void;
23
24
  onCloseForm?: () => void;
24
- onSaveAviationForm?: (formValues: AviationProduct, action: ProductStatus, warningType: 'sigmet' | 'airmet', vaSigmetMoveToFIR?: string) => Promise<Headers | null>;
25
+ onSaveAviationForm?: (productToPost: AviationProduct, newStatus: ProductStatus, warningType: 'sigmet' | 'airmet', vaSigmetMoveToFIR?: string, setSelectedUUID?: (uuid: string) => void) => Promise<SigmetFromBackend | AirmetFromBackend | undefined>;
25
26
  object?: DrawingListItem;
26
27
  publicWarningDetails?: PublicWarningDetail;
27
28
  error?: FormError;
@@ -47,4 +47,5 @@ export declare const publicWarningFormReducer: import("redux").Reducer<WarningFo
47
47
  setEditMode: (draft: Draft<WarningFormState>, action: PayloadAction<{
48
48
  warningId: string;
49
49
  }>) => void;
50
+ setSelectedWarningId: (draft: Draft<WarningFormState>, action: PayloadAction<string>) => void;
50
51
  }, "publicWarningForm">;
@@ -1,6 +1,8 @@
1
1
  import { RequestHandler } from 'msw';
2
+ import { SigmetFromBackend } from '@opengeoweb/api';
2
3
  import type { DrawingFromBE, DrawingListItem } from '../../store/warningsDrawings/types';
3
4
  import type { AirmetWarning, PublicWarning, SigmetWarning, Warning } from '../../store/publicWarningForm/types';
5
+ export declare const newSigmet: SigmetFromBackend;
4
6
  declare const drawingList: DrawingListItem[];
5
7
  declare const drawingsListFullContent: DrawingFromBE[];
6
8
  declare const warningList: PublicWarning[];
File without changes