@odynn/awayz-core 0.9.21 → 0.9.24

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.
@@ -30,21 +30,21 @@ class O {
30
30
  );
31
31
  if (!(a != null && a.success))
32
32
  return [];
33
- const s = a.data.map((c) => ({
33
+ const t = a.data.map((c) => ({
34
34
  ...c,
35
35
  flightBookings: T(c.flight_bookings ?? []),
36
36
  hotelBookings: b(c.hotel_bookings ?? [])
37
37
  }));
38
- return d(s);
38
+ return d(t);
39
39
  });
40
40
  n(this, "updateTrip", async (e, a) => {
41
- const { data: s } = await i.put(
41
+ const { data: t } = await i.put(
42
42
  `${o.TRIPS}/${e}`,
43
43
  D(u(a))
44
44
  );
45
- return s != null && s.success ? {
45
+ return t != null && t.success ? {
46
46
  success: !0,
47
- data: d(s.data),
47
+ data: d(t.data),
48
48
  message: "Trip updated successfully."
49
49
  } : {
50
50
  success: !1,
@@ -69,30 +69,30 @@ class O {
69
69
  hotelBookings: []
70
70
  };
71
71
  });
72
- n(this, "addBookingToTrip", async (e, a, s) => {
73
- const { data: t } = await i.put(o.ADD_BOOKING, {
72
+ n(this, "addBookingToTrip", async (e, a, t) => {
73
+ const { data: s } = await i.put(o.ADD_BOOKING, {
74
74
  trip_id: e,
75
75
  booking_id: a,
76
- booking_type: s
76
+ booking_type: t
77
77
  });
78
- return t.success;
78
+ return s.success;
79
79
  });
80
- n(this, "removeBookingFromTrip", async (e, a, s) => {
81
- const { data: t } = await i.put(
80
+ n(this, "removeBookingFromTrip", async (e, a, t) => {
81
+ const { data: s } = await i.put(
82
82
  o.REMOVE_BOOKING,
83
83
  u({
84
84
  trip_id: e,
85
85
  booking_id: a,
86
- booking_type: s
86
+ booking_type: t
87
87
  })
88
88
  );
89
- return t.success;
89
+ return s.success;
90
90
  });
91
91
  }
92
92
  }
93
93
  const T = (r) => r.map((e) => {
94
94
  var c, l, _, g;
95
- const a = e.slices.length > 1, s = e.slices[0], t = a ? e.slices.getLast() : void 0;
95
+ const a = e.slices.length > 1, t = e.slices[0], s = a ? e.slices.getLast() : void 0;
96
96
  return d({
97
97
  id: e._id,
98
98
  reference: e.booking_reference,
@@ -107,24 +107,24 @@ const T = (r) => r.map((e) => {
107
107
  };
108
108
  }),
109
109
  arrival: {
110
- airportCode: s.destination,
110
+ airportCode: t.destination,
111
111
  location: ""
112
112
  },
113
113
  departure: {
114
- airportCode: s.origin,
114
+ airportCode: t.origin,
115
115
  location: ""
116
116
  },
117
- class: s.fare_brand_name,
117
+ class: t.fare_brand_name,
118
118
  passengers: e.passengers.length,
119
119
  hasAirlineChanges: !1,
120
120
  orderId: e.order_id,
121
121
  type: e.type,
122
122
  cancelledAt: e.cancelled_at,
123
123
  isRoundTrip: a,
124
- outboundArrivalDate: (l = (c = s.segments) == null ? void 0 : c.getLast()) == null ? void 0 : l.arriving_at,
125
- inboundDepartureDate: t ? (g = (_ = t.segments) == null ? void 0 : _[0]) == null ? void 0 : g.departing_at : void 0,
126
- inboundDeparture: t ? { airportCode: t.origin, location: "" } : void 0,
127
- inboundArrival: t ? { airportCode: t.destination, location: "" } : void 0
124
+ outboundArrivalDate: t.arriving_at ?? ((l = (c = t.segments) == null ? void 0 : c.getLast()) == null ? void 0 : l.arriving_at),
125
+ inboundDepartureDate: s ? s.departing_at ?? ((g = (_ = s.segments) == null ? void 0 : _[0]) == null ? void 0 : g.departing_at) : void 0,
126
+ inboundDeparture: s ? { airportCode: s.origin, location: "" } : void 0,
127
+ inboundArrival: s ? { airportCode: s.destination, location: "" } : void 0
128
128
  });
129
129
  }), b = (r) => r.map(
130
130
  (e) => d({
@@ -13,7 +13,7 @@ import { awayzClient as o } from "../../configs/awayzClient.js";
13
13
  import "../../index-Cv-wvFlM.js";
14
14
  import "../../context/AwayzContext.js";
15
15
  /* empty css */
16
- import { T as n } from "../../TripsService-GImsS17_.js";
16
+ import { T as n } from "../../TripsService-CJxjOcrR.js";
17
17
  const b = ({
18
18
  tripId: t,
19
19
  tripDetails: s
@@ -1,5 +1,5 @@
1
1
  import { h as p } from "../../arrayExtensions-DlcBOj5a.js";
2
- import { D as f } from "../../TripsService-GImsS17_.js";
2
+ import { D as f } from "../../TripsService-CJxjOcrR.js";
3
3
  import "react";
4
4
  import { renderHook as o, waitFor as i } from "../../tests/TestWrapper.js";
5
5
  import { EMyTripsEndpoints as c } from "../../configs/endpoints.js";
@@ -1,6 +1,6 @@
1
1
  import { useQuery as n, useMutation as s } from "@tanstack/react-query";
2
2
  import "../../arrayExtensions-DlcBOj5a.js";
3
- import { E as a, d as u } from "../../noRetryInstance-DKhe8ju0.js";
3
+ import { E as a, d as m } from "../../noRetryInstance-DKhe8ju0.js";
4
4
  import "react";
5
5
  import "react/jsx-runtime";
6
6
  import "react-i18next";
@@ -11,25 +11,25 @@ import { awayzClient as i } from "../../configs/awayzClient.js";
11
11
  /* empty css */
12
12
  /* empty css */
13
13
  import "../../index-Cv-wvFlM.js";
14
- import { useAwayzContext as l } from "../useAwayzContext.js";
14
+ import { useAwayzContext as c } from "../useAwayzContext.js";
15
15
  /* empty css */
16
16
  import "../../context/AwayzContext.js";
17
17
  import { WalletService as o } from "../../services/wallet/WalletService.js";
18
- const T = () => {
19
- const { user: r } = l(), { data: t } = n({
18
+ const x = () => {
19
+ const { user: e } = c(), { data: t } = n({
20
20
  queryKey: [a.PROGRAMS],
21
21
  queryFn: o.getAwards,
22
22
  placeholderData: []
23
- }), { data: c } = n({
24
- queryKey: [a.USER_PROGRAMS, r == null ? void 0 : r.id],
25
- queryFn: () => r != null && r.id ? o.getUserAwards(r.id) : [],
23
+ }), { data: l } = n({
24
+ queryKey: [a.USER_PROGRAMS, e == null ? void 0 : e.id],
25
+ queryFn: () => e != null && e.id ? o.getUserAwards(e.id) : [],
26
26
  placeholderData: [],
27
- enabled: !!(r != null && r.id)
27
+ enabled: !!(e != null && e.id)
28
28
  }), { data: y } = n({
29
- queryKey: [a.LINKED_USER_PROGRAMS, r == null ? void 0 : r.id],
30
- queryFn: () => r != null && r.id ? o.getLinkedUserAwards(r.id) : [],
29
+ queryKey: [a.LINKED_USER_PROGRAMS, e == null ? void 0 : e.id],
30
+ queryFn: () => e != null && e.id ? o.getLinkedUserAwards(e.id) : [],
31
31
  placeholderData: [],
32
- enabled: !!(r != null && r.id)
32
+ enabled: !!(e != null && e.id)
33
33
  }), { data: A } = n({
34
34
  queryKey: [a.BANKS],
35
35
  queryFn: o.getBanks,
@@ -42,55 +42,55 @@ const T = () => {
42
42
  queryKey: [a.USER_CARDS],
43
43
  queryFn: o.getUserCards,
44
44
  placeholderData: []
45
- }), { featureFlags: R, featureFlagsLoaded: S } = l(), { data: p } = n({
45
+ }), { featureFlags: R, featureFlagsLoaded: S, isAuthenticated: p } = c(), { data: C } = n({
46
46
  queryKey: [a.POINTS_AS_CASH],
47
47
  queryFn: o.getPointsAsCash,
48
48
  placeholderData: { availablePoints: 0, valuePerPoint: 0, currency: "" },
49
- enabled: S && R.usePointsAsCashFeature
50
- }), { mutate: C } = s({
51
- mutationFn: async (e) => {
52
- const { mainProgram: m, awardsAmount: d } = typeof e == "string" ? { mainProgram: e, awardsAmount: 0 } : e;
53
- await o.addAwardProgram(m, d);
49
+ enabled: S && R.usePointsAsCashFeature && p
50
+ }), { mutate: E } = s({
51
+ mutationFn: async (r) => {
52
+ const { mainProgram: u, awardsAmount: d } = typeof r == "string" ? { mainProgram: r, awardsAmount: 0 } : r;
53
+ await o.addAwardProgram(u, d);
54
54
  },
55
55
  onSuccess: () => {
56
56
  i.invalidateQueries({
57
57
  queryKey: [a.LINKED_USER_PROGRAMS]
58
58
  });
59
59
  }
60
- }), { mutate: E } = s({
61
- mutationFn: async (e) => {
62
- await o.removeAwardProgram(e);
60
+ }), { mutate: K } = s({
61
+ mutationFn: async (r) => {
62
+ await o.removeAwardProgram(r);
63
63
  },
64
64
  onSuccess: () => {
65
65
  i.invalidateQueries({
66
66
  queryKey: [a.LINKED_USER_PROGRAMS]
67
67
  });
68
68
  }
69
- }), { mutateAsync: K } = s({
70
- mutationFn: async ({ mainProgram: e, awardsAmount: m }) => {
71
- const d = t == null ? void 0 : t.find((F) => F.mainProgram === e);
69
+ }), { mutateAsync: f } = s({
70
+ mutationFn: async ({ mainProgram: r, awardsAmount: u }) => {
71
+ const d = t == null ? void 0 : t.find((h) => h.mainProgram === r);
72
72
  if (!d)
73
73
  throw new Error("Program not found");
74
- return o.setAwardPoints(d.mainProgram, m);
74
+ return o.setAwardPoints(d.mainProgram, u);
75
75
  },
76
76
  onSuccess: () => {
77
77
  [
78
78
  a.LINKED_USER_PROGRAMS,
79
79
  a.USER_PROGRAMS,
80
80
  a.PROGRAMS
81
- ].forEach((e) => {
82
- i.invalidateQueries({ queryKey: [e] });
81
+ ].forEach((r) => {
82
+ i.invalidateQueries({ queryKey: [r] });
83
83
  });
84
84
  }
85
- }), { mutateAsync: f } = s({
86
- mutationFn: async (e) => o.addCardsToWallet(e),
85
+ }), { mutateAsync: q } = s({
86
+ mutationFn: async (r) => o.addCardsToWallet(r),
87
87
  onSuccess: () => {
88
88
  i.invalidateQueries({
89
89
  queryKey: [a.USER_CARDS]
90
90
  });
91
91
  }
92
- }), { mutateAsync: q } = s({
93
- mutationFn: async (e) => o.removeCardsFromWallet(e),
92
+ }), { mutateAsync: F } = s({
93
+ mutationFn: async (r) => o.removeCardsFromWallet(r),
94
94
  onSuccess: () => {
95
95
  i.invalidateQueries({
96
96
  queryKey: [a.USER_CARDS]
@@ -100,27 +100,27 @@ const T = () => {
100
100
  return {
101
101
  // Program Management
102
102
  allPrograms: t || [],
103
- userPrograms: c || [],
103
+ userPrograms: l || [],
104
104
  linkedUserPrograms: y || [],
105
105
  hotelPrograms: (t == null ? void 0 : t.filter(
106
- (e) => e.category.includes(u.HOTEL)
106
+ (r) => r.category.includes(m.HOTEL)
107
107
  )) || [],
108
108
  airlinePrograms: (t == null ? void 0 : t.filter(
109
- (e) => e.category.includes(u.AIRLINE)
109
+ (r) => r.category.includes(m.AIRLINE)
110
110
  )) || [],
111
111
  bankPrograms: (t == null ? void 0 : t.filter(
112
- (e) => e.category.includes(u.BANK)
112
+ (r) => r.category.includes(m.BANK)
113
113
  )) || [],
114
- updatePoints: K,
115
- addAwardProgram: C,
116
- removeAwardProgram: E,
114
+ updatePoints: f,
115
+ addAwardProgram: E,
116
+ removeAwardProgram: K,
117
117
  // Card Management
118
118
  banks: A || [],
119
119
  allCards: P || [],
120
120
  userCards: g || [],
121
- addCards: f,
122
- removeCards: q,
123
- pointsAsCash: p || {
121
+ addCards: q,
122
+ removeCards: F,
123
+ pointsAsCash: C || {
124
124
  availablePoints: 0,
125
125
  valuePerPoint: 0,
126
126
  currency: ""
@@ -128,5 +128,5 @@ const T = () => {
128
128
  };
129
129
  };
130
130
  export {
131
- T as useWallet
131
+ x as useWallet
132
132
  };
@@ -1,6 +1,6 @@
1
1
  import "../../arrayExtensions-DlcBOj5a.js";
2
2
  import "../../noRetryInstance-DKhe8ju0.js";
3
- import { T } from "../../TripsService-GImsS17_.js";
3
+ import { T } from "../../TripsService-CJxjOcrR.js";
4
4
  import "react";
5
5
  import "../../configs/defaultAwayzConfig.js";
6
6
  import "../../configs/endpoints.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.9.21",
3
+ "version": "0.9.24",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"