Skip to content

Commit c185c42

Browse files
vertically center button in reports, add title for template route and placeholder route
1 parent 4648ace commit c185c42

File tree

3 files changed

+85
-51
lines changed

3 files changed

+85
-51
lines changed

apps/OpenSign/src/primitives/GetReportDisplay.js

Lines changed: 81 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ const ReportTable = ({
2121
const [actLoader, setActLoader] = useState({});
2222
const [isAlert, setIsAlert] = useState(false);
2323
const [isErr, setIsErr] = useState(false);
24+
const [isDocErr, setIsDocErr] = useState(false);
2425
const [isContactform, setIsContactform] = useState(false);
2526
const [isDeleteModal, setIsDeleteModal] = useState({});
27+
const startIndex = (currentPage - 1) * docPerPage;
28+
2629
// For loop is used to calculate page numbers visible below table
2730
// Initialize pageNumbers using useMemo to avoid unnecessary re-creation
2831
const pageNumbers = useMemo(() => {
@@ -65,7 +68,7 @@ const ReportTable = ({
6568
if (btnLabel === "Edit") {
6669
navigate(`/asmf/${url}/${item.objectId}`);
6770
} else {
68-
setActLoader({ [item.objectId]: true });
71+
setActLoader({ [`${item.objectId}_${btnLabel}`]: true });
6972
try {
7073
const params = {
7174
templateId: item.objectId
@@ -104,46 +107,59 @@ const ReportTable = ({
104107
signers.push(obj);
105108
}
106109
});
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+
);
127145

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+
});
138153
}
154+
} catch (err) {
155+
console.log("Err", err);
156+
setIsAlert(true);
157+
setIsErr(true);
158+
setActLoader({});
139159
}
140-
);
141-
142-
// console.log("Res ", res.data);
143-
if (res.data && res.data.objectId) {
160+
} else {
161+
setIsDocErr(true);
144162
setActLoader({});
145-
setIsAlert(true);
146-
navigate(`/asmf/${url}/${res.data.objectId}`);
147163
}
148164
} else {
149165
setIsAlert(true);
@@ -190,7 +206,7 @@ const ReportTable = ({
190206
};
191207

192208
const handleDelete = async (item) => {
193-
setIsDeleteModal({})
209+
setIsDeleteModal({});
194210
setActLoader({ [item.objectId]: true });
195211
try {
196212
const url =
@@ -264,12 +280,12 @@ const ReportTable = ({
264280
ReportName === "Contactbook" ? (
265281
<tr className="border-y-[1px]" key={index}>
266282
{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>
268284
)}
269285
<td className="px-4 py-2 font-semibold">{item?.Name} </td>
270286
<td className="px-4 py-2">{item?.Email || "-"}</td>
271287
<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">
273289
{actions?.length > 0 &&
274290
actions.map((act, index) => (
275291
<button
@@ -279,7 +295,7 @@ const ReportTable = ({
279295
? handlemicroapp(item, act.redirectUrl)
280296
: handlebtn(item)
281297
}
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`}
283299
style={{
284300
backgroundColor: act.btnColor
285301
? act.btnColor
@@ -306,7 +322,11 @@ const ReportTable = ({
306322
</button>
307323
))}
308324
{isDeleteModal[item.objectId] && (
309-
<ModalUi isOpen title={"Delete Contact"} handleClose={handleCloseDeleteModal}>
325+
<ModalUi
326+
isOpen
327+
title={"Delete Contact"}
328+
handleClose={handleCloseDeleteModal}
329+
>
310330
<div className="m-[20px]">
311331
<div className="text-lg font-normal text-black">
312332
Are you sure you want to delete this contact?
@@ -334,9 +354,11 @@ const ReportTable = ({
334354
) : (
335355
<tr className="border-y-[1px]" key={index}>
336356
{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>
338358
)}
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>
340362
{heading.includes("Note") && (
341363
<td className="px-4 py-2">{item?.Note || "-"}</td>
342364
)}
@@ -362,7 +384,7 @@ const ReportTable = ({
362384
<td className="px-4 py-2">
363385
{item?.Signers ? formatRow(item?.Signers) : "-"}
364386
</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">
366388
{actions?.length > 0 &&
367389
actions.map((act, index) => (
368390
<button
@@ -376,7 +398,7 @@ const ReportTable = ({
376398
)
377399
: handlebtn(item)
378400
}
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`}
380402
style={{
381403
backgroundColor: act.btnColor
382404
? act.btnColor
@@ -388,7 +410,9 @@ const ReportTable = ({
388410
{act?.btnIcon && (
389411
<i
390412
className={
391-
actLoader[item.objectId]
413+
actLoader[
414+
`${item.objectId}_${act.btnLabel}`
415+
]
392416
? "fa-solid fa-spinner fa-spin-pulse"
393417
: act.btnIcon
394418
}
@@ -466,6 +490,16 @@ const ReportTable = ({
466490
closePopup={handleContactFormModal}
467491
/>
468492
</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>
469503
</div>
470504
);
471505
};

microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ const TemplatePlaceholder = () => {
197197
}
198198
}
199199
);
200-
// console.log("templateDeatils.data ", templateDeatils.data);
201200
const documentData =
202201
templateDeatils.data && templateDeatils.data.result
203202
? [templateDeatils.data.result]
@@ -780,7 +779,7 @@ const TemplatePlaceholder = () => {
780779
// handle create document
781780
const res = await createDocument(pdfDetails, signerPos, signersdata);
782781
if (res.status === "success") {
783-
navigate(`${hostUrl}placeHolderSign/${res.id}`);
782+
navigate(`${hostUrl}placeHolderSign/${res.id}`,{state: {title:"Use Template"}});
784783
setIsCreateDoc(false);
785784
} else {
786785
setHandleError("Error: Something went wrong!");

microfrontends/SignDocuments/src/Component/placeHolderSign.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useDrag, useDrop } from "react-dnd";
1111
import RenderAllPdfPage from "./component/renderAllPdfPage";
1212
import FieldsComponent from "./component/fieldsComponent";
1313
import Tour from "reactour";
14-
import { useParams } from "react-router-dom";
14+
import { useLocation, useParams } from "react-router-dom";
1515
import Loader from "./component/loader";
1616
import HandleError from "./component/HandleError";
1717
import Nodata from "./component/Nodata";
@@ -34,6 +34,7 @@ import Title from "./component/Title";
3434

3535
function PlaceHolderSign() {
3636
const navigate = useNavigate();
37+
const {state}= useLocation()
3738
const [pdfDetails, setPdfDetails] = useState([]);
3839
const [isMailSend, setIsMailSend] = useState(false);
3940
const [allPages, setAllPages] = useState(null);
@@ -876,7 +877,7 @@ function PlaceHolderSign() {
876877
};
877878
return (
878879
<>
879-
<Title title={"placeholder"} />
880+
<Title title={state?.title ? state.title: "New Document"} />
880881
<DndProvider backend={HTML5Backend}>
881882
{isLoading.isLoad ? (
882883
<Loader isLoading={isLoading} />

0 commit comments

Comments
 (0)