@@ -21,8 +21,11 @@ const ReportTable = ({
21
21
const [ actLoader , setActLoader ] = useState ( { } ) ;
22
22
const [ isAlert , setIsAlert ] = useState ( false ) ;
23
23
const [ isErr , setIsErr ] = useState ( false ) ;
24
+ const [ isDocErr , setIsDocErr ] = useState ( false ) ;
24
25
const [ isContactform , setIsContactform ] = useState ( false ) ;
25
26
const [ isDeleteModal , setIsDeleteModal ] = useState ( { } ) ;
27
+ const startIndex = ( currentPage - 1 ) * docPerPage ;
28
+
26
29
// For loop is used to calculate page numbers visible below table
27
30
// Initialize pageNumbers using useMemo to avoid unnecessary re-creation
28
31
const pageNumbers = useMemo ( ( ) => {
@@ -65,7 +68,7 @@ const ReportTable = ({
65
68
if ( btnLabel === "Edit" ) {
66
69
navigate ( `/asmf/${ url } /${ item . objectId } ` ) ;
67
70
} else {
68
- setActLoader ( { [ item . objectId ] : true } ) ;
71
+ setActLoader ( { [ ` ${ item . objectId } _ ${ btnLabel } ` ] : true } ) ;
69
72
try {
70
73
const params = {
71
74
templateId : item . objectId
@@ -104,46 +107,59 @@ const ReportTable = ({
104
107
signers . push ( obj ) ;
105
108
}
106
109
} ) ;
107
- }
108
- const data = {
109
- Name : Doc . Name ,
110
- URL : Doc . URL ,
111
- SignedUrl : Doc . SignedUrl ,
112
- Description : Doc . Description ,
113
- Note : Doc . Note ,
114
- Placeholders : placeholdersArr ,
115
- ExtUserPtr : {
116
- __type : "Pointer" ,
117
- className : "contracts_Users" ,
118
- objectId : Doc . ExtUserPtr . objectId
119
- } ,
120
- CreatedBy : {
121
- __type : "Pointer" ,
122
- className : "_User" ,
123
- objectId : Doc . CreatedBy . objectId
124
- } ,
125
- Signers : signers
126
- } ;
110
+ const data = {
111
+ Name : Doc . Name ,
112
+ URL : Doc . URL ,
113
+ SignedUrl : Doc . SignedUrl ,
114
+ Description : Doc . Description ,
115
+ Note : Doc . Note ,
116
+ Placeholders : placeholdersArr ,
117
+ ExtUserPtr : {
118
+ __type : "Pointer" ,
119
+ className : "contracts_Users" ,
120
+ objectId : Doc . ExtUserPtr . objectId
121
+ } ,
122
+ CreatedBy : {
123
+ __type : "Pointer" ,
124
+ className : "_User" ,
125
+ objectId : Doc . CreatedBy . objectId
126
+ } ,
127
+ Signers : signers
128
+ } ;
129
+ try {
130
+ const res = await axios . post (
131
+ `${ localStorage . getItem (
132
+ "baseUrl"
133
+ ) } classes/${ localStorage . getItem ( "_appName" ) } _Document`,
134
+ data ,
135
+ {
136
+ headers : {
137
+ "Content-Type" : "application/json" ,
138
+ "X-Parse-Application-Id" :
139
+ localStorage . getItem ( "parseAppId" ) ,
140
+ "X-Parse-Session-Token" :
141
+ localStorage . getItem ( "accesstoken" )
142
+ }
143
+ }
144
+ ) ;
127
145
128
- const res = await axios . post (
129
- `${ localStorage . getItem ( "baseUrl" ) } classes/${ localStorage . getItem (
130
- "_appName"
131
- ) } _Document`,
132
- data ,
133
- {
134
- headers : {
135
- "Content-Type" : "application/json" ,
136
- "X-Parse-Application-Id" : localStorage . getItem ( "parseAppId" ) ,
137
- "X-Parse-Session-Token" : localStorage . getItem ( "accesstoken" )
146
+ // console.log("Res ", res.data);
147
+ if ( res . data && res . data . objectId ) {
148
+ setActLoader ( { } ) ;
149
+ setIsAlert ( true ) ;
150
+ navigate ( `/asmf/${ url } /${ res . data . objectId } ` , {
151
+ state : { title : "Use Template" }
152
+ } ) ;
138
153
}
154
+ } catch ( err ) {
155
+ console . log ( "Err" , err ) ;
156
+ setIsAlert ( true ) ;
157
+ setIsErr ( true ) ;
158
+ setActLoader ( { } ) ;
139
159
}
140
- ) ;
141
-
142
- // console.log("Res ", res.data);
143
- if ( res . data && res . data . objectId ) {
160
+ } else {
161
+ setIsDocErr ( true ) ;
144
162
setActLoader ( { } ) ;
145
- setIsAlert ( true ) ;
146
- navigate ( `/asmf/${ url } /${ res . data . objectId } ` ) ;
147
163
}
148
164
} else {
149
165
setIsAlert ( true ) ;
@@ -190,7 +206,7 @@ const ReportTable = ({
190
206
} ;
191
207
192
208
const handleDelete = async ( item ) => {
193
- setIsDeleteModal ( { } )
209
+ setIsDeleteModal ( { } ) ;
194
210
setActLoader ( { [ item . objectId ] : true } ) ;
195
211
try {
196
212
const url =
@@ -264,12 +280,12 @@ const ReportTable = ({
264
280
ReportName === "Contactbook" ? (
265
281
< tr className = "border-y-[1px]" key = { index } >
266
282
{ heading . includes ( "Sr.No" ) && (
267
- < td className = "px-4 py-2" > { index + 1 } </ td >
283
+ < td className = "px-4 py-2" > { startIndex + index + 1 } </ td >
268
284
) }
269
285
< td className = "px-4 py-2 font-semibold" > { item ?. Name } </ td >
270
286
< td className = "px-4 py-2" > { item ?. Email || "-" } </ td >
271
287
< td className = "px-4 py-2" > { item ?. Phone || "-" } </ td >
272
- < td className = "px-4 py-2 flex flex-col justify-center items-center gap -2 text-white" >
288
+ < td className = "px-3 py-2 text-white" >
273
289
{ actions ?. length > 0 &&
274
290
actions . map ( ( act , index ) => (
275
291
< button
@@ -279,7 +295,7 @@ const ReportTable = ({
279
295
? handlemicroapp ( item , act . redirectUrl )
280
296
: handlebtn ( item )
281
297
}
282
- className = { `flex justify-center items-center gap-1 px-2 py-1 rounded shadow` }
298
+ className = { `mb-1 flex justify-center items-center gap-1 px-2 py-1 rounded shadow` }
283
299
style = { {
284
300
backgroundColor : act . btnColor
285
301
? act . btnColor
@@ -306,7 +322,11 @@ const ReportTable = ({
306
322
</ button >
307
323
) ) }
308
324
{ isDeleteModal [ item . objectId ] && (
309
- < ModalUi isOpen title = { "Delete Contact" } handleClose = { handleCloseDeleteModal } >
325
+ < ModalUi
326
+ isOpen
327
+ title = { "Delete Contact" }
328
+ handleClose = { handleCloseDeleteModal }
329
+ >
310
330
< div className = "m-[20px]" >
311
331
< div className = "text-lg font-normal text-black" >
312
332
Are you sure you want to delete this contact?
@@ -334,9 +354,11 @@ const ReportTable = ({
334
354
) : (
335
355
< tr className = "border-y-[1px]" key = { index } >
336
356
{ heading . includes ( "Sr.No" ) && (
337
- < td className = "px-4 py-2" > { index + 1 } </ td >
357
+ < td className = "px-4 py-2" > { startIndex + index + 1 } </ td >
338
358
) }
339
- < td className = "px-4 py-2 font-semibold" > { item ?. Name } </ td >
359
+ < td className = "px-4 py-2 font-semibold w-56" >
360
+ { item ?. Name } { " " }
361
+ </ td >
340
362
{ heading . includes ( "Note" ) && (
341
363
< td className = "px-4 py-2" > { item ?. Note || "-" } </ td >
342
364
) }
@@ -362,7 +384,7 @@ const ReportTable = ({
362
384
< td className = "px-4 py-2" >
363
385
{ item ?. Signers ? formatRow ( item ?. Signers ) : "-" }
364
386
</ td >
365
- < td className = "px-4 py-2 flex flex-col justify-center items-center gap -2 text-white" >
387
+ < td className = "px-3 py-2 text-white" >
366
388
{ actions ?. length > 0 &&
367
389
actions . map ( ( act , index ) => (
368
390
< button
@@ -376,7 +398,7 @@ const ReportTable = ({
376
398
)
377
399
: handlebtn ( item )
378
400
}
379
- className = { `flex justify-center items-center w-full gap-1 px-2 py-1 rounded shadow` }
401
+ className = { `mb-1 flex justify-center items-center gap-1 px-2 py-1 rounded shadow` }
380
402
style = { {
381
403
backgroundColor : act . btnColor
382
404
? act . btnColor
@@ -388,7 +410,9 @@ const ReportTable = ({
388
410
{ act ?. btnIcon && (
389
411
< i
390
412
className = {
391
- actLoader [ item . objectId ]
413
+ actLoader [
414
+ `${ item . objectId } _${ act . btnLabel } `
415
+ ]
392
416
? "fa-solid fa-spinner fa-spin-pulse"
393
417
: act . btnIcon
394
418
}
@@ -466,6 +490,16 @@ const ReportTable = ({
466
490
closePopup = { handleContactFormModal }
467
491
/>
468
492
</ ModalUi >
493
+ < ModalUi
494
+ headColor = { "#dc3545" }
495
+ isOpen = { isDocErr }
496
+ title = { "Receipent required" }
497
+ handleClose = { ( ) => setIsDocErr ( false ) }
498
+ >
499
+ < div style = { { height : "100%" , padding : 20 } } >
500
+ < p > Please add receipent in template!</ p >
501
+ </ div >
502
+ </ ModalUi >
469
503
</ div >
470
504
) ;
471
505
} ;
0 commit comments