mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-09-13 21:27:40 +02:00
refactor: validation
This commit is contained in:
@@ -475,7 +475,7 @@
|
||||
"role-not-found": "Role not found.",
|
||||
"do-not-access": "You don't have access, please contact the admin.",
|
||||
"add-admin": "Add admin",
|
||||
"opensign-setup": "Opensign Setup",
|
||||
"opensign-setup": "OpenSign Setup",
|
||||
"join-discord": "Join our discord server",
|
||||
"admin-already-exist": "Admin already exist.",
|
||||
"password-update-alert-1": "Password updated successfully.",
|
||||
@@ -531,7 +531,7 @@
|
||||
"filed-required-correctly": "Please fill required details correctly.",
|
||||
"admin-created": "Admin created",
|
||||
"invalid-masterkey": "Invalid masterkey",
|
||||
"opensign-Setup": "Opensign Setup",
|
||||
"opensign-Setup": "OpenSign Setup",
|
||||
"master-key": " Master key",
|
||||
"profile-update-alert": "Profile updated successfully.",
|
||||
"date": "Date",
|
||||
@@ -593,7 +593,7 @@
|
||||
"Recently sent for signatures": "This is a list of documents you've sent to other parties for signature.",
|
||||
"Drafts": "This are documents you have started but have not finalized for sending.",
|
||||
"public-template": "This video demonstrates how to set up your personalized public profile, such as ‘https://opensign.me/your-username’. You’ll also learn how to customize your tagline and make your templates available for public signing."
|
||||
},
|
||||
},
|
||||
"enter-email-plaholder": "Add an email address and hit enter",
|
||||
"success-email-alert": "Email sent successfully!",
|
||||
"expired-doc-title": "Expired Document",
|
||||
@@ -634,6 +634,7 @@
|
||||
"quotamailselfsign": "You've reached your limit of 20 emails for this month. Upgrade now to continue sending emails directly.",
|
||||
"quotamail": "You've reached your limit of 20 signature request emails for this month. Upgrade now to continue sending emails directly.",
|
||||
"quotamailTip":"Tip: You can still sign unlimited documents by manually sharing the signing request links below.",
|
||||
"quotamailhead":"Quota Reached"
|
||||
"quotamailhead":"Quota Reached",
|
||||
"unauthorized-modal":"You don't have permission to perform this action, please contact {{adminName}}<{{adminEmail}}>."
|
||||
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@
|
||||
"role-not-found": "Rôle introuvable.",
|
||||
"do-not-access": "Vous n'y avez pas accès, veuillez contacter l'administrateur.",
|
||||
"add-admin": "Ajouter un administrateur",
|
||||
"opensign-setup": "Configuration d'Opensign",
|
||||
"opensign-setup": "Configuration d'OpenSign",
|
||||
"join-discord": "Rejoignez notre serveur Discord",
|
||||
"admin-already-exist": "L'administrateur existe déjà.",
|
||||
"password-update-alert-1": "Mot de passe mis à jour avec succès.",
|
||||
@@ -530,7 +530,7 @@
|
||||
"filed-required-correctly": "Veuillez remplir correctement les informations requises.",
|
||||
"admin-created": "Administrateur créé",
|
||||
"invalid-masterkey": "Clé principale invalide",
|
||||
"opensign-Setup": "Configuration d'Opensign",
|
||||
"opensign-Setup": "Configuration d'OpenSign",
|
||||
"master-key": "La clef maitresse",
|
||||
"profile-update-alert": "Mise à jour du profil réussie.",
|
||||
"date": "Date",
|
||||
@@ -634,6 +634,7 @@
|
||||
"quotamailselfsign": "Vous avez atteint votre limite de 20 e-mails pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
|
||||
"quotamail": "Vous avez atteint votre limite de 20 e-mails de demande de signature pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
|
||||
"quotamailTip":"Astuce : Vous pouvez toujours signer un nombre illimité de documents en partageant manuellement les liens de demande de signature ci-dessous.",
|
||||
"quotamailhead":"Quota atteint"
|
||||
"quotamailhead":"Quota atteint",
|
||||
"unauthorized-modal":"Vous n'êtes pas autorisé à effectuer cette action, veuillez contacter {{adminName}}<{{adminEmail}}>."
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,12 @@ const BulkSendUi = (props) => {
|
||||
const [isQuotaReached, setIsQuotaReached] = useState(false);
|
||||
const [isLoader, setIsLoader] = useState(false);
|
||||
const [isFreePlan, setIsFreePlan] = useState(false);
|
||||
const [admin, setAdmin] = useState({
|
||||
objectId: "",
|
||||
name: "",
|
||||
email: "",
|
||||
isAdmin: true
|
||||
});
|
||||
const allowedSigners = 50;
|
||||
useEffect(() => {
|
||||
signatureExist();
|
||||
@@ -41,6 +47,27 @@ const BulkSendUi = (props) => {
|
||||
setIsLoader(true);
|
||||
try {
|
||||
const subscription = await fetchSubscription();
|
||||
const extUser =
|
||||
localStorage.getItem("Extand_Class") &&
|
||||
JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||
if (
|
||||
subscription?.adminId &&
|
||||
extUser?.objectId === subscription?.adminId
|
||||
) {
|
||||
setAdmin((obj) => ({
|
||||
...obj,
|
||||
objectId: subscription?.adminId,
|
||||
isAdmin: true
|
||||
}));
|
||||
} else {
|
||||
setAdmin((obj) => ({
|
||||
...obj,
|
||||
isAdmin: false,
|
||||
name: extUser?.CreatedBy?.name,
|
||||
email: extUser?.CreatedBy?.email
|
||||
}));
|
||||
}
|
||||
setAdmin((obj) => ({ ...obj, objectId: subscription?.adminId }));
|
||||
if (subscription?.plan === "freeplan") {
|
||||
setIsFreePlan(true);
|
||||
}
|
||||
@@ -69,6 +96,7 @@ const BulkSendUi = (props) => {
|
||||
}
|
||||
} else {
|
||||
setIsBulkAvailable(true);
|
||||
setAdmin((obj) => ({ ...obj, isAdmin: true }));
|
||||
const getPlaceholder = props.item?.Placeholders;
|
||||
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
|
||||
placeholderObj?.placeHolder?.some((holder) =>
|
||||
@@ -417,46 +445,57 @@ const BulkSendUi = (props) => {
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<form onSubmit={handleAddOnQuickSubmit} className="p-3">
|
||||
<p className="flex justify-center text-center mx-2 mb-3 text-base op-text-accent font-medium">
|
||||
{t("additional-credits")}
|
||||
</p>
|
||||
<div className="mb-3 flex justify-between">
|
||||
<label
|
||||
htmlFor="quantity"
|
||||
className="block text-xs text-gray-700 font-semibold"
|
||||
>
|
||||
{t("quantityofcredits")}
|
||||
<span className="text-[red] text-[13px]">*</span>
|
||||
</label>
|
||||
<select
|
||||
value={amount.quantity}
|
||||
onChange={(e) => handlePricePerQuick(e)}
|
||||
name="quantity"
|
||||
className="op-select op-select-bordered op-select-sm focus:outline-none hover:border-base-content w-1/4 text-xs"
|
||||
required
|
||||
>
|
||||
{quantityList.length > 0 &&
|
||||
quantityList.map((x) => (
|
||||
<option key={x} value={x}>
|
||||
{x}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="mb-3 flex justify-between">
|
||||
<label className="block text-xs text-gray-700 font-semibold">
|
||||
{t("Price")} (1 * {amount.priceperbulksend})
|
||||
</label>
|
||||
<div className="w-1/4 flex justify-center items-center text-sm">
|
||||
USD {amount.price}
|
||||
<>
|
||||
{admin?.isAdmin ? (
|
||||
<form onSubmit={handleAddOnQuickSubmit} className="p-3">
|
||||
<p className="flex justify-center text-center mx-2 mb-3 text-base op-text-accent font-medium">
|
||||
{t("additional-credits")}
|
||||
</p>
|
||||
<div className="mb-3 flex justify-between">
|
||||
<label
|
||||
htmlFor="quantity"
|
||||
className="block text-xs text-gray-700 font-semibold"
|
||||
>
|
||||
{t("quantityofcredits")}
|
||||
<span className="text-[red] text-[13px]">*</span>
|
||||
</label>
|
||||
<select
|
||||
value={amount.quantity}
|
||||
onChange={(e) => handlePricePerQuick(e)}
|
||||
name="quantity"
|
||||
className="op-select op-select-bordered op-select-sm focus:outline-none hover:border-base-content w-1/4 text-xs"
|
||||
required
|
||||
>
|
||||
{quantityList.length > 0 &&
|
||||
quantityList.map((x) => (
|
||||
<option key={x} value={x}>
|
||||
{x}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="mb-3 flex justify-between">
|
||||
<label className="block text-xs text-gray-700 font-semibold">
|
||||
{t("Price")} (1 * {amount.priceperbulksend})
|
||||
</label>
|
||||
<div className="w-1/4 flex justify-center items-center text-sm">
|
||||
USD {amount.price}
|
||||
</div>
|
||||
</div>
|
||||
<hr className="text-base-content mb-3" />
|
||||
<button className="op-btn op-btn-primary w-full mt-2">
|
||||
{t("Proceed")}
|
||||
</button>
|
||||
</form>
|
||||
) : (
|
||||
<div className="mx-8 mt-4 mb-8 flex justify-center text-center items-center font-medium break-all">
|
||||
{t("unauthorized-modal", {
|
||||
adminName: admin?.name,
|
||||
adminEmail: admin?.email
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<hr className="text-base-content mb-3" />
|
||||
<button className="op-btn op-btn-primary w-full mt-2">
|
||||
{t("Proceed")}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -56,7 +56,7 @@ export async function fetchSubscription(
|
||||
? { contactId: contactObjId }
|
||||
: { extUserId: extUser };
|
||||
const tenatRes = await axios.post(url, params, { headers: headers });
|
||||
let plan, status, billingDate;
|
||||
let plan, status, billingDate, adminId;
|
||||
if (isGuestSign) {
|
||||
plan = tenatRes.data?.result?.result?.plan;
|
||||
status = tenatRes.data?.result?.result?.isSubscribed;
|
||||
@@ -64,12 +64,13 @@ export async function fetchSubscription(
|
||||
plan = tenatRes.data?.result?.result?.PlanCode;
|
||||
billingDate = tenatRes.data?.result?.result?.Next_billing_date?.iso;
|
||||
const allowedUsers = tenatRes.data?.result?.result?.AllowedUsers || 0;
|
||||
adminId = tenatRes?.data?.result?.result?.ExtUserPtr?.objectId;
|
||||
localStorage.setItem("allowedUsers", allowedUsers);
|
||||
}
|
||||
return { plan, billingDate, status };
|
||||
return { plan, billingDate, status, adminId };
|
||||
} catch (err) {
|
||||
console.log("Err in fetch subscription", err);
|
||||
return { plan: "", billingDate: "" };
|
||||
return { plan: "", billingDate: "", status: "", adminId: "" };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,22 +123,22 @@ export async function checkIsSubscribed() {
|
||||
try {
|
||||
const res = await fetchSubscription();
|
||||
if (res.plan === "freeplan") {
|
||||
return { plan: res.plan, isValid: false };
|
||||
return { plan: res.plan, isValid: false, adminId: res?.adminId };
|
||||
} else if (res.billingDate) {
|
||||
const plan = validplan[res.plan] || false;
|
||||
if (plan && new Date(res.billingDate) > new Date()) {
|
||||
return { plan: res.plan, isValid: true };
|
||||
return { plan: res.plan, isValid: true, adminId: res?.adminId };
|
||||
} else if (new Date(res.billingDate) > new Date()) {
|
||||
return { plan: res.plan, isValid: true };
|
||||
return { plan: res.plan, isValid: true, adminId: res?.adminId };
|
||||
} else {
|
||||
return { plan: res.plan, isValid: false };
|
||||
return { plan: res.plan, isValid: false, adminId: res?.adminId };
|
||||
}
|
||||
} else {
|
||||
return { plan: res.plan, isValid: false };
|
||||
return { plan: res.plan, isValid: false, adminId: res?.adminId };
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("Err in fetch subscription", err);
|
||||
return { plan: "no-plan", isValid: false };
|
||||
return { plan: "no-plan", isValid: false, adminId: "" };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,16 @@ function GenerateToken() {
|
||||
const [isLoader, setIsLoader] = useState(true);
|
||||
const [isModal, setIsModal] = useState({
|
||||
generateapi: false,
|
||||
buyapis: false
|
||||
buyapis: false,
|
||||
unauthorized: false
|
||||
});
|
||||
const [isSubscribe, setIsSubscribe] = useState({
|
||||
plan: "",
|
||||
isValid: false,
|
||||
adminId: "",
|
||||
adminName: "",
|
||||
adminEmail: ""
|
||||
});
|
||||
const [isSubscribe, setIsSubscribe] = useState({ plan: "", isValid: false });
|
||||
const [isAlert, setIsAlert] = useState({ type: "success", msg: "" });
|
||||
const [isTour, setIsTour] = useState(false);
|
||||
const [amount, setAmount] = useState({
|
||||
@@ -139,10 +146,24 @@ function GenerateToken() {
|
||||
if (isSubscribe?.plan === "freeplan" && isEnableSubscription) {
|
||||
setIsTour(true);
|
||||
} else {
|
||||
setIsModal((obj) => ({ ...obj, buyapis: !obj.buyapis }));
|
||||
const extUser =
|
||||
localStorage.getItem("Extand_Class") &&
|
||||
JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||
if (isSubscribe?.adminId && extUser?.objectId === isSubscribe?.adminId) {
|
||||
setIsModal((obj) => ({ ...obj, buyapis: !obj.buyapis }));
|
||||
} else {
|
||||
setIsSubscribe((obj) => ({
|
||||
...obj,
|
||||
adminName: extUser?.CreatedBy?.name,
|
||||
adminEmail: extUser?.CreatedBy?.email
|
||||
}));
|
||||
setIsModal((obj) => ({ ...obj, unauthorized: !obj.unauthorized }));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleCloseModal = () => {
|
||||
setIsModal({ generateapi: false, buyapis: false, unauthorized: false });
|
||||
};
|
||||
const handlePricePerAPIs = (e) => {
|
||||
const quantity = e.target?.value;
|
||||
const price =
|
||||
@@ -374,7 +395,7 @@ function GenerateToken() {
|
||||
<ModalUi
|
||||
isOpen={isModal.buyapis}
|
||||
title={"Buy Credits"}
|
||||
handleClose={handleBuyAPIsModal}
|
||||
handleClose={handleCloseModal}
|
||||
>
|
||||
{isFormLoader && (
|
||||
<div className="absolute w-full h-full inset-0 flex justify-center items-center bg-base-content/30 z-50">
|
||||
@@ -419,6 +440,18 @@ function GenerateToken() {
|
||||
</button>
|
||||
</form>
|
||||
</ModalUi>
|
||||
<ModalUi
|
||||
isOpen={isModal.unauthorized}
|
||||
title={"Unauthorized"}
|
||||
handleClose={handleCloseModal}
|
||||
>
|
||||
<div className="m-8 flex justify-center text-center items-center font-medium break-all">
|
||||
{t("unauthorized-modal", {
|
||||
adminName: isSubscribe?.adminName,
|
||||
adminEmail: isSubscribe?.adminEmail
|
||||
})}
|
||||
</div>
|
||||
</ModalUi>
|
||||
</div>
|
||||
{isEnableSubscription && isSubscribe?.plan === "freeplan" && (
|
||||
<div data-tut="apisubscribe">
|
||||
|
||||
@@ -475,7 +475,7 @@
|
||||
"role-not-found": "Role not found.",
|
||||
"do-not-access": "You don't have access, please contact the admin.",
|
||||
"add-admin": "Add admin",
|
||||
"opensign-setup": "Opensign Setup",
|
||||
"opensign-setup": "OpenSign Setup",
|
||||
"join-discord": "Join our discord server",
|
||||
"admin-already-exist": "Admin already exist.",
|
||||
"password-update-alert-1": "Password updated successfully.",
|
||||
@@ -531,7 +531,7 @@
|
||||
"filed-required-correctly": "Please fill required details correctly.",
|
||||
"admin-created": "Admin created",
|
||||
"invalid-masterkey": "Invalid masterkey",
|
||||
"opensign-Setup": "Opensign Setup",
|
||||
"opensign-Setup": "OpenSign Setup",
|
||||
"master-key": " Master key",
|
||||
"profile-update-alert": "Profile updated successfully.",
|
||||
"date": "Date",
|
||||
@@ -631,6 +631,7 @@
|
||||
"quotamailselfsign": "You've reached your limit of 20 emails for this month. Upgrade now to continue sending emails directly.",
|
||||
"quotamail": "You've reached your limit of 20 signature request emails for this month. Upgrade now to continue sending emails directly.",
|
||||
"quotamailTip":"Tip: You can still sign unlimited documents by manually sharing the signing request links below.",
|
||||
"quotamailhead":"Quota Reached"
|
||||
"quotamailhead":"Quota Reached",
|
||||
"unauthorized-modal":"You don't have permission to perform this action, please contact {{adminName}}<{{adminEmail}}>."
|
||||
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@
|
||||
"role-not-found": "Rôle introuvable.",
|
||||
"do-not-access": "Vous n'y avez pas accès, veuillez contacter l'administrateur.",
|
||||
"add-admin": "Ajouter un administrateur",
|
||||
"opensign-setup": "Configuration d'Opensign",
|
||||
"opensign-setup": "Configuration d'OpenSign",
|
||||
"join-discord": "Rejoignez notre serveur Discord",
|
||||
"admin-already-exist": "L'administrateur existe déjà.",
|
||||
"password-update-alert-1": "Mot de passe mis à jour avec succès.",
|
||||
@@ -530,7 +530,7 @@
|
||||
"filed-required-correctly": "Veuillez remplir correctement les informations requises.",
|
||||
"admin-created": "Administrateur créé",
|
||||
"invalid-masterkey": "Clé principale invalide",
|
||||
"opensign-Setup": "Configuration d'Opensign",
|
||||
"opensign-Setup": "Configuration d'OpenSign",
|
||||
"master-key": "La clef maitresse",
|
||||
"profile-update-alert": "Mise à jour du profil réussie.",
|
||||
"date": "Date",
|
||||
@@ -631,6 +631,7 @@
|
||||
"quotamailselfsign": "Vous avez atteint votre limite de 20 e-mails pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
|
||||
"quotamail": "Vous avez atteint votre limite de 20 e-mails de demande de signature pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
|
||||
"quotamailTip":"Astuce : Vous pouvez toujours signer un nombre illimité de documents en partageant manuellement les liens de demande de signature ci-dessous.",
|
||||
"quotamailhead":"Quota atteint"
|
||||
"quotamailhead":"Quota atteint",
|
||||
"unauthorized-modal":"Vous n'êtes pas autorisé à effectuer cette action, veuillez contacter {{adminName}}<{{adminEmail}}>."
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user