-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconnect.tsx
More file actions
68 lines (61 loc) · 2.07 KB
/
Copy pathconnect.tsx
File metadata and controls
68 lines (61 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { useEffect, useState } from "react"
import { StyleSheet, useWindowDimensions } from "react-native"
import { SafeAreaView } from "react-native-safe-area-context"
import * as Linking from "expo-linking"
import { ConnectWidget } from "@mxenabled/react-native-widget-sdk"
import { fetchConnectWidgetUrl } from "../shared/api"
const styles = StyleSheet.create({
page: {
backgroundColor: "#ffffff",
paddingTop: 10,
},
})
export default function Connect() {
const clientRedirectUrl = Linking.createURL("connect")
const { height, width } = useWindowDimensions()
const [url, setUrl] = useState<string | null>(null)
useEffect(() => {
fetchConnectWidgetUrl(clientRedirectUrl).then((url) => {
setUrl(url)
})
}, [clientRedirectUrl])
return (
<SafeAreaView style={{ ...styles.page, height, width }}>
{url && (
<ConnectWidget
url={url}
onSsoUrlLoadError={(error) => {
console.error(`SSO URL load error: ${error}`)
}}
onMessage={(url) => {
console.log(`Got a message: ${url}`)
}}
onInvalidMessageError={(url, _error) => {
console.log(`Got an unknown message: ${url}`)
}}
onLoad={(_payload) => {
console.log("Widget is loading")
}}
onLoaded={(_payload) => {
console.log("Widget has loaded")
}}
onMemberConnected={(payload) => {
console.log(`Member connected with payload: ${JSON.stringify(payload)}`)
}}
onOAuthError={(payload) => {
console.log(`OAuth error with payload: ${JSON.stringify(payload)}`)
}}
onOAuthRequested={(payload) => {
console.log(`OAuth requested with URL: ${payload.url}`)
}}
onStepChange={(payload) => {
console.log(`Moving from ${payload.previous} to ${payload.current}`)
}}
onSelectedInstitution={(payload) => {
console.log(`Selecting ${payload.name}`)
}}
/>
)}
</SafeAreaView>
)
}