@nuskin/ns-shop 7.4.0-pa-1.1 → 7.4.0-pa-1.2
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/package.json +1 -1
- package/src/account/agreementService.js +30 -21
package/package.json
CHANGED
|
@@ -1,35 +1,44 @@
|
|
|
1
1
|
import {UrlService} from "@nuskin/ns-util";
|
|
2
2
|
import axios from 'axios'
|
|
3
3
|
|
|
4
|
-
const downConvertAgreedToTerms = async (sapId
|
|
4
|
+
const downConvertAgreedToTerms = async (sapId) => {
|
|
5
5
|
let retVal = true;
|
|
6
|
+
const oktaTokens = sessionStorage.getItem("oktaTokens");
|
|
7
|
+
const { accessToken } = JSON.parse(oktaTokens);
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (accessToken) {
|
|
10
|
+
try {
|
|
11
|
+
const result = await axios.get(
|
|
12
|
+
`${UrlService.getApisUrl()}/account-enrollment/agreement-terms/${sapId}`,
|
|
13
|
+
{ headers: { Authorization: `Bearer ${accessToken}` } }
|
|
14
|
+
)
|
|
15
|
+
retVal = result?.data?.agreedTerms;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
console.error('agreement-terms check failed', e)
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
return retVal
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
const setDownConvertAgreedToTerms = async (sapId
|
|
24
|
+
const setDownConvertAgreedToTerms = async (sapId) => {
|
|
21
25
|
let succeeded = true
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const oktaTokens = sessionStorage.getItem("oktaTokens");
|
|
27
|
+
const { accessToken } = JSON.parse(oktaTokens);
|
|
28
|
+
|
|
29
|
+
if (accessToken) {
|
|
30
|
+
try {
|
|
31
|
+
await axios.post(`${UrlService.getApisUrl()}/account-enrollment/agreement-terms`,
|
|
32
|
+
{
|
|
33
|
+
agreedTerms: true,
|
|
34
|
+
sapId
|
|
35
|
+
},
|
|
36
|
+
{headers: {Authorization: `Bearer ${accessToken}`}}
|
|
37
|
+
)
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error('Failed setting agreement to terms', e);
|
|
40
|
+
succeeded = false;
|
|
41
|
+
}
|
|
33
42
|
}
|
|
34
43
|
return succeeded;
|
|
35
44
|
}
|