@@ -6,17 +6,19 @@ import axios from "axios";
6
6
import { isEnableSubscription , themeColor } from "../constant/const" ;
7
7
import { contractUsers , getAppLogo } from "../constant/Utils" ;
8
8
import logo from "../assets/images/logo.png" ;
9
+ import { appInfo } from "../constant/appinfo" ;
9
10
10
11
function GuestLogin ( ) {
11
- const { id, userMail, contactBookId, serverUrl } = useParams ( ) ;
12
+ const { id, userMail, contactBookId, base64url } = useParams ( ) ;
12
13
let navigate = useNavigate ( ) ;
13
14
const [ email , setEmail ] = useState ( userMail ) ;
14
15
const [ OTP , setOTP ] = useState ( "" ) ;
15
16
const [ EnterOTP , setEnterOtp ] = useState ( false ) ;
16
17
const [ loading , setLoading ] = useState ( false ) ;
17
18
const [ isLoading , setIsLoading ] = useState ( true ) ;
18
19
const [ appLogo , setAppLogo ] = useState ( "" ) ;
19
-
20
+ const [ documentId , setDocumentId ] = useState ( id ) ;
21
+ const [ contactId , setContactId ] = useState ( contactBookId ) ;
20
22
useEffect ( ( ) => {
21
23
handleServerUrl ( ) ;
22
24
@@ -36,17 +38,24 @@ function GuestLogin() {
36
38
setAppLogo ( logo ) ;
37
39
}
38
40
39
- //split url in array from '&'
40
41
localStorage . clear ( ) ;
41
- const checkSplit = serverUrl . split ( "&" ) ;
42
- const server = checkSplit [ 0 ] ;
43
- const parseId = checkSplit [ 1 ] ;
44
- const appName = checkSplit [ 2 ] ;
45
-
46
- const newServer = server . replaceAll ( "%2F" , "/" ) ;
42
+ const parseId = appInfo . appId ;
43
+ const newServer = `${ appInfo . baseUrl } /` ;
44
+ const appName = appInfo . appname ;
47
45
localStorage . setItem ( "baseUrl" , newServer ) ;
48
46
localStorage . setItem ( "parseAppId" , parseId ) ;
49
47
localStorage . setItem ( "_appName" , appName ) ;
48
+ //this condition is used decode base64 to string and get userEmail,documentId, contactBoookId data.
49
+ if ( ! id ) {
50
+ //`atob` function is used to decode base64
51
+ const decodebase64 = atob ( base64url ) ;
52
+ //split url in array from '/'
53
+ const checkSplit = decodebase64 . split ( "/" ) ;
54
+ setDocumentId ( checkSplit [ 0 ] ) ;
55
+ setEmail ( checkSplit [ 1 ] ) ;
56
+ setContactId ( checkSplit [ 2 ] ) ;
57
+ }
58
+
50
59
setIsLoading ( false ) ;
51
60
} ;
52
61
@@ -74,7 +83,7 @@ function GuestLogin() {
74
83
} ;
75
84
let body = {
76
85
email : email . toString ( ) ,
77
- docId : id
86
+ docId : documentId
78
87
} ;
79
88
let Otp = await axios . post ( url , body , { headers : headers } ) ;
80
89
@@ -137,7 +146,7 @@ function GuestLogin() {
137
146
//save isGuestSigner true in local to handle login flow header in mobile view
138
147
localStorage . setItem ( "isGuestSigner" , true ) ;
139
148
setLoading ( false ) ;
140
- navigate ( `/load/recipientSignPdf/${ id } /${ contactBookId } ` ) ;
149
+ navigate ( `/load/recipientSignPdf/${ documentId } /${ contactId } ` ) ;
141
150
}
142
151
} catch ( error ) {
143
152
console . log ( "err " , error ) ;
0 commit comments