@@ -6,26 +6,12 @@ import Congratulations from "./components/Congratulations";
6
6
import Section from "./components/Section" ;
7
7
import ProveEligibility from "./components/ProveEligibility" ;
8
8
import Button from "@/src/ui/Button" ;
9
- import { ZkCustomAppConfig } from "@/space-config/types" ;
9
+ import { CustomAppConfig } from "@/space-config/types" ;
10
10
import Button3D from "@/src/ui/Button3D" ;
11
11
import { useRouter } from "next/navigation" ;
12
12
import { worldcoinConfigMain } from "../main" ;
13
13
import { CredentialType , IDKitWidget } from "@worldcoin/idkit" ;
14
- import { ZkCustomAppContainer } from "@/src/components/ZkCustomAppContainer" ;
15
-
16
- const Title = styled . div `
17
- margin-bottom: 16px;
18
- font-family: ${ props => props . theme . fonts . semibold } ;
19
- color: ${ props => props . theme . colors . neutral1 } ;
20
- font-size: 32px;
21
- `
22
-
23
- const Description = styled . div `
24
- margin-bottom: 32px;
25
- font-family: ${ props => props . theme . fonts . regular } ;
26
- color: ${ props => props . theme . colors . neutral3 } ;
27
- font-size: 16px;
28
- `
14
+ import { CustomAppContainer } from "@/src/components/CustomAppContainer" ;
29
15
30
16
const AlreadyRegistered = styled . div `
31
17
color: ${ props => props . theme . colors . neutral1 } ;
@@ -40,10 +26,6 @@ const AlreadyRegistered = styled.div`
40
26
border-radius: 4px;
41
27
`
42
28
43
- const Content = styled . div `
44
- max-width: 580px;
45
- `
46
-
47
29
const Bottom = styled . div `
48
30
width: 100%;
49
31
display: flex;
@@ -55,25 +37,35 @@ const Bottom = styled.div`
55
37
const ErrorMsg = styled . div `
56
38
color: ${ props => props . theme . colors . error } ;
57
39
font-family: ${ props => props . theme . fonts . regular } ;
40
+ position: absolute;
41
+ bottom: -35px;
42
+ left: 0px;
43
+ `
44
+
45
+ const Verifications = styled . div `
46
+ display: flex;
47
+ gap: 10px;
48
+ align-items: center;
49
+ margin-top: 24px;
58
50
`
59
51
60
52
export default function WorldcoinProofOfPersonhoodCustomApp ( ) : JSX . Element {
61
53
const router = useRouter ( ) ;
62
- const app = worldcoinConfigMain . apps [ 0 ] as ZkCustomAppConfig ;
63
- const api = app . templateConfig . extraData . api ;
54
+ const app = worldcoinConfigMain . apps [ 0 ] as CustomAppConfig ;
55
+ const api = app . templateConfig . api ;
64
56
const [ alreadySubscribed , setAlreadySubscribed ] = useState ( false ) ;
65
57
const [ domReady , setDomReady ] = React . useState ( false ) ;
66
- const [ verifying , setVerifying ] = useState ( false ) ;
67
58
const [ finished , setFinished ] = useState ( false ) ;
68
59
const [ error , setError ] = useState ( null ) ;
69
- const [ loading , setLoading ] = useState ( false ) ;
70
60
const [ redirect , setRedirect ] = useState ( null ) ;
61
+ const [ verifyingOrb , setVerifyingOrb ] = useState ( false ) ;
62
+ const [ verifyingPhone , setVerifyingPhone ] = useState ( false ) ;
71
63
72
64
const [ sismoResponse , setSismoResponse ] = useState ( null ) ;
73
65
74
- const onFinish = async ( worldcoinResult ) => {
75
- setVerifying ( true ) ;
76
- setLoading ( true ) ;
66
+ const onFinish = async ( worldcoinResult , type : "orb" | "phone" ) => {
67
+ if ( type === "orb" ) setVerifyingOrb ( true ) ;
68
+ if ( type === "phone" ) setVerifyingPhone ( true ) ;
77
69
const body = JSON . stringify ( {
78
70
result : worldcoinResult ,
79
71
response : sismoResponse
@@ -82,21 +74,20 @@ export default function WorldcoinProofOfPersonhoodCustomApp(): JSX.Element {
82
74
method : "POST" ,
83
75
body
84
76
} ) ;
85
- setVerifying ( false ) ;
86
- if ( ! res . ok ) {
87
- throw new Error ( "Error while verifying Worldcoin proof" ) ;
88
- }
77
+ setVerifyingOrb ( false ) ;
78
+ setVerifyingPhone ( false ) ;
89
79
const data = await res . json ( ) ;
80
+
90
81
if ( data . success ) {
91
82
setFinished ( true ) ;
92
83
}
93
84
94
85
switch ( data . code ) {
95
86
case "sismo-response-invalid" :
96
- setError ( "Server error [ Sismo response invalid] . Please contact us or retry later." ) ;
87
+ setError ( "Server error: Sismo response invalid. Please contact us or retry later." ) ;
97
88
break ;
98
89
case "worldcoin-result-invalid" :
99
- setError ( "Server error [ Worldcoin result invalid] . Please contact us or retry later." ) ;
90
+ setError ( "Server error: Worldcoin result invalid. Please contact us or retry later." ) ;
100
91
break ;
101
92
case "worldcoin-proof-already-verified" :
102
93
setAlreadySubscribed ( true ) ;
@@ -132,7 +123,7 @@ export default function WorldcoinProofOfPersonhoodCustomApp(): JSX.Element {
132
123
133
124
if ( ! domReady ) return ;
134
125
135
- return < ZkCustomAppContainer >
126
+ return < CustomAppContainer >
136
127
{
137
128
! finished && < >
138
129
< Section number = { 1 } isOpen = { ! sismoResponse } title = "Sign in with Sismo" style = { { marginBottom : 16 } } success = { Boolean ( sismoResponse ) } >
@@ -145,28 +136,39 @@ export default function WorldcoinProofOfPersonhoodCustomApp(): JSX.Element {
145
136
You already registered.
146
137
</ AlreadyRegistered >
147
138
:
148
- < >
139
+ < Verifications >
149
140
< IDKitWidget
150
141
app_id = "app_staging_9aa79aedb09dc9224e0b85c36133278b"
151
- action = "proof-of-personhood"
142
+ action = "proof-of-personhood-orb "
152
143
signal = "main"
153
- credential_types = { [ CredentialType . Phone , CredentialType . Orb ] }
154
- onSuccess = { ( result ) => onFinish ( result ) }
144
+ credential_types = { [ CredentialType . Orb ] }
145
+ onSuccess = { ( result ) => onFinish ( result , "orb" ) }
155
146
>
156
- { ( { open } ) => < Button onClick = { open } loading = { verifying || loading } style = { { width : "100%" , marginTop : 16 } } >
157
- { verifying ? "Verifying..." : "Prove you are unique " }
147
+ { ( { open } ) => < Button onClick = { open } loading = { verifyingOrb } style = { { width : "100%" } } >
148
+ { verifyingOrb ? "Verifying Biometric ..." : "Biometric verification " }
158
149
</ Button > }
159
150
</ IDKitWidget >
160
- {
161
- error &&
162
- < ErrorMsg >
163
- { error }
164
- </ ErrorMsg >
165
- }
166
- </ >
151
+ { /* <IDKitWidget
152
+ app_id="app_staging_9aa79aedb09dc9224e0b85c36133278b"
153
+ action="proof-of-personhood-phone"
154
+ signal="main"
155
+ credential_types={[CredentialType.Phone]}
156
+ onSuccess={(result) => onFinish(result, "phone")}
157
+ >
158
+ {({ open }) => <Button onClick={open} loading={verifyingPhone} style={{ width: "100%" }}>
159
+ {verifyingPhone ? "Verifying Biometric..." : "Phone verification" }
160
+ </Button>}
161
+ </IDKitWidget> */ }
162
+ </ Verifications >
163
+ }
164
+ {
165
+ error &&
166
+ < ErrorMsg >
167
+ { error }
168
+ </ ErrorMsg >
167
169
}
168
170
</ Section >
169
- { Boolean ( sismoResponse ) &&
171
+ { alreadySubscribed &&
170
172
< Bottom >
171
173
< Button3D onClick = { ( ) => redirect ? window . location . href : router . push ( `/${ worldcoinConfigMain . metadata . slug } ` ) } secondary >
172
174
{ redirect ? "Back to the Vault App" : "Back to the space" }
@@ -178,5 +180,5 @@ export default function WorldcoinProofOfPersonhoodCustomApp(): JSX.Element {
178
180
{
179
181
finished && < Congratulations app = { app } />
180
182
}
181
- </ ZkCustomAppContainer > ;
183
+ </ CustomAppContainer > ;
182
184
}
0 commit comments