@open-tender/cloud 0.1.16 → 0.1.18

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.
@@ -16,7 +16,10 @@ export declare const fetchGuest: import("@reduxjs/toolkit").AsyncThunk<Partial<G
16
16
  callback?: (() => void) | undefined;
17
17
  }, {
18
18
  state: AppState;
19
- rejectValue: RequestError;
19
+ rejectValue: {
20
+ error: RequestError;
21
+ email: string;
22
+ };
20
23
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
21
24
  extra?: unknown;
22
25
  serializedErrorType?: unknown;
@@ -28,11 +31,13 @@ export declare const fetchGuestThanx: import("@reduxjs/toolkit").AsyncThunk<void
28
31
  email: string;
29
32
  }, {
30
33
  email: string;
31
- callback: (() => void) | null;
32
- origin?: string | undefined;
34
+ callback?: (() => void) | null | undefined;
33
35
  }, {
34
36
  state: AppState;
35
- rejectValue: RequestError;
37
+ rejectValue: {
38
+ error: RequestError;
39
+ email: string;
40
+ };
36
41
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
37
42
  extra?: unknown;
38
43
  serializedErrorType?: unknown;
@@ -17,32 +17,34 @@ var GuestActionType;
17
17
  GuestActionType["FetchGuest"] = "guest/fetchGuest";
18
18
  GuestActionType["FetchGuestThanx"] = "guest/fetchGuestThanx";
19
19
  })(GuestActionType = exports.GuestActionType || (exports.GuestActionType = {}));
