@open-tender/cloud 0.1.110 → 0.1.112

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.
@@ -1,4 +1,4 @@
1
- import { Auth, ConfigApp, Customer, CustomerCreate, GroupOrder, GroupOrdersExpanded, OneTimePasscode, OrderType, RevenueCenterType, ServiceType, TPLSTerms, Weekday } from '@open-tender/types';
1
+ import { Auth, ConfigApp, Customer, CustomerCreate, CustomerSignIn, GroupOrder, GroupOrdersExpanded, OrderType, RevenueCenterType, ServiceType, TPLSTerms, Weekday } from '@open-tender/types';
2
2
  declare class OpenTenderAPI {
3
3
  brandId?: string;
4
4
  clientId?: string;
@@ -104,7 +104,7 @@ declare class OpenTenderAPI {
104
104
  getSubscriber(email: string): Promise<unknown>;
105
105
  postSubscriber(email: string): Promise<unknown>;
106
106
  postSignUp(data: CustomerCreate): Promise<Customer | null | undefined>;
107
- postOneTimePasscode(data: OneTimePasscode): Promise<void | Auth | null | undefined>;
107
+ postCustomerSignIn(data: CustomerSignIn): Promise<void | Auth | null | undefined>;
108
108
  postThanxLogin(email: string, origin?: string): Promise<unknown>;
109
109
  postThanxAuth(code: string, path: string, origin?: string): Promise<unknown>;
110
110
  postLogin(email: string, password: string): Promise<unknown>;
@@ -504,7 +504,7 @@ class OpenTenderAPI {
504
504
  postSignUp(data) {
505
505
  return this.request(`/customer`, 'POST', data);
506
506
  }
507
- postOneTimePasscode(data) {
507
+ postCustomerSignIn(data) {
508
508
  return this.request(`/customer/sign-in`, 'POST', data);
509
509
  }
510
510
  postThanxLogin(email, origin) {
@@ -6,6 +6,7 @@ export interface ConfigState {
6
6
  appTheme: AppTheme | null;
7
7
  brand: ConfigBrand | null;
8
8
  content: ConfigContent | null;
9
+ stylesheet: string | null;
9
10
  error: any;
10
11
  isApp: boolean | undefined;
11
12
  isBackgroundFetch: boolean;
@@ -41,6 +42,7 @@ export declare const selectBrand: (state: AppState) => ConfigBrand | null;
41
42
  export declare const selectTheme: (state: AppState) => Theme | null;
42
43
  export declare const selectContent: (state: AppState) => ConfigContent | null;
43
44
  export declare const selectSettings: (state: AppState) => ConfigSettings | null;
45
+ export declare const selectStylesheet: (state: AppState) => string | null;
44
46
  export declare const selectApi: (state: AppState) => any;
45
47
  export declare const selectAccountConfig: (state: AppState) => {
46
48
  addresses: import("@open-tender/types").ConfigContentField;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.configReducer = exports.selectCategoryType = exports.selectHasCatering = exports.selectOutpostName = exports.selectHeaderHeight = exports.selectSoldOutMsg = exports.selectContentSection = exports.selectRecaptcha = exports.selectFulfillment = exports.selectOptIns = exports.selectLightColor = exports.selectConfigRetries = exports.selectDisplaySettings = exports.selectAccountConfig = exports.selectApi = exports.selectSettings = exports.selectContent = exports.selectTheme = exports.selectBrand = exports.selectConfig = exports.selectCateringOnly = exports.incrementRetries = exports.resetRetries = exports.resetConfig = exports.fetchConfig = exports.ConfigActionType = void 0;
4
+ exports.configReducer = exports.selectCategoryType = exports.selectHasCatering = exports.selectOutpostName = exports.selectHeaderHeight = exports.selectSoldOutMsg = exports.selectContentSection = exports.selectRecaptcha = exports.selectFulfillment = exports.selectOptIns = exports.selectLightColor = exports.selectConfigRetries = exports.selectDisplaySettings = exports.selectAccountConfig = exports.selectApi = exports.selectStylesheet = exports.selectSettings = exports.selectContent = exports.selectTheme = exports.selectBrand = exports.selectConfig = exports.selectCateringOnly = exports.incrementRetries = exports.resetRetries = exports.resetConfig = exports.fetchConfig = exports.ConfigActionType = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const toolkit_1 = require("@reduxjs/toolkit");
7
7
  const utils_1 = require("@open-tender/utils");
@@ -13,6 +13,7 @@ const initialState = {
13
13
  appTheme: null,
14
14
  brand: null,
15
15
  content: null,
16
+ stylesheet: null,
16
17
  theme: null,
17
18
  isApp: false,
18
19
  isBackgroundFetch: false,
@@ -58,13 +59,14 @@ const configSlice = (0, toolkit_1.createSlice)({
58
59
  extraReducers: builder => {
59
60
  builder
60
61
  .addCase(exports.fetchConfig.fulfilled, (state, action) => {
61
- const { app, isApp, brand, content, theme, settings } = action.payload;
62
+ const { app, isApp, brand, content, theme, settings, stylesheet } = action.payload;
62
63
  state.app = app;
63
64
  state.brand = brand;
64
65
  state.content = content;
65
66
  state.theme = !isApp && theme ? theme : null;
66
67
  state.appTheme = isApp && theme ? (0, utils_1.decorateTheme)(theme) : null;
67
68
  state.settings = settings;
69
+ state.stylesheet = stylesheet;
68
70
  state.loading = 'idle';
69
71
  state.api = new api_1.default(app);
70
72
  state.error = null;
@@ -97,6 +99,8 @@ const selectContent = (state) => state.config.content;
97
99
  exports.selectContent = selectContent;
98
100
  const selectSettings = (state) => state.config.settings;
99
101
  exports.selectSettings = selectSettings;
102
+ const selectStylesheet = (state) => state.config.stylesheet;
103
+ exports.selectStylesheet = selectStylesheet;
100
104
  const selectApi = (state) => state.config.api;
101
105
  exports.selectApi = selectApi;
102
106
  const selectAccountConfig = (state) => { var _a; return (_a = state.config.content) === null || _a === void 0 ? void 0 : _a.account; };
@@ -1,15 +1,29 @@
1
1
  import { AppState } from '../app';
2
- import { OneTimePasscode, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { CustomerSignIn, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface OneTimePasscodeState {
4
4
  otpSent: boolean;
5
5
  loading: RequestStatus;
6
6
  error: RequestError;
7
7
  }
8
8
  export declare enum OneTimePasscodeActionType {
9
- OneTimePasscodeCustomer = "oneTimePasscode/oneTimePasscodeCustomer"
9
+ OneTimePasscodeCustomer = "oneTimePasscode/oneTimePasscodeCustomer",
10
+ SignInCustomer = "oneTimePasscode/signInCustomer"
10
11
  }
11
12
  export declare const sendOneTimePasscode: import("@reduxjs/toolkit").AsyncThunk<boolean, {
12
- data: OneTimePasscode;
13
+ data: CustomerSignIn;
14
+ callback?: (() => void) | undefined;
15
+ }, {
16
+ state: AppState;
17
+ rejectValue: RequestError;
18
+ dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
19
+ extra?: unknown;
20
+ serializedErrorType?: unknown;
21
+ pendingMeta?: unknown;
22
+ fulfilledMeta?: unknown;
23
+ rejectedMeta?: unknown;
24
+ }>;
25
+ export declare const signInCustomer: import("@reduxjs/toolkit").AsyncThunk<void, {
26
+ data: CustomerSignIn;
13
27
  callback?: (() => void) | undefined;
14
28
  }, {
15
29
  state: AppState;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.oneTimePasscodeReducer = exports.selectOneTimePasscode = exports.toggleOtpSent = exports.resetOneTimePasscode = exports.sendOneTimePasscode = exports.OneTimePasscodeActionType = void 0;
4
+ exports.oneTimePasscodeReducer = exports.selectOneTimePasscode = exports.toggleOtpSent = exports.resetOneTimePasscode = exports.signInCustomer = exports.sendOneTimePasscode = exports.OneTimePasscodeActionType = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const toolkit_1 = require("@reduxjs/toolkit");
7
7
  const types_1 = require("./types");
@@ -14,11 +14,12 @@ const initialState = {
14
14
  var OneTimePasscodeActionType;
15
15
  (function (OneTimePasscodeActionType) {
16
16
  OneTimePasscodeActionType["OneTimePasscodeCustomer"] = "oneTimePasscode/oneTimePasscodeCustomer";
17
+ OneTimePasscodeActionType["SignInCustomer"] = "oneTimePasscode/signInCustomer";
17
18
  })(OneTimePasscodeActionType = exports.OneTimePasscodeActionType || (exports.OneTimePasscodeActionType = {}));
18
19
  exports.sendOneTimePasscode = (0, toolkit_1.createAsyncThunk)(OneTimePasscodeActionType.OneTimePasscodeCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
19
20
  try {
20
21
  const api = getState().config.api;
21
- const response = yield api.postOneTimePasscode(data);
22
+ const response = yield api.postCustomerSignIn(data);
22
23
  if (data.one_time_passcode) {
23
24
  dispatch((0, customer_1.setCustomerAuth)(response));
24
25
  yield dispatch((0, customer_1.fetchCustomer)());
@@ -34,6 +35,20 @@ exports.sendOneTimePasscode = (0, toolkit_1.createAsyncThunk)(OneTimePasscodeAct
34
35
  return rejectWithValue(err);
35
36
  }
36
37
  }));
38
+ exports.signInCustomer = (0, toolkit_1.createAsyncThunk)(OneTimePasscodeActionType.SignInCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
39
+ try {
40
+ const api = getState().config.api;
41
+ const response = yield api.postCustomerSignIn(data);
42
+ dispatch((0, customer_1.setCustomerAuth)(response));
43
+ yield dispatch((0, customer_1.fetchCustomer)());
44
+ if (callback)
45
+ callback();
46
+ return;
47
+ }
48
+ catch (err) {
49
+ return rejectWithValue(err);
50
+ }
51
+ }));
37
52
  const oneTimePasscodeSlice = (0, toolkit_1.createSlice)({
38
53
  name: types_1.ReducerType.OneTimePasscode,
39
54
  initialState,
@@ -56,6 +71,17 @@ const oneTimePasscodeSlice = (0, toolkit_1.createSlice)({
56
71
  .addCase(exports.sendOneTimePasscode.rejected, (state, action) => {
57
72
  state.loading = 'idle';
58
73
  state.error = action.payload;
74
+ })
75
+ .addCase(exports.signInCustomer.fulfilled, state => {
76
+ state.loading = 'idle';
77
+ state.error = null;
78
+ })
79
+ .addCase(exports.signInCustomer.pending, state => {
80
+ state.loading = 'pending';
81
+ })
82
+ .addCase(exports.signInCustomer.rejected, (state, action) => {
83
+ state.loading = 'idle';
84
+ state.error = action.payload;
59
85
  });
60
86
  }
61
87
  });
@@ -1,4 +1,4 @@
1
- import { Auth, ConfigApp, Customer, CustomerCreate, GroupOrder, GroupOrdersExpanded, OneTimePasscode, OrderType, RevenueCenterType, ServiceType, TPLSTerms, Weekday } from '@open-tender/types';
1
+ import { Auth, ConfigApp, Customer, CustomerCreate, CustomerSignIn, GroupOrder, GroupOrdersExpanded, OrderType, RevenueCenterType, ServiceType, TPLSTerms, Weekday } from '@open-tender/types';
2
2
  declare class OpenTenderAPI {
3
3
  brandId?: string;
4
4
  clientId?: string;
@@ -104,7 +104,7 @@ declare class OpenTenderAPI {
104
104
  getSubscriber(email: string): Promise<unknown>;
105
105
  postSubscriber(email: string): Promise<unknown>;
106
106
  postSignUp(data: CustomerCreate): Promise<Customer | null | undefined>;
107
- postOneTimePasscode(data: OneTimePasscode): Promise<void | Auth | null | undefined>;
107
+ postCustomerSignIn(data: CustomerSignIn): Promise<void | Auth | null | undefined>;
108
108
  postThanxLogin(email: string, origin?: string): Promise<unknown>;
109
109
  postThanxAuth(code: string, path: string, origin?: string): Promise<unknown>;
110
110
  postLogin(email: string, password: string): Promise<unknown>;
@@ -502,7 +502,7 @@ class OpenTenderAPI {
502
502
  postSignUp(data) {
503
503
  return this.request(`/customer`, 'POST', data);
504
504
  }
505
- postOneTimePasscode(data) {
505
+ postCustomerSignIn(data) {
506
506
  return this.request(`/customer/sign-in`, 'POST', data);
507
507
  }
508
508
  postThanxLogin(email, origin) {
@@ -6,6 +6,7 @@ export interface ConfigState {
6
6
  appTheme: AppTheme | null;
7
7
  brand: ConfigBrand | null;
8
8
  content: ConfigContent | null;
9
+ stylesheet: string | null;
9
10
  error: any;
10
11
  isApp: boolean | undefined;
11
12
  isBackgroundFetch: boolean;
@@ -41,6 +42,7 @@ export declare const selectBrand: (state: AppState) => ConfigBrand | null;
41
42
  export declare const selectTheme: (state: AppState) => Theme | null;
42
43
  export declare const selectContent: (state: AppState) => ConfigContent | null;
43
44
  export declare const selectSettings: (state: AppState) => ConfigSettings | null;
45
+ export declare const selectStylesheet: (state: AppState) => string | null;
44
46
  export declare const selectApi: (state: AppState) => any;
45
47
  export declare const selectAccountConfig: (state: AppState) => {
46
48
  addresses: import("@open-tender/types").ConfigContentField;
@@ -9,6 +9,7 @@ const initialState = {
9
9
  appTheme: null,
10
10
  brand: null,
11
11
  content: null,
12
+ stylesheet: null,
12
13
  theme: null,
13
14
  isApp: false,
14
15
  isBackgroundFetch: false,
@@ -54,13 +55,14 @@ const configSlice = createSlice({
54
55
  extraReducers: builder => {
55
56
  builder
56
57
  .addCase(fetchConfig.fulfilled, (state, action) => {
57
- const { app, isApp, brand, content, theme, settings } = action.payload;
58
+ const { app, isApp, brand, content, theme, settings, stylesheet } = action.payload;
58
59
  state.app = app;
59
60
  state.brand = brand;
60
61
  state.content = content;
61
62
  state.theme = !isApp && theme ? theme : null;
62
63
  state.appTheme = isApp && theme ? decorateTheme(theme) : null;
63
64
  state.settings = settings;
65
+ state.stylesheet = stylesheet;
64
66
  state.loading = 'idle';
65
67
  state.api = new OpenTenderAPI(app);
66
68
  state.error = null;
@@ -87,6 +89,7 @@ export const selectBrand = (state) => state.config.brand;
87
89
  export const selectTheme = (state) => state.config.theme;
88
90
  export const selectContent = (state) => state.config.content;
89
91
  export const selectSettings = (state) => state.config.settings;
92
+ export const selectStylesheet = (state) => state.config.stylesheet;
90
93
  export const selectApi = (state) => state.config.api;
91
94
  export const selectAccountConfig = (state) => { var _a; return (_a = state.config.content) === null || _a === void 0 ? void 0 : _a.account; };
92
95
  export const selectDisplaySettings = (state) => {
@@ -1,15 +1,29 @@
1
1
  import { AppState } from '../app';
2
- import { OneTimePasscode, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { CustomerSignIn, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface OneTimePasscodeState {
4
4
  otpSent: boolean;
5
5
  loading: RequestStatus;
6
6
  error: RequestError;
7
7
  }
8
8
  export declare enum OneTimePasscodeActionType {
9
- OneTimePasscodeCustomer = "oneTimePasscode/oneTimePasscodeCustomer"
9
+ OneTimePasscodeCustomer = "oneTimePasscode/oneTimePasscodeCustomer",
10
+ SignInCustomer = "oneTimePasscode/signInCustomer"
10
11
  }
11
12
  export declare const sendOneTimePasscode: import("@reduxjs/toolkit").AsyncThunk<boolean, {
12
- data: OneTimePasscode;
13
+ data: CustomerSignIn;
14
+ callback?: (() => void) | undefined;
15
+ }, {
16
+ state: AppState;
17
+ rejectValue: RequestError;
18
+ dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
19
+ extra?: unknown;
20
+ serializedErrorType?: unknown;
21
+ pendingMeta?: unknown;
22
+ fulfilledMeta?: unknown;
23
+ rejectedMeta?: unknown;
24
+ }>;
25
+ export declare const signInCustomer: import("@reduxjs/toolkit").AsyncThunk<void, {
26
+ data: CustomerSignIn;
13
27
  callback?: (() => void) | undefined;
14
28
  }, {
15
29
  state: AppState;
@@ -10,11 +10,12 @@ const initialState = {
10
10
  export var OneTimePasscodeActionType;
11
11
  (function (OneTimePasscodeActionType) {
12
12
  OneTimePasscodeActionType["OneTimePasscodeCustomer"] = "oneTimePasscode/oneTimePasscodeCustomer";
13
+ OneTimePasscodeActionType["SignInCustomer"] = "oneTimePasscode/signInCustomer";
13
14
  })(OneTimePasscodeActionType || (OneTimePasscodeActionType = {}));
14
15
  export const sendOneTimePasscode = createAsyncThunk(OneTimePasscodeActionType.OneTimePasscodeCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
15
16
  try {
16
17
  const api = getState().config.api;
17
- const response = yield api.postOneTimePasscode(data);
18
+ const response = yield api.postCustomerSignIn(data);
18
19
  if (data.one_time_passcode) {
19
20
  dispatch(setCustomerAuth(response));
20
21
  yield dispatch(fetchCustomer());
@@ -30,6 +31,20 @@ export const sendOneTimePasscode = createAsyncThunk(OneTimePasscodeActionType.On
30
31
  return rejectWithValue(err);
31
32
  }
32
33
  }));
34
+ export const signInCustomer = createAsyncThunk(OneTimePasscodeActionType.SignInCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
35
+ try {
36
+ const api = getState().config.api;
37
+ const response = yield api.postCustomerSignIn(data);
38
+ dispatch(setCustomerAuth(response));
39
+ yield dispatch(fetchCustomer());
40
+ if (callback)
41
+ callback();
42
+ return;
43
+ }
44
+ catch (err) {
45
+ return rejectWithValue(err);
46
+ }
47
+ }));
33
48
  const oneTimePasscodeSlice = createSlice({
34
49
  name: ReducerType.OneTimePasscode,
35
50
  initialState,
@@ -52,6 +67,17 @@ const oneTimePasscodeSlice = createSlice({
52
67
  .addCase(sendOneTimePasscode.rejected, (state, action) => {
53
68
  state.loading = 'idle';
54
69
  state.error = action.payload;
70
+ })
71
+ .addCase(signInCustomer.fulfilled, state => {
72
+ state.loading = 'idle';
73
+ state.error = null;
74
+ })
75
+ .addCase(signInCustomer.pending, state => {
76
+ state.loading = 'pending';
77
+ })
78
+ .addCase(signInCustomer.rejected, (state, action) => {
79
+ state.loading = 'idle';
80
+ state.error = action.payload;
55
81
  });
56
82
  }
57
83
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.110",
3
+ "version": "0.1.112",
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",
@@ -49,8 +49,8 @@
49
49
  "typescript": "^4.8.2"
50
50
  },
51
51
  "peerDependencies": {
52
- "@open-tender/types": "^0.2.100",
53
- "@open-tender/utils": "^0.1.166",
52
+ "@open-tender/types": "^0.2.102",
53
+ "@open-tender/utils": "^0.1.171",
54
54
  "@reduxjs/toolkit": "^1.8.5",
55
55
  "react": "^18.2.0"
56
56
  }