1
- import React from "react" ;
2
- import * as Select from "@radix-ui/react-select " ;
3
- import classnames from "classnames " ;
1
+ import React , { useState } from "react" ;
2
+ import ModalUi from "../../premitives/ModalUi " ;
3
+ import RecipientList from "../../premitives/RecipientList " ;
4
4
5
5
function FieldsComponent ( {
6
6
pdfUrl,
@@ -28,33 +28,20 @@ function FieldsComponent({
28
28
isSigners,
29
29
dataTut,
30
30
dataTut2,
31
- setIsShowEmail,
32
31
isMailSend,
33
- selectedEmail,
34
- setSelectedEmail,
35
32
handleAddSigner,
36
33
setUniqueId,
37
- setRoleName
34
+ setRoleName,
35
+ handleDeleteUser,
36
+ signerPos,
37
+ handleRoleChange,
38
+ handleOnBlur
38
39
} ) {
40
+ const [ isSignersModal , setIsSignersModal ] = useState ( false ) ;
39
41
const signStyle = pdfUrl ? "disableSign" : "signatureBtn" ;
40
42
41
43
const isMobile = window . innerWidth < 767 ;
42
44
43
- const SelectItem = React . forwardRef (
44
- ( { children, className, ...props } , forwardedRef ) => {
45
- return (
46
- < Select . Item
47
- className = { classnames ( "SelectItem" , className ) }
48
- { ...props }
49
- ref = { forwardedRef }
50
- >
51
- < Select . ItemText > { children } </ Select . ItemText >
52
- < Select . ItemIndicator className = "SelectItemIndicator" > </ Select . ItemIndicator >
53
- </ Select . Item >
54
- ) ;
55
- }
56
- ) ;
57
-
58
45
const color = [
59
46
"#93a3db" ,
60
47
"#e6c3db" ,
@@ -70,6 +57,9 @@ function FieldsComponent({
70
57
"#ffffcc"
71
58
] ;
72
59
60
+ const handleModal = ( ) => {
61
+ setIsSignersModal ( ! isSignersModal ) ;
62
+ } ;
73
63
return (
74
64
< >
75
65
{ isMobile && isSignYourself ? (
@@ -92,97 +82,24 @@ function FieldsComponent({
92
82
alignItems : "center" ,
93
83
justifyContent : "center"
94
84
} }
85
+ onClick = { ( ) => {
86
+ if ( signersdata ?. length ) {
87
+ handleModal ( ) ;
88
+ }
89
+ } }
95
90
>
96
91
< span style = { { fontSize : "13px" , fontWeight : "700" } } >
97
- Signer :
92
+ Recipient
93
+ </ span >
94
+ < span style = { { fontSize : "13px" , fontWeight : "700" } } >
95
+ { signersdata [ isSelectListId ] ?. Role && (
96
+ < div >
97
+ { signersdata [ isSelectListId ] ?. Name
98
+ ? ` : ${ signersdata [ isSelectListId ] ?. Name } `
99
+ : ` : ${ signersdata [ isSelectListId ] ?. Role } ` }
100
+ </ div >
101
+ ) }
98
102
</ span >
99
-
100
- < Select . Root
101
- onValueChange = { ( obj ) => {
102
- const [ selectedKey , selectedData ] = obj . split ( "|" ) ;
103
- const parseData = JSON . parse ( selectedData ) ;
104
-
105
- setSignerObjId ( parseData . objectId ) ;
106
- setIsSelectId ( selectedKey ) ;
107
- setContractName ( parseData . className ) ;
108
- setSelectedEmail ( true ) ;
109
- setUniqueId ( parseData . Id ) ;
110
- setRoleName ( parseData . Role ) ;
111
- } }
112
- >
113
- < Select . Trigger
114
- className = { selectedEmail ? "selectEmail" : "SelectTrigger" }
115
- style = { {
116
- background : isSelectListId
117
- ? color [ isSelectListId % color . length ]
118
- : color [ 0 ]
119
- } }
120
- aria-label = "Food"
121
- >
122
- < Select . Value placeholder = "Select signer.." />
123
- { ! selectedEmail && (
124
- < Select . Icon className = "SelectIcon" >
125
- < i
126
- style = { {
127
- marginTop : "5px" ,
128
- marginLeft : "5px" ,
129
- color : "#3b15d1" ,
130
- fontSize : "20px"
131
- } }
132
- className = "fa fa-angle-down"
133
- aria-hidden = "true"
134
- > </ i >
135
- </ Select . Icon >
136
- ) }
137
- </ Select . Trigger >
138
- < Select . Portal >
139
- < Select . Content
140
- className = "SelectContent"
141
- style = { { zIndex : "5000" } }
142
- >
143
- < Select . ScrollUpButton className = "SelectScrollButton" >
144
- < i
145
- style = { {
146
- marginTop : "5px" ,
147
- marginLeft : "5px" ,
148
- color : "#3b15d1" ,
149
- fontSize : "20px"
150
- } }
151
- className = "fa fa-angle-down"
152
- aria-hidden = "true"
153
- > </ i >
154
- </ Select . ScrollUpButton >
155
- < Select . Viewport className = "SelectViewport" >
156
- < Select . Group >
157
- { signersdata . map ( ( obj , ind ) => {
158
- return (
159
- < SelectItem
160
- selected
161
- key = { ind }
162
- value = { `${ ind } |${ JSON . stringify ( obj ) } ` }
163
- // value={(obj)}
164
- >
165
- { obj . Email ? obj . Email : obj . Role }
166
- </ SelectItem >
167
- ) ;
168
- } ) }
169
- </ Select . Group >
170
- </ Select . Viewport >
171
- < Select . ScrollDownButton className = "SelectScrollButton" >
172
- < i
173
- style = { {
174
- marginTop : "5px" ,
175
- marginLeft : "5px" ,
176
- color : "#3b15d1" ,
177
- fontSize : "20px"
178
- } }
179
- className = "fa fa-angle-down"
180
- aria-hidden = "false"
181
- > </ i >
182
- </ Select . ScrollDownButton >
183
- </ Select . Content >
184
- </ Select . Portal >
185
- </ Select . Root >
186
103
</ div >
187
104
) }
188
105
{ handleAddSigner && (
@@ -206,17 +123,7 @@ function FieldsComponent({
206
123
style = { { backgroundColor : themeColor ( ) } }
207
124
>
208
125
< div
209
- onClick = { ( ) => {
210
- if ( isSigners ) {
211
- if ( selectedEmail ) {
212
- addPositionOfSignature ( "onclick" , false ) ;
213
- } else {
214
- setIsShowEmail ( true ) ;
215
- }
216
- } else {
217
- addPositionOfSignature ( "onclick" , false ) ;
218
- }
219
- } }
126
+ onClick = { ( ) => addPositionOfSignature ( "onclick" , false ) }
220
127
ref = { ( element ) => {
221
128
dragSignatureSS ( element ) ;
222
129
if ( element ) {
@@ -426,6 +333,25 @@ function FieldsComponent({
426
333
</ div >
427
334
</ div >
428
335
) }
336
+ < ModalUi
337
+ title = { "Recipients" }
338
+ isOpen = { isSignersModal }
339
+ handleClose = { handleModal }
340
+ >
341
+ < RecipientList
342
+ signerPos = { signerPos }
343
+ signersdata = { signersdata }
344
+ isSelectListId = { isSelectListId }
345
+ setSignerObjId = { setSignerObjId }
346
+ setIsSelectId = { setIsSelectId }
347
+ setContractName = { setContractName }
348
+ setUniqueId = { setUniqueId }
349
+ setRoleName = { setRoleName }
350
+ handleDeleteUser = { handleDeleteUser }
351
+ handleRoleChange = { handleRoleChange }
352
+ handleOnBlur = { handleOnBlur }
353
+ />
354
+ </ ModalUi >
429
355
</ >
430
356
) ;
431
357
}
0 commit comments