1
+ import { DeliveryServiceProfile } from "@dm3-org/dm3-lib-profile" ;
2
+ import { useEffect , useState } from "react" ;
3
+
1
4
interface ConfigureProfileProps {
2
5
ens : string ,
3
6
rpc : string ,
@@ -10,50 +13,110 @@ interface ConfigureProfileProps {
10
13
rpcError : string | null ,
11
14
urlError : string | null ,
12
15
isConnected : boolean ,
16
+ profile : DeliveryServiceProfile | undefined
13
17
}
14
18
15
19
export function ConfigureProfile ( props : ConfigureProfileProps ) {
16
20
17
- const isDisabled = ( ! props . isConnected || ! props . ens . length || ! props . url . length || ! props . rpc . length )
21
+ const [ showSuccessMsg , setShowSuccessMsg ] = useState < boolean > ( false ) ;
22
+
23
+ const isDisabled = ( ! props . isConnected || ! props . ens . length || ! props . url . length )
18
24
? true : false ;
19
25
20
- return < div >
21
- < h2 > Step 1: Create config and profile</ h2 >
26
+ // show success message of profile creation for 3 seconds & then clears the msg from UI
27
+ useEffect ( ( ) => {
28
+ if ( props . profile ) {
29
+ setShowSuccessMsg ( true ) ;
30
+ setTimeout ( ( ) => {
31
+ setShowSuccessMsg ( false ) ;
32
+ } , 3000 ) ;
33
+ }
34
+ } , [ props . profile ] )
35
+
36
+ return < div className = "description-text step" >
37
+
38
+ < h2 className = "heading-text" > Step 1: Create config and profile</ h2 >
22
39
To create the profile and config file, please connect the account
23
40
the delivery service will use. Also, we need this information:
24
- < p className = "config-profile-para" >
25
- ENS:
26
- < input
27
- value = { props . ens }
28
- onChange = { ( event ) => props . handleEnsChange ( event ) } />
29
- < b className = "mandatory" > *</ b >
30
- (the ens domain your delivery service will use, e.g.
31
- myPersonalDeliveryService.eth)
32
- </ p >
33
- { props . ensError && < span className = "error" > { props . ensError } </ span > }
34
- < p className = "config-profile-para" >
35
- URL:
36
- < input
37
- value = { props . url }
38
- onChange = { ( event ) => props . handleUrlChange ( event ) } />
39
- < b className = "mandatory" > *</ b >
40
- (the url your delivery service will use, e.g.
41
- https://my-personal-delivery-service.com)
42
- </ p >
43
- { props . urlError && < span className = "error" > { props . urlError } </ span > }
44
- < p className = "config-profile-para" >
45
- RPC:
46
- < input
47
- value = { props . rpc }
48
- onChange = { ( event ) => props . handleRpcChange ( event ) } />
49
- < b className = "mandatory" > *</ b >
50
- (the rpc url your delivery service will use, e.g.
51
- https://mainnet.infura.io/v3/f02ijf0283i0jq0jdoisjd07829)
52
- </ p >
53
- { props . rpcError && < span className = "error" > { props . rpcError } </ span > }
41
+
42
+ < div className = "base-input-container" >
43
+ { /* Error msg of ENS name */ }
44
+ < div className = "input-description" >
45
+ < span className = "input-heading-hidden" > ENS:</ span >
46
+ { props . ensError && < span className = "error" > { props . ensError } </ span > }
47
+ </ div >
48
+ { /* Input field to enter ENS name */ }
49
+ < div className = "input-container" >
50
+ < span className = "input-heading" > ENS:</ span >
51
+ < input
52
+ className = "input-field"
53
+ value = { props . ens }
54
+ onChange = { ( event ) => props . handleEnsChange ( event ) } />
55
+ </ div >
56
+ { /* Description content for ENS name */ }
57
+ < div className = "input-description" >
58
+ < span className = "input-heading-hidden" > ENS:</ span >
59
+ The ens domain your delivery service will use, e.g.
60
+ myPersonalDeliveryService.eth
61
+ </ div >
62
+ </ div >
63
+
64
+ < div className = "base-input-container" >
65
+ { /* Error msg of URL endpoint */ }
66
+ < div className = "input-description" >
67
+ < span className = "input-heading-hidden" > URL:</ span >
68
+ { props . urlError && < span className = "error" > { props . urlError } </ span > }
69
+ </ div >
70
+ { /* Input field to enter URL name */ }
71
+ < div className = "input-container" >
72
+ < span className = "input-heading" > URL:</ span >
73
+ < input
74
+ className = "input-field"
75
+ value = { props . url }
76
+ onChange = { ( event ) => props . handleUrlChange ( event ) } />
77
+ </ div >
78
+ { /* Description content for URL name */ }
79
+ < div className = "input-description" >
80
+ < span className = "input-heading-hidden" > URL:</ span >
81
+ The url your delivery service will use, e.g.
82
+ https://my-personal-delivery-service.com
83
+ </ div >
84
+ </ div >
85
+
86
+ < div className = "base-input-container" >
87
+ { /* Error msg of RPC endpoint */ }
88
+ < div className = "input-description" >
89
+ < span className = "input-heading-hidden" > RPC:</ span >
90
+ { props . rpcError && < span className = "error" > { props . rpcError } </ span > }
91
+ </ div >
92
+ { /* Input field to enter RPC name */ }
93
+ < div className = "input-container" >
94
+ < span className = "input-heading" > RPC:</ span >
95
+ < input
96
+ className = "input-field"
97
+ value = { props . rpc }
98
+ onChange = { ( event ) => props . handleRpcChange ( event ) } />
99
+ </ div >
100
+ { /* Description content for RPC name */ }
101
+ < div className = "input-description" >
102
+ < span className = "input-heading-hidden" > RPC:</ span >
103
+ The rpc url your delivery service will use, e.g.
104
+ https://mainnet.infura.io/v3/f02ijf0283i0jq0jdoisjd07829
105
+ RPC can be added later also to the dm3-ds.env file.
106
+ </ div >
107
+ </ div >
108
+
109
+ < div className = "input-description" >
110
+ < span className = "input-heading-hidden" > RPC:</ span >
111
+
112
+ { /* Success msg of profile creation */ }
113
+ { showSuccessMsg && < span className = "success" > Profile created successfully!</ span > }
114
+ </ div >
115
+
116
+ { /* Button to sign the profile */ }
54
117
< div >
55
118
< button
56
- className = " env-btn"
119
+ className = { "btn env-btn active-btn " . concat ( ( isDisabled ? "disabled-btn" : "" ) ) }
57
120
disabled = { isDisabled }
58
121
onClick = { ( ) => props . createConfigAndProfile ( ) } >
59
122
Create profile and .env
0 commit comments