@@ -3,6 +3,8 @@ import pad from "../assets/images/pad.svg";
3
3
import { useNavigate } from "react-router-dom" ;
4
4
import axios from "axios" ;
5
5
import "../styles/report.css" ;
6
+ import ModalUi from "./ModalUi" ;
7
+ import AppendFormInForm from "../components/AppendFormInForm" ;
6
8
const ReportTable = ( {
7
9
ReportName,
8
10
List,
@@ -11,13 +13,15 @@ const ReportTable = ({
11
13
heading,
12
14
setIsNextRecord,
13
15
isMoreDocs,
14
- docPerPage
16
+ docPerPage,
17
+ form
15
18
} ) => {
16
19
const navigate = useNavigate ( ) ;
17
20
const [ currentPage , setCurrentPage ] = useState ( 1 ) ;
18
21
const [ actLoader , setActLoader ] = useState ( { } ) ;
19
22
const [ isAlert , setIsAlert ] = useState ( false ) ;
20
23
const [ isErr , setIsErr ] = useState ( false ) ;
24
+ const [ isPopup , setIsPopup ] = useState ( false ) ;
21
25
// For loop is used to calculate page numbers visible below table
22
26
// Initialize pageNumbers using useMemo to avoid unnecessary re-creation
23
27
const pageNumbers = useMemo ( ( ) => {
@@ -57,9 +61,9 @@ const ReportTable = ({
57
61
// `handlemicroapp` is used to open microapp
58
62
const handlemicroapp = async ( item , url , btnLabel ) => {
59
63
if ( ReportName === "Templates" ) {
60
- if ( btnLabel === "Edit" ) {
64
+ if ( btnLabel === "Edit" ) {
61
65
navigate ( `/asmf/${ url } /${ item . objectId } ` ) ;
62
- } else {
66
+ } else {
63
67
setActLoader ( { [ item . objectId ] : true } ) ;
64
68
try {
65
69
const params = {
@@ -76,13 +80,13 @@ const ReportTable = ({
76
80
}
77
81
}
78
82
) ;
79
-
83
+
80
84
// console.log("templateDeatils.data ", templateDeatils.data);
81
85
const templateData =
82
86
templateDeatils . data && templateDeatils . data . result ;
83
87
if ( ! templateData . error ) {
84
88
const Doc = templateData ;
85
-
89
+
86
90
let placeholdersArr = [ ] ;
87
91
if ( Doc . Placeholders ?. length > 0 ) {
88
92
placeholdersArr = Doc . Placeholders ;
@@ -119,7 +123,7 @@ const ReportTable = ({
119
123
} ,
120
124
Signers : signers
121
125
} ;
122
-
126
+
123
127
const res = await axios . post (
124
128
`${ localStorage . getItem ( "baseUrl" ) } classes/${ localStorage . getItem (
125
129
"_appName"
@@ -133,7 +137,7 @@ const ReportTable = ({
133
137
}
134
138
}
135
139
) ;
136
-
140
+
137
141
// console.log("Res ", res.data);
138
142
if ( res . data && res . data . objectId ) {
139
143
setActLoader ( { } ) ;
@@ -200,6 +204,13 @@ const ReportTable = ({
200
204
const paginateFront = ( ) => setCurrentPage ( currentPage + 1 ) ;
201
205
const paginateBack = ( ) => setCurrentPage ( currentPage - 1 ) ;
202
206
207
+ const handlePopup = ( ) => {
208
+ setIsPopup ( ! isPopup ) ;
209
+ } ;
210
+
211
+ const handleUserData = ( data ) => {
212
+ setList ( ( prevData ) => [ data , ...prevData ] ) ;
213
+ } ;
203
214
return (
204
215
< div className = "p-2 overflow-x-scroll w-full bg-white rounded-md" >
205
216
{ isAlert && (
@@ -214,7 +225,14 @@ const ReportTable = ({
214
225
</ div >
215
226
) }
216
227
217
- < h2 className = "text-[23px] font-light my-2" > { ReportName } </ h2 >
228
+ < div className = "flex flex-row items-center justify-between my-2 mx-3 text-[20px] md:text-[23px]" >
229
+ < div className = "font-light" > { ReportName } </ div >
230
+ { form && (
231
+ < div className = "cursor-pointer" onClick = { ( ) => handlePopup ( ) } >
232
+ < i className = "fa-solid fa-square-plus text-sky-400 text-[25px]" > </ i >
233
+ </ div >
234
+ ) }
235
+ </ div >
218
236
< table className = "table-auto w-full border-collapse" >
219
237
< thead className = "text-[14px]" >
220
238
< tr className = "border-y-[1px]" >
@@ -316,7 +334,11 @@ const ReportTable = ({
316
334
key = { index }
317
335
onClick = { ( ) =>
318
336
act ?. redirectUrl
319
- ? handlemicroapp ( item , act . redirectUrl , act . btnLabel )
337
+ ? handlemicroapp (
338
+ item ,
339
+ act . redirectUrl ,
340
+ act . btnLabel
341
+ )
320
342
: handlebtn ( item )
321
343
}
322
344
className = { `flex justify-center items-center w-full gap-1 px-2 py-1 rounded shadow` }
@@ -399,6 +421,12 @@ const ReportTable = ({
399
421
< div className = "text-sm font-semibold" > No Data Available</ div >
400
422
</ div >
401
423
) }
424
+ < ModalUi title = { "Add Contact" } isOpen = { isPopup } handleClose = { handlePopup } >
425
+ < AppendFormInForm
426
+ handleUserData = { handleUserData }
427
+ closePopup = { handlePopup }
428
+ />
429
+ </ ModalUi >
402
430
</ div >
403
431
) ;
404
432
} ;
0 commit comments