Skip to content

Commit

Permalink
feat: add extend document expiry date functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
prafull-opensignlabs committed Nov 19, 2024
1 parent cb07e37 commit 1a45541
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 36 deletions.
10 changes: 7 additions & 3 deletions apps/OpenSign/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
"option": "Option",
"Embed": "Embed",
"Copy TemplateId":"Copy TemplateId",
"Copy Public URL":"Copy Public URL"
"Copy Public URL":"Copy Public URL",
"extend-expiry-date": "Extend expiry date"
},
"report-heading": {
"Sr.No": "Sr.No",
Expand Down Expand Up @@ -267,7 +268,8 @@
"make-template-public-alert": "Are you sure you want to make this template public?",
"make-template-private-alert": "Are you sure you want to make this template private? This will remove it from your public profile.",
"public-role": "Public role",
"public-url": "Public profile needed",
"public-url": "Public profile",
"embed-template": "Embed Template",
"public-url-copy": "Here’s your public URL: ",
"public-url-copy-mssg":"Copy it or share it with the signer, and you will be able to see all your publicly set templates.",
"add-public-url-alert": "Please complete your OpenSign public profile setup. Once done, you’ll be able to make templates public. This process only needs to be completed once.",
Expand Down Expand Up @@ -703,5 +705,7 @@
"notify-on-signatures-help": {
"p1": "The document creator will receive an email notification whenever a signer signs the document.",
"note": "Note: Notification email will not be sent for the last signer, as the document creator will receive a completion email instead."
}
},
"expiry-date-updated": "The expiry date has been successfully extended to {{newexpirydate}}",
"expiry-date-error": "Please provide a new expiry date that is later than the current one"
}
10 changes: 7 additions & 3 deletions apps/OpenSign/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
"option": "Opción",
"Embed": "Incrustar",
"Copy TemplateId": "Copiar ID de plantilla",
"Copy Public URL": "Copiar URL pública"
"Copy Public URL": "Copiar URL pública",
"extend-expiry-date": "Ampliar fecha de caducidad"
},
"report-heading": {
"Sr.No": "",
Expand Down Expand Up @@ -267,7 +268,8 @@
"make-template-public-alert": "¿En definitiva quieres convertir esta plantilla en pública?",
"make-template-private-alert": "¿En definitiva quieres convertir esta plantilla en privada? Esto lo removerá de tu perfil público.",
"public-role": "Rol público",
"public-url": "Se requiere perfil público",
"public-url": "Perfil publico",
"embed-template": "Insertar plantilla",
"public-url-copy": "Aquí está tu URL pública: ",
"public-url-copy-mssg": "Cópiala o compártela con el firmante y podrás ver todas tus plantillas públicas.",
"add-public-url-alert": "Por favor, completa la configuración de tu perfil público OpenSign. Una vez terminado, podrás crear plantillas públicas. Este proceso solo necesita ser completado una vez.",
Expand Down Expand Up @@ -703,5 +705,7 @@
"notify-on-signatures-help": {
"p1": "El creador del documento recibirá una notificación por correo electrónico cada vez que un firmante firme el documento.",
"note": "Nota: No se enviará un correo electrónico de notificación al último firmante, ya que el creador del documento recibirá un correo electrónico de finalización."
}
},
"expiry-date-updated": "La fecha de vencimiento se ha extendido con éxito hasta el {{newexpirydate}}",
"expiry-date-error": "Proporcione una nueva fecha de vencimiento que sea posterior a la actual"
}
10 changes: 7 additions & 3 deletions apps/OpenSign/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@
"option": "Option",
"Embed": "Intégrer",
"Copy TemplateId": "Copier l'ID du modèle",
"Copy Public URL":"Copier l'URL publique"
"Copy Public URL":"Copier l'URL publique",
"extend-expiry-date": "Prolonger la date d'expiration"
},
"report-help": {
"Draft Documents": "Il s'agit de documents que vous avez commencés mais que vous n'avez pas finalisés pour envoi.",
Expand Down Expand Up @@ -266,7 +267,8 @@
"make-template-public-alert": "Êtes-vous sûr de vouloir rendre ce modèle public ?",
"make-template-private-alert": "Êtes-vous sûr de vouloir rendre ce modèle privé ? Cela le supprimera de votre profil public.",
"public-role": "Rôle public",
"public-url": "Profil public requis",
"public-url": "Profil public",
"embed-template": "Intégrer le modèle",
"public-url-copy": "Voici votre URL publique : ",
"public-url-copy-mssg": "copiez-la ou partagez-le avec le signataire et vous pouvoir voir tous vos paramètres publics modèles.",
"add-public-url-alert": "Veuillez terminer la configuration de votre profil public OpenSign. Une fois cela fait, vous pourrez rendre les modèles publics. Ce processus ne doit être effectué qu’une seule fois.",
Expand Down Expand Up @@ -702,5 +704,7 @@
"notify-on-signatures-help": {
"p1": "Le créateur du document recevra une notification par e-mail chaque fois qu'un signataire signera le document.",
"note": "Remarque : L'e-mail de notification ne sera pas envoyé pour le dernier signataire, car le créateur du document recevra à la place un e-mail de fin."
}
},
"expiry-date-updated": "La fecha de vencimiento se ha extendido con éxito hasta el {{newexpirydate}}",
"expiry-date-error": "Veuillez fournir une nouvelle date d'expiration postérieure à la date actuelle"
}
22 changes: 10 additions & 12 deletions apps/OpenSign/src/components/pdf/EmbedTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ function EmbedTab(props) {
{
id: 0,
title: "Installation",
codeString: `
npm install @opensign/react`
codeString: `npm install @opensign/react`
},
{
id: 1,
title: "Usage",
codeString: `
import React from "react";
import React from "react";
import Opensign from "@opensign/react";
export function App() {
export default function App() {
return (
<div className="app">
<Opensign
Expand All @@ -40,7 +39,6 @@ export function App() {
);
}
`
}
];
Expand All @@ -49,15 +47,14 @@ export function App() {
{
id: 0,
title: "Installation",
codeString: `
npm install @opensign/angular`
codeString: `npm install @opensign/angular`
},
{
id: 1,
title: "Usage",
codeString: `
import { Component } from '@angular/core';
import {OpensignComponent} from "@opensign/angular"
import { OpensignComponent } from "@opensign/angular"
@Component({
selector:'app-root',
Expand All @@ -68,17 +65,15 @@ import {OpensignComponent} from "@opensign/angular"
(onLoadError)="handleError($event)"
></opensign>\`,
})
export class AppComponent{
export class AppComponent {
handleLoad() {
console.log("success");
}
handleError(error: string) {
console.log(error);
}
}
`
}
];
Expand All @@ -98,6 +93,9 @@ export class AppComponent{

return (
<div className="mt-4 border-t-[1px]">
<h3 className="text-base-content font-bold text-lg pt-[15px] pb-[5px]">
{t("embed-template")}
</h3>
<div className="flex justify-center items-center mt-2">
<div role="tablist" className="op-tabs op-tabs-bordered">
{tabName.map((tabData, ind) => (
Expand All @@ -107,7 +105,7 @@ export class AppComponent{
role="tab"
className={`${
activeTab === ind ? "op-tab-active" : ""
} op-tab flex items-center`}
} op-tab flex items-center pb-10 md:pb-0`}
>
<i
className={`${tabData.icon}`}
Expand Down
19 changes: 19 additions & 0 deletions apps/OpenSign/src/json/ReportJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,25 @@ export default function reportJson(id) {
btnIcon: "fa-light fa-trash",
redirectUrl: "",
action: "delete"
},
{
btnId: "3234",
hoverLabel: "option",
btnColor: "",
textColor: "black",
btnIcon: "fa-light fa-ellipsis-vertical fa-lg",
action: "option",
subaction: [
{
btnId: "2199",
btnLabel: "extend-expiry-date",
hoverLabel: "Extend expiry date",
btnColor: "op-btn-primary",
btnIcon: "fa-light fa-hourglass-end",
redirectUrl: "",
action: "extendexpiry"
}
]
}
],
helpMsg:
Expand Down
39 changes: 39 additions & 0 deletions apps/OpenSign/src/pages/PdfRequestFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import LoaderWithMsg from "../primitives/LoaderWithMsg";
import DownloadPdfZip from "../primitives/DownloadPdfZip";
import Loader from "../primitives/Loader";
import PdfDeclineModal from "../primitives/PdfDeclineModal";
import { serverUrl_fn } from "../constant/appinfo";

function PdfRequestFiles(props) {
const { t } = useTranslation();
Expand Down Expand Up @@ -1752,6 +1753,42 @@ function PdfRequestFiles(props) {
</div>
);
};

const handleExpiry = async (expiryDate) => {
setIsUiLoading(true);
const doc = pdfDetails?.[0];
const oldExpiryDate = new Date(doc?.ExpiryDate?.iso);
const newExpiryDate = new Date(expiryDate);
if (newExpiryDate > oldExpiryDate) {
const updateExpiryDate = new Date(expiryDate).toISOString();
const expiryIsoFormat = { iso: updateExpiryDate, __type: "Date" };
try {
const serverUrl = serverUrl_fn();
const url = serverUrl + `/classes/contracts_Document/`;
const body = { ExpiryDate: expiryIsoFormat };
const res = await axios.put(url + doc.objectId, body, {
headers: {
"Content-Type": "application/json",
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
}
});
if (res.data && res.data.updatedAt) {
setIsExpired(false);
let doc = pdfDetails?.[0];
doc.ExpiryDate = expiryIsoFormat;
setPdfDetails([doc]);
}
} catch (err) {
console.log("err", err);
} finally {
setIsUiLoading(false);
}
} else {
setIsUiLoading(false);
alert(t("expiry-date-error"));
}
};
return (
<DndProvider backend={HTML5Backend}>
<Title title={props.templateId ? "Public Sign" : "Request Sign"} />
Expand Down Expand Up @@ -1838,10 +1875,12 @@ function PdfRequestFiles(props) {
{/* this modal is used for show expired alert */}
<PdfDeclineModal
show={isExpired}
doc={pdfDetails?.[0]}
headMsg={t("expired-doc-title")}
bodyMssg={t("expired-on-mssg", { expiredDate })}
isDownloadBtn={true}
handleDownloadBtn={handleDownloadBtn}
handleExpiry={handleExpiry}
/>
{!isEmailVerified && (
<VerifyEmail
Expand Down
99 changes: 98 additions & 1 deletion apps/OpenSign/src/primitives/GetReportDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const ReportTable = (props) => {
const [isEmbed, setIsEmbed] = useState(false);
const [isPublicTour, setIsPublicTour] = useState();
const [signatureType, setSignatureType] = useState([]);
const [expiryDate, setExpiryDate] = useState("");
const Extand_Class = localStorage.getItem("Extand_Class");
const extClass = Extand_Class && JSON.parse(Extand_Class);
const startIndex = (currentPage - 1) * props.docPerPage;
Expand Down Expand Up @@ -433,6 +434,8 @@ const ReportTable = (props) => {
} else {
setIsPublicTour({ [item.objectId]: true });
}
} else if (act.action) {
setIsModal({ [`extendexpiry_${item.objectId}`]: true });
}
};
// Get current list
Expand Down Expand Up @@ -1210,6 +1213,67 @@ const ReportTable = (props) => {
const closePublicTour = () => {
setIsPublicTour();
};
const handleUpdateExpiry = async (e, item) => {
e.preventDefault();
e.stopPropagation();
if (expiryDate) {
const oldExpiryDate = new Date(item?.ExpiryDate?.iso);
const newExpiryDate = new Date(expiryDate);
if (newExpiryDate > oldExpiryDate) {
setActLoader({ [`${item.objectId}`]: true });
const updateExpiryDate = new Date(expiryDate).toISOString();
const expiryIsoFormat = { iso: updateExpiryDate, __type: "Date" };
try {
const serverUrl = serverUrl_fn();
const cls = "contracts_Document";
const url = serverUrl + `/classes/${cls}/`;
const body = { ExpiryDate: expiryIsoFormat };
const res = await axios.put(url + item.objectId, body, {
headers: {
"Content-Type": "application/json",
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
}
});
if (res.data && res.data.updatedAt) {
setIsAlert(true);
setAlertMsg({
type: "success",
message: t("expiry-date-updated", {
newexpirydate: new Date(expiryDate)?.toLocaleDateString()
})
});
if (props.ReportName === "Expired Documents") {
const upldatedList = props.List.filter(
(x) => x.objectId !== item.objectId
);
props.setList(upldatedList);
}
}
} catch (err) {
console.log("err", err);
setIsAlert(true);
setAlertMsg({
type: "danger",
message: t("something-went-wrong-mssg")
});
} finally {
setActLoader({});
setExpiryDate();
setTimeout(() => setIsAlert(false), 2000);
setIsModal({});
}
} else {
setIsAlert(true);
setAlertMsg({ type: "danger", message: t("expiry-date-error") });
setTimeout(() => setIsAlert(false), 2000);
}
} else {
setIsAlert(true);
setAlertMsg({ type: "danger", message: t("expiry-date-error") });
setTimeout(() => setIsAlert(false), 2000);
}
};
return (
<div className="relative">
{Object.keys(actLoader)?.length > 0 && (
Expand Down Expand Up @@ -1490,7 +1554,7 @@ const ReportTable = (props) => {
<td className=" pl-[20px] py-2">
{props.ReportName === "Templates" && (
<div
className="flex flex-row "
className="flex flex-row"
data-tut="IsPublic"
>
<label className="cursor-pointer relative inline-flex items-center mb-0">
Expand Down Expand Up @@ -1773,6 +1837,39 @@ const ReportTable = (props) => {
)
)}
</div>
{isModal["extendexpiry_" + item.objectId] && (
<ModalUi
isOpen
title={t("btnLabel.extend-expiry-date")}
reduceWidth={"md:max-w-[450px]"}
handleClose={() => setIsModal({})}
>
<form
className="px-4 py-2 flex flex-col"
onSubmit={(e) => handleUpdateExpiry(e, item)}
>
<label className="mr-2">Expiry date</label>
<input
type="date"
className="rounded-full mb-2 bg-base-300 w-full px-4 py-2 text-black border-2 hover:border-spacing-2"
defaultValue={
item?.ExpiryDate?.iso?.split("T")?.[0]
}
onChange={(e) => {
setExpiryDate(e.target.value);
}}
/>
<div className="flex justify-start mb-1">
<button
type="submit"
className="op-btn op-btn-primary"
>
{t("update")}
</button>
</div>
</form>
</ModalUi>
)}
{isShareWith[item.objectId] && (
<div className="op-modal op-modal-open">
<div className="max-h-90 bg-base-100 w-[95%] md:max-w-[500px] rounded-box relative">
Expand Down
Loading

0 comments on commit 1a45541

Please sign in to comment.