ordering-ui-react-native 0.14.34 → 0.14.35
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
CHANGED
|
@@ -11,7 +11,8 @@ export const FacebookLogin = (props: any) => {
|
|
|
11
11
|
const {
|
|
12
12
|
handleErrors,
|
|
13
13
|
handleLoading,
|
|
14
|
-
handleSuccessFacebookLogin
|
|
14
|
+
handleSuccessFacebookLogin,
|
|
15
|
+
notificationState
|
|
15
16
|
} = props
|
|
16
17
|
|
|
17
18
|
const [, t] = useLanguage()
|
|
@@ -30,7 +31,14 @@ export const FacebookLogin = (props: any) => {
|
|
|
30
31
|
|
|
31
32
|
const handleLoginClick = async (accessToken: string) => {
|
|
32
33
|
try {
|
|
33
|
-
const
|
|
34
|
+
const body: any = {
|
|
35
|
+
access_token: accessToken
|
|
36
|
+
}
|
|
37
|
+
if (notificationState?.notification_token) {
|
|
38
|
+
body.notification_token = notificationState.notification_token
|
|
39
|
+
body.notification_app = notificationState.notification_app
|
|
40
|
+
}
|
|
41
|
+
const response = await ordering.users().authFacebook(body)
|
|
34
42
|
if (!response.content.error) {
|
|
35
43
|
if (handleSuccessFacebookLogin) {
|
|
36
44
|
handleSuccessFacebookLogin(response.content.result)
|
|
@@ -38,9 +46,10 @@ export const FacebookLogin = (props: any) => {
|
|
|
38
46
|
}
|
|
39
47
|
} else {
|
|
40
48
|
handleLoading && handleLoading(false)
|
|
49
|
+
handleErrors && handleErrors(response.content.result)
|
|
41
50
|
logoutWithFacebook()
|
|
42
51
|
}
|
|
43
|
-
} catch (err) {
|
|
52
|
+
} catch (err: any) {
|
|
44
53
|
handleLoading && handleLoading(false)
|
|
45
54
|
handleErrors && handleErrors(err.message)
|
|
46
55
|
}
|
|
@@ -48,7 +57,7 @@ export const FacebookLogin = (props: any) => {
|
|
|
48
57
|
|
|
49
58
|
const loginWithFacebook = () => {
|
|
50
59
|
handleLoading && handleLoading(true)
|
|
51
|
-
LoginManager && LoginManager.logInWithPermissions(['public_profile']).then(
|
|
60
|
+
LoginManager && LoginManager.logInWithPermissions(['public_profile', 'email']).then(
|
|
52
61
|
(login: any) => {
|
|
53
62
|
if (login.isCancelled) {
|
|
54
63
|
const err = t('LOGIN_WITH_FACEBOOK_CANCELLED', 'Login cancelled')
|
|
@@ -58,6 +67,9 @@ export const FacebookLogin = (props: any) => {
|
|
|
58
67
|
AccessToken.getCurrentAccessToken().then((data: any) => {
|
|
59
68
|
const accessToken = data.accessToken.toString();
|
|
60
69
|
handleLoginClick(accessToken)
|
|
70
|
+
}).catch((err : any) => {
|
|
71
|
+
handleErrors && handleErrors(err.message)
|
|
72
|
+
handleLoading && handleLoading(false)
|
|
61
73
|
});
|
|
62
74
|
}
|
|
63
75
|
},
|
|
@@ -68,7 +80,10 @@ export const FacebookLogin = (props: any) => {
|
|
|
68
80
|
handleLoading && handleLoading(false)
|
|
69
81
|
handleErrors && handleErrors(err)
|
|
70
82
|
},
|
|
71
|
-
)
|
|
83
|
+
).catch((err : any) => {
|
|
84
|
+
handleErrors && handleErrors(err.message)
|
|
85
|
+
handleLoading && handleLoading(false)
|
|
86
|
+
});
|
|
72
87
|
};
|
|
73
88
|
|
|
74
89
|
const onPressButton = auth
|