|
|
@@ -8,9 +8,9 @@ import { Preferences } from '@capacitor/preferences';
|
|
8
|
8
|
|
|
9
|
9
|
|
|
10
|
10
|
export const TOKEN = '173cb9e357a861abd91e8008fab9246e0cc116af'
|
|
11
|
|
-//export const BASE_URL = 'http://192.168.1.35:8020/'
|
|
12
|
|
-export const BASE_URL = 'http://localhost:8020/'
|
|
13
|
|
-//export const BASE_URL = 'https://www.tigermuaythai.live/'
|
|
|
11
|
+
|
|
|
12
|
+//export const BASE_URL = 'http://localhost:8020/'
|
|
|
13
|
+export const BASE_URL = 'https://www.tigermuaythai.live/'
|
|
14
|
14
|
|
|
15
|
15
|
export const APPLE_CALLBACK = BASE_URL + "soc_accounts/apple/login/callback/";
|
|
16
|
16
|
//const axios = setupCache(Axios);
|
|
|
@@ -50,9 +50,9 @@ export const getToken = async () => {
|
|
50
|
50
|
console.log("get token ", data)
|
|
51
|
51
|
await Preferences.set({
|
|
52
|
52
|
key: 'token',
|
|
53
|
|
- value: data.token
|
|
|
53
|
+ value: data.key
|
|
54
|
54
|
})
|
|
55
|
|
- return data.token
|
|
|
55
|
+ return data.key
|
|
56
|
56
|
}else {
|
|
57
|
57
|
return token.value
|
|
58
|
58
|
}
|
|
|
@@ -64,16 +64,17 @@ export const initAPI = async () => {
|
|
64
|
64
|
console.log("-- cookie ---")
|
|
65
|
65
|
const cookieHeaders = r.headers['Set-Cookie'];
|
|
66
|
66
|
console.log(cookieHeaders)
|
|
|
67
|
+ return r;
|
|
67
|
68
|
}
|
|
68
|
69
|
export const setUserToken = async(token) => {
|
|
69
|
70
|
let data = await Preferences.set({
|
|
70
|
71
|
key: 'user_token',
|
|
71
|
72
|
value: token
|
|
72
|
73
|
})
|
|
73
|
|
- let data2 = await Preferences.set({
|
|
74
|
|
- key: 'token',
|
|
75
|
|
- value: token
|
|
76
|
|
- })
|
|
|
74
|
+ //let data2 = await Preferences.set({
|
|
|
75
|
+ //key: 'token',
|
|
|
76
|
+ //value: token
|
|
|
77
|
+ //})
|
|
77
|
78
|
return data
|
|
78
|
79
|
}
|
|
79
|
80
|
export const getTrainers = async () => {
|
|
|
@@ -148,8 +149,8 @@ export const getMat = async(pk) => {
|
|
148
|
149
|
}
|
|
149
|
150
|
|
|
150
|
151
|
export const storeAPNToken = async (device_token) => {
|
|
151
|
|
-
|
|
152
|
152
|
const token = await Preferences.get({ key: 'token' });
|
|
|
153
|
+ console.log('storeAPNToken ', token, device_token)
|
|
153
|
154
|
console.log("token = ", token)
|
|
154
|
155
|
const { data } = await axios.post(BASE_URL + "backend/api/device_tokens/",{token: device_token},
|
|
155
|
156
|
{
|
|
|
@@ -316,7 +317,8 @@ export const logout = async() => {
|
|
316
|
317
|
}
|
|
317
|
318
|
export const clearPref = async() => {
|
|
318
|
319
|
|
|
319
|
|
- const clear = await Preferences.clear()
|
|
|
320
|
+ //const clear = await Preferences.clear()
|
|
|
321
|
+ const clear = await Preferences.remove({key: 'user_token'})
|
|
320
|
322
|
return clear
|
|
321
|
323
|
}
|
|
322
|
324
|
export const isLogin = async() => {
|
|
|
@@ -356,7 +358,7 @@ export const resetPassword = async (email) => {
|
|
356
|
358
|
|
|
357
|
359
|
|
|
358
|
360
|
export const getPref = async () => {
|
|
359
|
|
- const token = await Preferences.get({ key: 'token' });
|
|
|
361
|
+ const token = await Preferences.get({ key: 'user_token' });
|
|
360
|
362
|
console.log("token = ", token)
|
|
361
|
363
|
const { data } = await axios.get(BASE_URL + `backend/api/profiles/myprofile/`, {
|
|
362
|
364
|
headers: {
|
|
|
@@ -371,7 +373,7 @@ export const getPref = async () => {
|
|
371
|
373
|
return data
|
|
372
|
374
|
}
|
|
373
|
375
|
export const likeCourse = async (cid) => {
|
|
374
|
|
- const token = await Preferences.get({ key: 'token' });
|
|
|
376
|
+ const token = await Preferences.get({ key: 'user_token' });
|
|
375
|
377
|
console.log("token = ", token)
|
|
376
|
378
|
const { data } = await axios.get(BASE_URL + `backend/api/profiles/like_course/?cid=${cid}`, {
|
|
377
|
379
|
headers: {
|
|
|
@@ -382,7 +384,7 @@ export const likeCourse = async (cid) => {
|
|
382
|
384
|
return data
|
|
383
|
385
|
}
|
|
384
|
386
|
export const likeMat = async (cid) => {
|
|
385
|
|
- const token = await Preferences.get({ key: 'token' });
|
|
|
387
|
+ const token = await Preferences.get({ key: 'user_token' });
|
|
386
|
388
|
console.log("token = ", token)
|
|
387
|
389
|
const { data } = await axios.get(BASE_URL + `backend/api/profiles/like_mat/?cid=${cid}`, {
|
|
388
|
390
|
headers: {
|
|
|
@@ -395,7 +397,7 @@ export const likeMat = async (cid) => {
|
|
395
|
397
|
|
|
396
|
398
|
|
|
397
|
399
|
export const updateNoti = async (noti) => {
|
|
398
|
|
- const token = await Preferences.get({ key: 'token' });
|
|
|
400
|
+ const token = await Preferences.get({ key: 'user_token' });
|
|
399
|
401
|
console.log("token = ", token)
|
|
400
|
402
|
const { data } = await axios.post(BASE_URL + `backend/api/profiles/update_noti/`,
|
|
401
|
403
|
{live_noti: noti.liveNoti, 'news_noti':noti.newsNoti},
|
|
|
@@ -410,7 +412,7 @@ export const updateNoti = async (noti) => {
|
|
410
|
412
|
|
|
411
|
413
|
export const appleLogin = async(access_token) => {
|
|
412
|
414
|
|
|
413
|
|
- const token = await Preferences.get({ key: 'token' });
|
|
|
415
|
+ const token = await Preferences.get({ key: 'user_token' });
|
|
414
|
416
|
console.log("access_code = ", access_token)
|
|
415
|
417
|
const { data } = await axios.post(BASE_URL + 'dj-rest-auth/apple/',{access_token: access_token.authorizationCode, id_token: access_token.identityToken}, {
|
|
416
|
418
|
headers: {
|