@open-tender/cloud 0.1.45 → 0.1.47
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.
|
@@ -7,7 +7,7 @@ export interface ConfigState {
|
|
|
7
7
|
brand: ConfigBrand | null;
|
|
8
8
|
content: ConfigContent | null;
|
|
9
9
|
error: any;
|
|
10
|
-
|
|
10
|
+
isApp: boolean | undefined;
|
|
11
11
|
isBackgroundFetch: boolean;
|
|
12
12
|
loading: RequestStatus;
|
|
13
13
|
retries: number;
|
|
@@ -23,7 +23,7 @@ export declare const fetchConfig: import("@reduxjs/toolkit").AsyncThunk<ConfigSt
|
|
|
23
23
|
clientId?: string | undefined;
|
|
24
24
|
brandId?: string | undefined;
|
|
25
25
|
callback?: (() => void) | undefined;
|
|
26
|
-
|
|
26
|
+
isApp?: boolean | undefined;
|
|
27
27
|
}, {
|
|
28
28
|
state: AppState;
|
|
29
29
|
rejectValue: RequestError;
|
|
@@ -14,7 +14,7 @@ const initialState = {
|
|
|
14
14
|
brand: null,
|
|
15
15
|
content: null,
|
|
16
16
|
theme: null,
|
|
17
|
-
|
|
17
|
+
isApp: false,
|
|
18
18
|
isBackgroundFetch: false,
|
|
19
19
|
loading: 'idle',
|
|
20
20
|
error: null,
|
|
@@ -29,14 +29,15 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
|
|
|
29
29
|
try {
|
|
30
30
|
const api = new api_1.default(options);
|
|
31
31
|
const response = yield api.getConfig();
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
clientId
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const { baseUrl, authUrl, clientId, brandId, callback, isApp } = options;
|
|
33
|
+
const app = { baseUrl, authUrl, clientId, brandId };
|
|
34
|
+
if (!app.clientId)
|
|
35
|
+
app.clientId = response.clientId;
|
|
36
|
+
if (!app.brandId)
|
|
37
|
+
app.brandId = response.brand.brandId;
|
|
38
|
+
if (callback)
|
|
39
|
+
callback();
|
|
40
|
+
return Object.assign(Object.assign({}, response), { isApp, app });
|
|
40
41
|
}
|
|
41
42
|
catch (err) {
|
|
42
43
|
return rejectWithValue(err);
|
|
@@ -57,18 +58,12 @@ const configSlice = (0, toolkit_1.createSlice)({
|
|
|
57
58
|
extraReducers: builder => {
|
|
58
59
|
builder
|
|
59
60
|
.addCase(exports.fetchConfig.fulfilled, (state, action) => {
|
|
60
|
-
const { app, brand, content, theme, settings } = action.payload;
|
|
61
|
-
const isApp = action.meta.arg.isMobile;
|
|
61
|
+
const { app, isApp, brand, content, theme, settings } = action.payload;
|
|
62
62
|
state.app = app;
|
|
63
|
-
state.appTheme = isApp && theme ? (0, utils_1.decorateTheme)(theme) : null;
|
|
64
63
|
state.brand = brand;
|
|
65
64
|
state.content = content;
|
|
66
65
|
state.theme = !isApp && theme ? theme : null;
|
|
67
|
-
|
|
68
|
-
// ? action.meta.arg.isMobile
|
|
69
|
-
// ? decorateTheme(theme as Theme)
|
|
70
|
-
// : theme
|
|
71
|
-
// : null
|
|
66
|
+
state.appTheme = isApp && theme ? (0, utils_1.decorateTheme)(theme) : null;
|
|
72
67
|
state.settings = settings;
|
|
73
68
|
state.loading = 'idle';
|
|
74
69
|
state.api = new api_1.default(app);
|
|
@@ -7,7 +7,7 @@ export interface ConfigState {
|
|
|
7
7
|
brand: ConfigBrand | null;
|
|
8
8
|
content: ConfigContent | null;
|
|
9
9
|
error: any;
|
|
10
|
-
|
|
10
|
+
isApp: boolean | undefined;
|
|
11
11
|
isBackgroundFetch: boolean;
|
|
12
12
|
loading: RequestStatus;
|
|
13
13
|
retries: number;
|
|
@@ -23,7 +23,7 @@ export declare const fetchConfig: import("@reduxjs/toolkit").AsyncThunk<ConfigSt
|
|
|
23
23
|
clientId?: string | undefined;
|
|
24
24
|
brandId?: string | undefined;
|
|
25
25
|
callback?: (() => void) | undefined;
|
|
26
|
-
|
|
26
|
+
isApp?: boolean | undefined;
|
|
27
27
|
}, {
|
|
28
28
|
state: AppState;
|
|
29
29
|
rejectValue: RequestError;
|
|
@@ -10,7 +10,7 @@ const initialState = {
|
|
|
10
10
|
brand: null,
|
|
11
11
|
content: null,
|
|
12
12
|
theme: null,
|
|
13
|
-
|
|
13
|
+
isApp: false,
|
|
14
14
|
isBackgroundFetch: false,
|
|
15
15
|
loading: 'idle',
|
|
16
16
|
error: null,
|
|
@@ -25,14 +25,15 @@ export const fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, (optio
|
|
|
25
25
|
try {
|
|
26
26
|
const api = new OpenTenderAPI(options);
|
|
27
27
|
const response = yield api.getConfig();
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
clientId
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const { baseUrl, authUrl, clientId, brandId, callback, isApp } = options;
|
|
29
|
+
const app = { baseUrl, authUrl, clientId, brandId };
|
|
30
|
+
if (!app.clientId)
|
|
31
|
+
app.clientId = response.clientId;
|
|
32
|
+
if (!app.brandId)
|
|
33
|
+
app.brandId = response.brand.brandId;
|
|
34
|
+
if (callback)
|
|
35
|
+
callback();
|
|
36
|
+
return Object.assign(Object.assign({}, response), { isApp, app });
|
|
36
37
|
}
|
|
37
38
|
catch (err) {
|
|
38
39
|
return rejectWithValue(err);
|
|
@@ -53,18 +54,12 @@ const configSlice = createSlice({
|
|
|
53
54
|
extraReducers: builder => {
|
|
54
55
|
builder
|
|
55
56
|
.addCase(fetchConfig.fulfilled, (state, action) => {
|
|
56
|
-
const { app, brand, content, theme, settings } = action.payload;
|
|
57
|
-
const isApp = action.meta.arg.isMobile;
|
|
57
|
+
const { app, isApp, brand, content, theme, settings } = action.payload;
|
|
58
58
|
state.app = app;
|
|
59
|
-
state.appTheme = isApp && theme ? decorateTheme(theme) : null;
|
|
60
59
|
state.brand = brand;
|
|
61
60
|
state.content = content;
|
|
62
61
|
state.theme = !isApp && theme ? theme : null;
|
|
63
|
-
|
|
64
|
-
// ? action.meta.arg.isMobile
|
|
65
|
-
// ? decorateTheme(theme as Theme)
|
|
66
|
-
// : theme
|
|
67
|
-
// : null
|
|
62
|
+
state.appTheme = isApp && theme ? decorateTheme(theme) : null;
|
|
68
63
|
state.settings = settings;
|
|
69
64
|
state.loading = 'idle';
|
|
70
65
|
state.api = new OpenTenderAPI(app);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/cloud",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
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",
|