20
- exports.fetchGuest = (0, toolkit_1.createAsyncThunk)(GuestActionType.FetchGuest, (requestData, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
20
+ exports.fetchGuest = (0, toolkit_1.createAsyncThunk)(GuestActionType.FetchGuest, ({ email, callback }, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
21
21
  const { api } = getState().config;
22
22
  if (!api)
23
23
  return;
24
24
  try {
25
- const response = yield api.getGuest(requestData.email);
26
- if (requestData.callback)
27
- requestData.callback();
25
+ const response = yield api.getGuest(email);
26
+ if (callback)
27
+ callback();
28
28
  return response;
29
29
  }
30
30
  catch (err) {
31
- return rejectWithValue(err);
31
+ const error = { error: err, email };
32
+ return rejectWithValue(error);
32
33
  }
33
34
  }));
34
- exports.fetchGuestThanx = (0, toolkit_1.createAsyncThunk)(GuestActionType.FetchGuestThanx, (requestData, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
35
+ exports.fetchGuestThanx = (0, toolkit_1.createAsyncThunk)(GuestActionType.FetchGuestThanx, ({ email, callback }, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
35
36
  const { api } = getState().config;
36
37
  if (!api)
37
38
  return;
38
39
  try {
39
- yield api.postThanxLogin(requestData.email, origin);
40
- if (requestData.callback)
41
- requestData.callback();
42
- return { email: requestData.email };
40
+ yield api.postThanxLogin(email);
41
+ if (callback)
42
+ callback();
43
+ return { email: email };
43
44
  }
44
45
  catch (err) {
45
- return rejectWithValue(err);
46
+ const error = { error: err, email };
47
+ return rejectWithValue(error);
46
48
  }
47
49
  }));
48
50
  const guestSlice = (0, toolkit_1.createSlice)({
@@ -68,10 +70,7 @@ const guestSlice = (0, toolkit_1.createSlice)({
68
70
  state.loading = 'pending';
69
71
  })
70
72
  .addCase(exports.fetchGuest.rejected, (state, action) => {
71
- state.error = action.payload;
72
- // state.email = action.payload?.email
73
- state.loading = 'idle';
74
- state.brands = null;
73
+ return Object.assign(Object.assign(Object.assign({}, state), { loading: 'idle', brands: null }), action.payload);
75
74
  })
76
75
  .addCase(exports.fetchGuestThanx.fulfilled, (state, action) => {
77
76
  return Object.assign(Object.assign(Object.assign({}, state), { loading: 'idle', errors: null, showMagicLink: true }), action.payload);
@@ -80,10 +79,7 @@ const guestSlice = (0, toolkit_1.createSlice)({
80
79
  state.loading = 'pending';
81
80
  })
82
81
  .addCase(exports.fetchGuestThanx.rejected, (state, action) => {
83
- state.error = action.payload;
84
- state.loading = 'idle';
85
- state.showMagicLink = false;
86
- state.brands = null;
82
+ return Object.assign(Object.assign(Object.assign({}, state), { loading: 'idle', showMagicLink: false, brands: null }), action.payload);
87
83
  });
88
84
  }
89
85
  });
@@ -16,7 +16,10 @@ export declare const fetchGuest: import("@reduxjs/toolkit").AsyncThunk<Partial<G
16
16
  callback?: (() => void) | undefined;
17
17
  }, {
18
18
  state: AppState;
19
- rejectValue: RequestError;
19
+ rejectValue: {
20
+ error: RequestError;
21
+ email: string;
22
+ };
20
23
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
21
24
  extra?: unknown;
22
25
  serializedErrorType?: unknown;
@@ -28,11 +31,13 @@ export declare const fetchGuestThanx: import("@reduxjs/toolkit").AsyncThunk<void
28
31
  email: string;
29
32
  }, {
30
33
  email: string;
31
- callback: (() => void) | null;
32
- origin?: string | undefined;
34
+ callback?: (() => void) | null | undefined;
33
35
  }, {
34
36
  state: AppState;
35
- rejectValue: RequestError;
37
+ rejectValue: {
38
+ error: RequestError;
39
+ email: string;
40
+ };
36
41
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
37
42
  extra?: unknown;
38
43
  serializedErrorType?: unknown;
@@ -13,32 +13,34 @@ export var GuestActionType;
13
13
  GuestActionType["FetchGuest"] = "guest/fetchGuest";
14
14
  GuestActionType["FetchGuestThanx"] = "guest/fetchGuestThanx";
15
15
  })(GuestActionType || (GuestActionType = {}));
16
- export const fetchGuest = createAsyncThunk(GuestActionType.FetchGuest, (requestData, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ export const fetchGuest = createAsyncThunk(GuestActionType.FetchGuest, ({ email, callback }, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
17
17
  const { api } = getState().config;
18
18
  if (!api)
19
19
  return;
20
20
  try {
21
- const response = yield api.getGuest(requestData.email);
22
- if (requestData.callback)
23
- requestData.callback();
21
+ const response = yield api.getGuest(email);
22
+ if (callback)
23
+ callback();
24
24
  return response;
25
25
  }
26
26
  catch (err) {
27
- return rejectWithValue(err);
27
+ const error = { error: err, email };
28
+ return rejectWithValue(error);
28
29
  }
29
30
  }));
30
- export const fetchGuestThanx = createAsyncThunk(GuestActionType.FetchGuestThanx, (requestData, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
31
+ export const fetchGuestThanx = createAsyncThunk(GuestActionType.FetchGuestThanx, ({ email, callback }, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
31
32
  const { api } = getState().config;
32
33
  if (!api)
33
34
  return;
34
35
  try {
35
- yield api.postThanxLogin(requestData.email, origin);
36
- if (requestData.callback)
37
- requestData.callback();
38
- return { email: requestData.email };
36
+ yield api.postThanxLogin(email);
37
+ if (callback)
38
+ callback();
39
+ return { email: email };
39
40
  }
40
41
  catch (err) {
41
- return rejectWithValue(err);
42
+ const error = { error: err, email };
43
+ return rejectWithValue(error);
42
44
  }
43
45
  }));
44
46
  const guestSlice = createSlice({
@@ -64,10 +66,7 @@ const guestSlice = createSlice({
64
66
  state.loading = 'pending';
65
67
  })
66
68
  .addCase(fetchGuest.rejected, (state, action) => {
67
- state.error = action.payload;
68
- // state.email = action.payload?.email
69
- state.loading = 'idle';
70
- state.brands = null;
69
+ return Object.assign(Object.assign(Object.assign({}, state), { loading: 'idle', brands: null }), action.payload);
71
70
  })
72
71
  .addCase(fetchGuestThanx.fulfilled, (state, action) => {
73
72
  return Object.assign(Object.assign(Object.assign({}, state), { loading: 'idle', errors: null, showMagicLink: true }), action.payload);
@@ -76,10 +75,7 @@ const guestSlice = createSlice({
76
75
  state.loading = 'pending';
77
76
  })
78
77
  .addCase(fetchGuestThanx.rejected, (state, action) => {
79
- state.error = action.payload;
80
- state.loading = 'idle';
81
- state.showMagicLink = false;
82
- state.brands = null;
78
+ return Object.assign(Object.assign(Object.assign({}, state), { loading: 'idle', showMagicLink: false, brands: null }), action.payload);
83
79
  });
84
80
  }
85
81
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",