mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-09-29 04:54:56 +02:00
fix: correct email validation in forms
This commit is contained in:
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
|
|||||||
import Parse from "parse";
|
import Parse from "parse";
|
||||||
import Loader from "../primitives/Loader";
|
import Loader from "../primitives/Loader";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { emailRegex } from "../constant/const";
|
||||||
|
|
||||||
const AddSigner = (props) => {
|
const AddSigner = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -47,139 +48,143 @@ const AddSigner = (props) => {
|
|||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsLoader(true);
|
if (!emailRegex.test(email)) {
|
||||||
if (localStorage.getItem("TenantId")) {
|
alert("Please enter a valid email address.");
|
||||||
try {
|
} else {
|
||||||
const user = Parse.User.current();
|
setIsLoader(true);
|
||||||
const query = new Parse.Query("contracts_Contactbook");
|
if (localStorage.getItem("TenantId")) {
|
||||||
query.equalTo("CreatedBy", user);
|
try {
|
||||||
query.notEqualTo("IsDeleted", true);
|
const user = Parse.User.current();
|
||||||
query.equalTo("Email", email);
|
const query = new Parse.Query("contracts_Contactbook");
|
||||||
const res = await query.first();
|
query.equalTo("CreatedBy", user);
|
||||||
// console.log(res);
|
query.notEqualTo("IsDeleted", true);
|
||||||
if (!res) {
|
query.equalTo("Email", email);
|
||||||
const contactQuery = new Parse.Object("contracts_Contactbook");
|
const res = await query.first();
|
||||||
contactQuery.set("Name", name);
|
// console.log(res);
|
||||||
if (phone) {
|
if (!res) {
|
||||||
contactQuery.set("Phone", phone);
|
const contactQuery = new Parse.Object("contracts_Contactbook");
|
||||||
}
|
contactQuery.set("Name", name);
|
||||||
contactQuery.set("Email", email);
|
|
||||||
contactQuery.set("UserRole", "contracts_Guest");
|
|
||||||
|
|
||||||
contactQuery.set("TenantId", {
|
|
||||||
__type: "Pointer",
|
|
||||||
className: "partners_Tenant",
|
|
||||||
objectId: localStorage.getItem("TenantId")
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const _users = Parse.Object.extend("User");
|
|
||||||
const _user = new _users();
|
|
||||||
_user.set("name", name);
|
|
||||||
_user.set("username", email);
|
|
||||||
_user.set("email", email);
|
|
||||||
_user.set("password", email);
|
|
||||||
if (phone) {
|
if (phone) {
|
||||||
_user.set("phone", phone);
|
contactQuery.set("Phone", phone);
|
||||||
}
|
}
|
||||||
const user = await _user.save();
|
contactQuery.set("Email", email);
|
||||||
if (user) {
|
contactQuery.set("UserRole", "contracts_Guest");
|
||||||
const currentUser = Parse.User.current();
|
|
||||||
contactQuery.set(
|
|
||||||
"CreatedBy",
|
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
|
||||||
);
|
|
||||||
|
|
||||||
contactQuery.set("UserId", user);
|
contactQuery.set("TenantId", {
|
||||||
const acl = new Parse.ACL();
|
__type: "Pointer",
|
||||||
acl.setPublicReadAccess(true);
|
className: "partners_Tenant",
|
||||||
acl.setPublicWriteAccess(true);
|
objectId: localStorage.getItem("TenantId")
|
||||||
acl.setReadAccess(currentUser.id, true);
|
});
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
|
||||||
|
|
||||||
contactQuery.setACL(acl);
|
try {
|
||||||
|
const _users = Parse.Object.extend("User");
|
||||||
|
const _user = new _users();
|
||||||
|
_user.set("name", name);
|
||||||
|
_user.set("username", email);
|
||||||
|
_user.set("email", email);
|
||||||
|
_user.set("password", email);
|
||||||
|
if (phone) {
|
||||||
|
_user.set("phone", phone);
|
||||||
|
}
|
||||||
|
const user = await _user.save();
|
||||||
|
if (user) {
|
||||||
|
const currentUser = Parse.User.current();
|
||||||
|
contactQuery.set(
|
||||||
|
"CreatedBy",
|
||||||
|
Parse.User.createWithoutData(currentUser.id)
|
||||||
|
);
|
||||||
|
|
||||||
const res = await contactQuery.save();
|
contactQuery.set("UserId", user);
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setPublicReadAccess(true);
|
||||||
|
acl.setPublicWriteAccess(true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
contactQuery.setACL(acl);
|
||||||
if (props.details) {
|
|
||||||
props.details({
|
const res = await contactQuery.save();
|
||||||
value: parseData[props.valueKey],
|
|
||||||
label: parseData[props.displayKey]
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
if (props.details) {
|
||||||
|
props.details({
|
||||||
|
value: parseData[props.valueKey],
|
||||||
|
label: parseData[props.displayKey]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (props.closePopup) {
|
||||||
|
props.closePopup();
|
||||||
|
}
|
||||||
|
if (props.handleUserData) {
|
||||||
|
props.handleUserData(parseData);
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLoader(false);
|
||||||
|
// Reset the form fields
|
||||||
|
setAddYourself(false);
|
||||||
|
setName("");
|
||||||
|
setPhone("");
|
||||||
|
setEmail("");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err ", err);
|
||||||
|
if (err.code === 202) {
|
||||||
|
const params = { email: email };
|
||||||
|
const userRes = await Parse.Cloud.run("getUserId", params);
|
||||||
|
const currentUser = Parse.User.current();
|
||||||
|
contactQuery.set(
|
||||||
|
"CreatedBy",
|
||||||
|
Parse.User.createWithoutData(currentUser.id)
|
||||||
|
);
|
||||||
|
|
||||||
|
contactQuery.set("UserId", {
|
||||||
|
__type: "Pointer",
|
||||||
|
className: "_User",
|
||||||
|
objectId: userRes.id
|
||||||
});
|
});
|
||||||
}
|
const acl = new Parse.ACL();
|
||||||
if (props.closePopup) {
|
acl.setPublicReadAccess(true);
|
||||||
props.closePopup();
|
acl.setPublicWriteAccess(true);
|
||||||
}
|
acl.setReadAccess(currentUser.id, true);
|
||||||
if (props.handleUserData) {
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
props.handleUserData(parseData);
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsLoader(false);
|
contactQuery.setACL(acl);
|
||||||
// Reset the form fields
|
const res = await contactQuery.save();
|
||||||
setAddYourself(false);
|
|
||||||
setName("");
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
setPhone("");
|
if (props.details) {
|
||||||
setEmail("");
|
props.details({
|
||||||
}
|
value: parseData[props.valueKey],
|
||||||
} catch (err) {
|
label: parseData[props.displayKey]
|
||||||
console.log("err ", err);
|
});
|
||||||
if (err.code === 202) {
|
}
|
||||||
const params = { email: email };
|
if (props.closePopup) {
|
||||||
const userRes = await Parse.Cloud.run("getUserId", params);
|
props.closePopup();
|
||||||
const currentUser = Parse.User.current();
|
}
|
||||||
contactQuery.set(
|
if (props.handleUserData) {
|
||||||
"CreatedBy",
|
props.handleUserData(parseData);
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
}
|
||||||
);
|
setIsLoader(false);
|
||||||
|
// Reset the form fields
|
||||||
contactQuery.set("UserId", {
|
setAddYourself(false);
|
||||||
__type: "Pointer",
|
setName("");
|
||||||
className: "_User",
|
setPhone("");
|
||||||
objectId: userRes.id
|
setEmail("");
|
||||||
});
|
}
|
||||||
const acl = new Parse.ACL();
|
|
||||||
acl.setPublicReadAccess(true);
|
|
||||||
acl.setPublicWriteAccess(true);
|
|
||||||
acl.setReadAccess(currentUser.id, true);
|
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
|
||||||
|
|
||||||
contactQuery.setACL(acl);
|
|
||||||
const res = await contactQuery.save();
|
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
|
||||||
if (props.details) {
|
|
||||||
props.details({
|
|
||||||
value: parseData[props.valueKey],
|
|
||||||
label: parseData[props.displayKey]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (props.closePopup) {
|
|
||||||
props.closePopup();
|
|
||||||
}
|
|
||||||
if (props.handleUserData) {
|
|
||||||
props.handleUserData(parseData);
|
|
||||||
}
|
|
||||||
setIsLoader(false);
|
|
||||||
// Reset the form fields
|
|
||||||
setAddYourself(false);
|
|
||||||
setName("");
|
|
||||||
setPhone("");
|
|
||||||
setEmail("");
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
alert(t("add-signer-alert"));
|
||||||
|
setIsLoader(false);
|
||||||
}
|
}
|
||||||
} else {
|
} catch (err) {
|
||||||
alert(t("add-signer-alert"));
|
console.log("err in fetch contact", err);
|
||||||
setIsLoader(false);
|
setIsLoader(false);
|
||||||
|
alert(t("something-went-wrong-mssg"));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} else {
|
||||||
console.log("err in fetch contact", err);
|
|
||||||
setIsLoader(false);
|
setIsLoader(false);
|
||||||
alert(t("something-went-wrong-mssg"));
|
alert(t("something-went-wrong-mssg"));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setIsLoader(false);
|
|
||||||
alert(t("something-went-wrong-mssg"));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Parse from "parse";
|
|||||||
import Title from "./Title";
|
import Title from "./Title";
|
||||||
import Loader from "../primitives/Loader";
|
import Loader from "../primitives/Loader";
|
||||||
import { copytoData, fetchSubscriptionInfo } from "../constant/Utils";
|
import { copytoData, fetchSubscriptionInfo } from "../constant/Utils";
|
||||||
import { isEnableSubscription } from "../constant/const";
|
import { emailRegex, isEnableSubscription } from "../constant/const";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
function generatePassword(length) {
|
function generatePassword(length) {
|
||||||
const characters =
|
const characters =
|
||||||
@@ -115,149 +115,172 @@ const AddUser = (props) => {
|
|||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const localUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
if (!emailRegex.test(formdata.email)) {
|
||||||
setIsFormLoader(true);
|
alert("Please enter a valid email address.");
|
||||||
const res = await checkUserExist();
|
|
||||||
if (res) {
|
|
||||||
props.setIsAlert({ type: "danger", msg: t("user-already-exist") });
|
|
||||||
setIsFormLoader(false);
|
|
||||||
setTimeout(() => props.setIsAlert({ type: "success", msg: "" }), 1000);
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
const localUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||||
const extUser = new Parse.Object("contracts_Users");
|
setIsFormLoader(true);
|
||||||
extUser.set("Name", formdata.name);
|
const res = await checkUserExist();
|
||||||
if (formdata.phone) {
|
if (res) {
|
||||||
extUser.set("Phone", formdata.phone);
|
props.setIsAlert({ type: "danger", msg: t("user-already-exist") });
|
||||||
}
|
setIsFormLoader(false);
|
||||||
extUser.set("Email", formdata.email);
|
setTimeout(() => props.setIsAlert({ type: "success", msg: "" }), 1000);
|
||||||
extUser.set("UserRole", `contracts_${formdata.role}`);
|
} else {
|
||||||
if (formdata?.team) {
|
|
||||||
extUser.set("TeamIds", [
|
|
||||||
{
|
|
||||||
__type: "Pointer",
|
|
||||||
className: "contracts_Teams",
|
|
||||||
objectId: formdata.team
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
if (localUser && localUser.OrganizationId) {
|
|
||||||
extUser.set("OrganizationId", {
|
|
||||||
__type: "Pointer",
|
|
||||||
className: "contracts_Organizations",
|
|
||||||
objectId: localUser.OrganizationId.objectId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (localUser && localUser.Company) {
|
|
||||||
extUser.set("Company", localUser.Company);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (localStorage.getItem("TenantId")) {
|
|
||||||
extUser.set("TenantId", {
|
|
||||||
__type: "Pointer",
|
|
||||||
className: "partners_Tenant",
|
|
||||||
objectId: localStorage.getItem("TenantId")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const _users = Parse.Object.extend("User");
|
const extUser = new Parse.Object("contracts_Users");
|
||||||
const _user = new _users();
|
extUser.set("Name", formdata.name);
|
||||||
_user.set("name", formdata.name);
|
|
||||||
_user.set("username", formdata.email);
|
|
||||||
_user.set("email", formdata.email);
|
|
||||||
_user.set("password", formdata.password);
|
|
||||||
if (formdata.phone) {
|
if (formdata.phone) {
|
||||||
_user.set("phone", formdata.phone);
|
extUser.set("Phone", formdata.phone);
|
||||||
|
}
|
||||||
|
extUser.set("Email", formdata.email);
|
||||||
|
extUser.set("UserRole", `contracts_${formdata.role}`);
|
||||||
|
if (formdata?.team) {
|
||||||
|
extUser.set("TeamIds", [
|
||||||
|
{
|
||||||
|
__type: "Pointer",
|
||||||
|
className: "contracts_Teams",
|
||||||
|
objectId: formdata.team
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (localUser && localUser.OrganizationId) {
|
||||||
|
extUser.set("OrganizationId", {
|
||||||
|
__type: "Pointer",
|
||||||
|
className: "contracts_Organizations",
|
||||||
|
objectId: localUser.OrganizationId.objectId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (localUser && localUser.Company) {
|
||||||
|
extUser.set("Company", localUser.Company);
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await _user.save();
|
if (localStorage.getItem("TenantId")) {
|
||||||
if (user) {
|
extUser.set("TenantId", {
|
||||||
const currentUser = Parse.User.current();
|
__type: "Pointer",
|
||||||
extUser.set(
|
className: "partners_Tenant",
|
||||||
"CreatedBy",
|
objectId: localStorage.getItem("TenantId")
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
});
|
||||||
);
|
}
|
||||||
|
|
||||||
extUser.set("UserId", user);
|
try {
|
||||||
const acl = new Parse.ACL();
|
const _users = Parse.Object.extend("User");
|
||||||
acl.setPublicReadAccess(true);
|
const _user = new _users();
|
||||||
acl.setPublicWriteAccess(true);
|
_user.set("name", formdata.name);
|
||||||
acl.setReadAccess(currentUser.id, true);
|
_user.set("username", formdata.email);
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
_user.set("email", formdata.email);
|
||||||
|
_user.set("password", formdata.password);
|
||||||
extUser.setACL(acl);
|
if (formdata.phone) {
|
||||||
|
_user.set("phone", formdata.phone);
|
||||||
const res = await extUser.save();
|
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
|
||||||
|
|
||||||
if (props.closePopup) {
|
|
||||||
props.closePopup();
|
|
||||||
}
|
}
|
||||||
if (props.handleUserData) {
|
|
||||||
if (formdata?.team) {
|
const user = await _user.save();
|
||||||
const team = teamList.find((x) => x.objectId === formdata.team);
|
if (user) {
|
||||||
parseData.TeamIds = parseData.TeamIds.map((y) =>
|
const currentUser = Parse.User.current();
|
||||||
y.objectId === team.objectId ? team : y
|
extUser.set(
|
||||||
);
|
"CreatedBy",
|
||||||
|
Parse.User.createWithoutData(currentUser.id)
|
||||||
|
);
|
||||||
|
|
||||||
|
extUser.set("UserId", user);
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setPublicReadAccess(true);
|
||||||
|
acl.setPublicWriteAccess(true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
|
||||||
|
extUser.setACL(acl);
|
||||||
|
|
||||||
|
const res = await extUser.save();
|
||||||
|
|
||||||
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
|
||||||
|
if (props.closePopup) {
|
||||||
|
props.closePopup();
|
||||||
|
}
|
||||||
|
if (props.handleUserData) {
|
||||||
|
if (formdata?.team) {
|
||||||
|
const team = teamList.find(
|
||||||
|
(x) => x.objectId === formdata.team
|
||||||
|
);
|
||||||
|
parseData.TeamIds = parseData.TeamIds.map((y) =>
|
||||||
|
y.objectId === team.objectId ? team : y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
props.handleUserData(parseData);
|
||||||
}
|
}
|
||||||
props.handleUserData(parseData);
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsFormLoader(false);
|
setIsFormLoader(false);
|
||||||
setFormdata({ name: "", email: "", phone: "", team: "", role: "" });
|
setFormdata({
|
||||||
|
name: "",
|
||||||
|
email: "",
|
||||||
|
phone: "",
|
||||||
|
team: "",
|
||||||
|
role: ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err ", err);
|
||||||
|
if (err.code === 202) {
|
||||||
|
const params = { email: formdata.email };
|
||||||
|
const userRes = await Parse.Cloud.run("getUserId", params);
|
||||||
|
const currentUser = Parse.User.current();
|
||||||
|
extUser.set(
|
||||||
|
"CreatedBy",
|
||||||
|
Parse.User.createWithoutData(currentUser.id)
|
||||||
|
);
|
||||||
|
|
||||||
|
extUser.set("UserId", {
|
||||||
|
__type: "Pointer",
|
||||||
|
className: "_User",
|
||||||
|
objectId: userRes.id
|
||||||
|
});
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setPublicReadAccess(true);
|
||||||
|
acl.setPublicWriteAccess(true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
|
||||||
|
extUser.setACL(acl);
|
||||||
|
const res = await extUser.save();
|
||||||
|
|
||||||
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
if (props.closePopup) {
|
||||||
|
props.closePopup();
|
||||||
|
}
|
||||||
|
if (props.handleUserData) {
|
||||||
|
if (formdata?.team) {
|
||||||
|
const team = teamList.find(
|
||||||
|
(x) => x.objectId === formdata.team
|
||||||
|
);
|
||||||
|
parseData.TeamIds = parseData.TeamIds.map((y) =>
|
||||||
|
y.objectId === team.objectId ? team : y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
props.handleUserData(parseData);
|
||||||
|
}
|
||||||
|
setIsFormLoader(false);
|
||||||
|
setFormdata({
|
||||||
|
name: "",
|
||||||
|
email: "",
|
||||||
|
phone: "",
|
||||||
|
team: "",
|
||||||
|
role: ""
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("err ", err);
|
console.log("err", err);
|
||||||
if (err.code === 202) {
|
setIsFormLoader(false);
|
||||||
const params = { email: formdata.email };
|
props.setIsAlert({
|
||||||
const userRes = await Parse.Cloud.run("getUserId", params);
|
type: "danger",
|
||||||
const currentUser = Parse.User.current();
|
msg: t("something-went-wrong-mssg")
|
||||||
extUser.set(
|
});
|
||||||
"CreatedBy",
|
} finally {
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
setTimeout(
|
||||||
);
|
() => props.setIsAlert({ type: "success", msg: "" }),
|
||||||
|
1500
|
||||||
extUser.set("UserId", {
|
);
|
||||||
__type: "Pointer",
|
|
||||||
className: "_User",
|
|
||||||
objectId: userRes.id
|
|
||||||
});
|
|
||||||
const acl = new Parse.ACL();
|
|
||||||
acl.setPublicReadAccess(true);
|
|
||||||
acl.setPublicWriteAccess(true);
|
|
||||||
acl.setReadAccess(currentUser.id, true);
|
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
|
||||||
|
|
||||||
extUser.setACL(acl);
|
|
||||||
const res = await extUser.save();
|
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
|
||||||
if (props.closePopup) {
|
|
||||||
props.closePopup();
|
|
||||||
}
|
|
||||||
if (props.handleUserData) {
|
|
||||||
if (formdata?.team) {
|
|
||||||
const team = teamList.find((x) => x.objectId === formdata.team);
|
|
||||||
parseData.TeamIds = parseData.TeamIds.map((y) =>
|
|
||||||
y.objectId === team.objectId ? team : y
|
|
||||||
);
|
|
||||||
}
|
|
||||||
props.handleUserData(parseData);
|
|
||||||
}
|
|
||||||
setIsFormLoader(false);
|
|
||||||
setFormdata({ name: "", email: "", phone: "", team: "", role: "" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
console.log("err", err);
|
|
||||||
setIsFormLoader(false);
|
|
||||||
props.setIsAlert({
|
|
||||||
type: "danger",
|
|
||||||
msg: t("something-went-wrong-mssg")
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setTimeout(() => props.setIsAlert({ type: "success", msg: "" }), 1500);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,15 +9,13 @@ function SelectLanguage(props) {
|
|||||||
{ value: "es", text: "Española" },
|
{ value: "es", text: "Española" },
|
||||||
{ value: "fr", text: "Français" }
|
{ value: "fr", text: "Français" }
|
||||||
];
|
];
|
||||||
const [lang, setLang] = useState(i18next.language || "en");
|
const defaultLanguage = i18next.language || "en";
|
||||||
|
const [lang, setLang] = useState(defaultLanguage);
|
||||||
// This function put query that helps to change the language
|
// This function put query that helps to change the language
|
||||||
const handleChangeLang = (e) => {
|
const handleChangeLang = (e) => {
|
||||||
setLang(e.target.value);
|
setLang(e.target.value);
|
||||||
i18n.changeLanguage(e.target.value);
|
i18n.changeLanguage(e.target.value);
|
||||||
props?.updateExtUser &&
|
props?.updateExtUser && props.updateExtUser({ language: e.target.value });
|
||||||
props.updateExtUser({
|
|
||||||
language: e.target.value
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -32,9 +30,7 @@ function SelectLanguage(props) {
|
|||||||
!props.isProfile ? " md:w-[15%] w-[50%]" : "w-[180px]"
|
!props.isProfile ? " md:w-[15%] w-[50%]" : "w-[180px]"
|
||||||
} op-select op-select-bordered bg-white op-select-sm `}
|
} op-select op-select-bordered bg-white op-select-sm `}
|
||||||
>
|
>
|
||||||
<option disabled selected>
|
<option disabled>select</option>
|
||||||
select
|
|
||||||
</option>
|
|
||||||
{languages.map((item) => {
|
{languages.map((item) => {
|
||||||
return (
|
return (
|
||||||
<option key={item.value} value={item.value}>
|
<option key={item.value} value={item.value}>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { showTenant } from "../redux/reducers/ShowTenant";
|
|||||||
import Loader from "../primitives/Loader";
|
import Loader from "../primitives/Loader";
|
||||||
import Title from "../components/Title";
|
import Title from "../components/Title";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { emailRegex } from "../constant/const";
|
||||||
|
|
||||||
const AddAdmin = () => {
|
const AddAdmin = () => {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
@@ -84,77 +85,81 @@ const AddAdmin = () => {
|
|||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (lengthValid && caseDigitValid && specialCharValid) {
|
if (!emailRegex.test(email)) {
|
||||||
clearStorage();
|
alert("Please enter a valid email address.");
|
||||||
setState({ loading: true });
|
} else {
|
||||||
const userDetails = {
|
if (lengthValid && caseDigitValid && specialCharValid) {
|
||||||
name: name,
|
clearStorage();
|
||||||
email: email,
|
setState({ loading: true });
|
||||||
phone: phone,
|
const userDetails = {
|
||||||
company: company,
|
name: name,
|
||||||
jobTitle: jobTitle
|
email: email,
|
||||||
};
|
phone: phone,
|
||||||
localStorage.setItem("userDetails", JSON.stringify(userDetails));
|
company: company,
|
||||||
try {
|
jobTitle: jobTitle
|
||||||
event.preventDefault();
|
};
|
||||||
const user = new Parse.User();
|
localStorage.setItem("userDetails", JSON.stringify(userDetails));
|
||||||
user.set("name", name);
|
try {
|
||||||
user.set("email", email);
|
event.preventDefault();
|
||||||
user.set("password", password);
|
const user = new Parse.User();
|
||||||
user.set("phone", phone);
|
user.set("name", name);
|
||||||
user.set("username", email);
|
user.set("email", email);
|
||||||
const userRes = await user.save();
|
user.set("password", password);
|
||||||
if (userRes) {
|
user.set("phone", phone);
|
||||||
const params = {
|
user.set("username", email);
|
||||||
userDetails: {
|
const userRes = await user.save();
|
||||||
jobTitle: jobTitle,
|
if (userRes) {
|
||||||
company: company,
|
const params = {
|
||||||
name: name,
|
userDetails: {
|
||||||
email: email,
|
jobTitle: jobTitle,
|
||||||
phone: phone,
|
company: company,
|
||||||
role: "contracts_Admin"
|
name: name,
|
||||||
}
|
email: email,
|
||||||
};
|
phone: phone,
|
||||||
try {
|
role: "contracts_Admin"
|
||||||
const usersignup = await Parse.Cloud.run("addadmin", params);
|
|
||||||
if (usersignup) {
|
|
||||||
if (isSubscribeNews) {
|
|
||||||
subscribeNewsletter();
|
|
||||||
}
|
}
|
||||||
handleNavigation(userRes.getSessionToken());
|
};
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
alert(err.message);
|
|
||||||
setState({ loading: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log("err ", error);
|
|
||||||
if (error.code === 202) {
|
|
||||||
const params = { email: email };
|
|
||||||
const res = await Parse.Cloud.run("getUserDetails", params);
|
|
||||||
// console.log("Res ", res);
|
|
||||||
if (res) {
|
|
||||||
alert(t("already-exists-this-username"));
|
|
||||||
setState({ loading: false });
|
|
||||||
} else {
|
|
||||||
// console.log("state.email ", email);
|
|
||||||
try {
|
try {
|
||||||
await Parse.User.requestPasswordReset(email).then(
|
const usersignup = await Parse.Cloud.run("addadmin", params);
|
||||||
async function (res) {
|
if (usersignup) {
|
||||||
if (res.data === undefined) {
|
if (isSubscribeNews) {
|
||||||
alert(t("verification-code-sent"));
|
subscribeNewsletter();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
handleNavigation(userRes.getSessionToken());
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
alert(err.message);
|
||||||
|
setState({ loading: false });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("err ", error);
|
||||||
|
if (error.code === 202) {
|
||||||
|
const params = { email: email };
|
||||||
|
const res = await Parse.Cloud.run("getUserDetails", params);
|
||||||
|
// console.log("Res ", res);
|
||||||
|
if (res) {
|
||||||
|
alert(t("already-exists-this-username"));
|
||||||
|
setState({ loading: false });
|
||||||
|
} else {
|
||||||
|
// console.log("state.email ", email);
|
||||||
|
try {
|
||||||
|
await Parse.User.requestPasswordReset(email).then(
|
||||||
|
async function (res) {
|
||||||
|
if (res.data === undefined) {
|
||||||
|
alert(t("verification-code-sent"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
setState({ loading: false });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(error.message);
|
||||||
setState({ loading: false });
|
setState({ loading: false });
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
alert(error.message);
|
|
||||||
setState({ loading: false });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import Alert from "../primitives/Alert";
|
|||||||
import { appInfo } from "../constant/appinfo";
|
import { appInfo } from "../constant/appinfo";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
||||||
import { isEnableSubscription } from "../constant/const";
|
import { emailRegex, isEnableSubscription } from "../constant/const";
|
||||||
import { getAppLogo } from "../constant/Utils";
|
import { getAppLogo } from "../constant/Utils";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
@@ -36,18 +36,22 @@ function ForgotPassword() {
|
|||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
localStorage.setItem("appLogo", appInfo.applogo);
|
if (!emailRegex.test(state.email)) {
|
||||||
localStorage.setItem("userSettings", JSON.stringify(appInfo.settings));
|
alert("Please enter a valid email address.");
|
||||||
if (state.email) {
|
} else {
|
||||||
const username = state.email;
|
localStorage.setItem("appLogo", appInfo.applogo);
|
||||||
try {
|
localStorage.setItem("userSettings", JSON.stringify(appInfo.settings));
|
||||||
await Parse.User.requestPasswordReset(username);
|
if (state.email) {
|
||||||
setSentStatus("success");
|
const username = state.email;
|
||||||
} catch (err) {
|
try {
|
||||||
console.log("err ", err.code);
|
await Parse.User.requestPasswordReset(username);
|
||||||
setSentStatus("failed");
|
setSentStatus("success");
|
||||||
} finally {
|
} catch (err) {
|
||||||
setTimeout(() => setSentStatus(""), 1000);
|
console.log("err ", err.code);
|
||||||
|
setSentStatus("failed");
|
||||||
|
} finally {
|
||||||
|
setTimeout(() => setSentStatus(""), 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+147
-140
@@ -9,7 +9,7 @@ import { NavLink, useNavigate, useLocation } from "react-router-dom";
|
|||||||
import login_img from "../assets/images/login_img.svg";
|
import login_img from "../assets/images/login_img.svg";
|
||||||
import { useWindowSize } from "../hook/useWindowSize";
|
import { useWindowSize } from "../hook/useWindowSize";
|
||||||
import ModalUi from "../primitives/ModalUi";
|
import ModalUi from "../primitives/ModalUi";
|
||||||
import { isEnableSubscription } from "../constant/const";
|
import { emailRegex, isEnableSubscription } from "../constant/const";
|
||||||
import Alert from "../primitives/Alert";
|
import Alert from "../primitives/Alert";
|
||||||
import { appInfo } from "../constant/appinfo";
|
import { appInfo } from "../constant/appinfo";
|
||||||
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
||||||
@@ -89,167 +89,174 @@ function Login() {
|
|||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
localStorage.removeItem("accesstoken");
|
localStorage.removeItem("accesstoken");
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const { email, password } = state;
|
if (!emailRegex.test(state.email)) {
|
||||||
if (email && password) {
|
alert("Please enter a valid email address.");
|
||||||
try {
|
} else {
|
||||||
setState({ ...state, loading: true });
|
const { email, password } = state;
|
||||||
localStorage.setItem("appLogo", appInfo.applogo);
|
if (email && password) {
|
||||||
// Pass the username and password to logIn function
|
try {
|
||||||
const user = await Parse.User.logIn(email, password);
|
setState({ ...state, loading: true });
|
||||||
if (user) {
|
localStorage.setItem("appLogo", appInfo.applogo);
|
||||||
let _user = user.toJSON();
|
// Pass the username and password to logIn function
|
||||||
localStorage.setItem("UserInformation", JSON.stringify(_user));
|
const user = await Parse.User.logIn(email, password);
|
||||||
localStorage.setItem("userEmail", email);
|
if (user) {
|
||||||
localStorage.setItem("accesstoken", _user.sessionToken);
|
let _user = user.toJSON();
|
||||||
localStorage.setItem("scriptId", true);
|
localStorage.setItem("UserInformation", JSON.stringify(_user));
|
||||||
if (_user.ProfilePic) {
|
localStorage.setItem("userEmail", email);
|
||||||
localStorage.setItem("profileImg", _user.ProfilePic);
|
localStorage.setItem("accesstoken", _user.sessionToken);
|
||||||
} else {
|
localStorage.setItem("scriptId", true);
|
||||||
localStorage.setItem("profileImg", "");
|
if (_user.ProfilePic) {
|
||||||
}
|
localStorage.setItem("profileImg", _user.ProfilePic);
|
||||||
// Check extended class user role and tenentId
|
} else {
|
||||||
try {
|
localStorage.setItem("profileImg", "");
|
||||||
const userSettings = appInfo.settings;
|
}
|
||||||
await Parse.Cloud.run("getUserDetails")
|
// Check extended class user role and tenentId
|
||||||
.then(async (extUser) => {
|
try {
|
||||||
if (extUser) {
|
const userSettings = appInfo.settings;
|
||||||
// console.log("extUser", extUser, extUser?.get("IsDisabled"));
|
await Parse.Cloud.run("getUserDetails")
|
||||||
const IsDisabled = extUser?.get("IsDisabled") || false;
|
.then(async (extUser) => {
|
||||||
if (!IsDisabled) {
|
if (extUser) {
|
||||||
const userRole = extUser?.get("UserRole");
|
// console.log("extUser", extUser, extUser?.get("IsDisabled"));
|
||||||
const menu =
|
const IsDisabled = extUser?.get("IsDisabled") || false;
|
||||||
userRole &&
|
if (!IsDisabled) {
|
||||||
userSettings.find((menu) => menu.role === userRole);
|
const userRole = extUser?.get("UserRole");
|
||||||
if (menu) {
|
const menu =
|
||||||
const _currentRole = userRole;
|
userRole &&
|
||||||
const redirectUrl =
|
userSettings.find((menu) => menu.role === userRole);
|
||||||
location?.state?.from ||
|
if (menu) {
|
||||||
`/${menu.pageType}/${menu.pageId}`;
|
const _currentRole = userRole;
|
||||||
let _role = _currentRole.replace("contracts_", "");
|
const redirectUrl =
|
||||||
localStorage.setItem("_user_role", _role);
|
location?.state?.from ||
|
||||||
const checkLanguage = extUser?.get("Language");
|
`/${menu.pageType}/${menu.pageId}`;
|
||||||
if (checkLanguage) {
|
let _role = _currentRole.replace("contracts_", "");
|
||||||
checkLanguage && i18n.changeLanguage(checkLanguage);
|
localStorage.setItem("_user_role", _role);
|
||||||
}
|
const checkLanguage = extUser?.get("Language");
|
||||||
|
if (checkLanguage) {
|
||||||
|
checkLanguage && i18n.changeLanguage(checkLanguage);
|
||||||
|
}
|
||||||
|
|
||||||
const results = [extUser];
|
const results = [extUser];
|
||||||
const extUser_str = JSON.stringify(results);
|
const extUser_str = JSON.stringify(results);
|
||||||
|
|
||||||
localStorage.setItem("Extand_Class", extUser_str);
|
localStorage.setItem("Extand_Class", extUser_str);
|
||||||
const extInfo = JSON.parse(JSON.stringify(extUser));
|
const extInfo = JSON.parse(JSON.stringify(extUser));
|
||||||
localStorage.setItem("userEmail", extInfo.Email);
|
localStorage.setItem("userEmail", extInfo.Email);
|
||||||
localStorage.setItem("username", extInfo.Name);
|
localStorage.setItem("username", extInfo.Name);
|
||||||
if (extInfo?.TenantId) {
|
if (extInfo?.TenantId) {
|
||||||
const tenant = {
|
const tenant = {
|
||||||
Id: extInfo?.TenantId?.objectId || "",
|
Id: extInfo?.TenantId?.objectId || "",
|
||||||
Name: extInfo?.TenantId?.TenantName || ""
|
Name: extInfo?.TenantId?.TenantName || ""
|
||||||
};
|
};
|
||||||
localStorage.setItem("TenantId", tenant?.Id);
|
localStorage.setItem("TenantId", tenant?.Id);
|
||||||
dispatch(showTenant(tenant?.Name));
|
dispatch(showTenant(tenant?.Name));
|
||||||
localStorage.setItem("TenantName", tenant?.Name);
|
localStorage.setItem("TenantName", tenant?.Name);
|
||||||
}
|
}
|
||||||
localStorage.setItem("PageLanding", menu.pageId);
|
localStorage.setItem("PageLanding", menu.pageId);
|
||||||
localStorage.setItem("defaultmenuid", menu.menuId);
|
localStorage.setItem("defaultmenuid", menu.menuId);
|
||||||
localStorage.setItem("pageType", menu.pageType);
|
localStorage.setItem("pageType", menu.pageType);
|
||||||
if (isEnableSubscription) {
|
if (isEnableSubscription) {
|
||||||
const LocalUserDetails = {
|
const LocalUserDetails = {
|
||||||
name: results[0].get("Name"),
|
name: results[0].get("Name"),
|
||||||
email: results[0].get("Email"),
|
email: results[0].get("Email"),
|
||||||
phone: results[0]?.get("Phone") || "",
|
phone: results[0]?.get("Phone") || "",
|
||||||
company: results[0].get("Company")
|
company: results[0].get("Company")
|
||||||
};
|
};
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"userDetails",
|
"userDetails",
|
||||||
JSON.stringify(LocalUserDetails)
|
JSON.stringify(LocalUserDetails)
|
||||||
);
|
);
|
||||||
const res = await fetchSubscription();
|
const res = await fetchSubscription();
|
||||||
const plan = res.plan;
|
const plan = res.plan;
|
||||||
const billingDate = res.billingDate;
|
const billingDate = res.billingDate;
|
||||||
if (plan === "freeplan") {
|
if (plan === "freeplan") {
|
||||||
setState({ ...state, loading: false });
|
|
||||||
navigate(redirectUrl);
|
|
||||||
} else if (billingDate) {
|
|
||||||
if (new Date(billingDate) > new Date()) {
|
|
||||||
localStorage.removeItem("userDetails");
|
|
||||||
// Redirect to the appropriate URL after successful login setState({ ...state, loading: false });
|
|
||||||
setState({ ...state, loading: false });
|
setState({ ...state, loading: false });
|
||||||
navigate(redirectUrl);
|
navigate(redirectUrl);
|
||||||
|
} else if (billingDate) {
|
||||||
|
if (new Date(billingDate) > new Date()) {
|
||||||
|
localStorage.removeItem("userDetails");
|
||||||
|
// Redirect to the appropriate URL after successful login setState({ ...state, loading: false });
|
||||||
|
setState({ ...state, loading: false });
|
||||||
|
navigate(redirectUrl);
|
||||||
|
} else {
|
||||||
|
setState({ ...state, loading: false });
|
||||||
|
handlePaidRoute(plan);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({ ...state, loading: false });
|
setState({ ...state, loading: false });
|
||||||
handlePaidRoute(plan);
|
handlePaidRoute(plan);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({ ...state, loading: false });
|
setState({ ...state, loading: false });
|
||||||
handlePaidRoute(plan);
|
// Redirect to the appropriate URL after successful login
|
||||||
|
navigate(redirectUrl);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({ ...state, loading: false });
|
setState({ ...state, loading: false });
|
||||||
// Redirect to the appropriate URL after successful login
|
setIsModal(true);
|
||||||
navigate(redirectUrl);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({ ...state, loading: false });
|
setState({
|
||||||
setIsModal(true);
|
...state,
|
||||||
|
loading: false,
|
||||||
|
alertType: "danger",
|
||||||
|
alertMsg:
|
||||||
|
"You don't have access, please contact the admin."
|
||||||
|
});
|
||||||
|
logOutUser();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({
|
if (isEnableSubscription) {
|
||||||
...state,
|
setState({ ...state, loading: false });
|
||||||
loading: false,
|
setIsModal(true);
|
||||||
alertType: "danger",
|
} else {
|
||||||
alertMsg:
|
setState({ ...state, loading: false });
|
||||||
"You don't have access, please contact the admin."
|
setState({
|
||||||
});
|
...state,
|
||||||
logOutUser();
|
loading: false,
|
||||||
|
alertType: "danger",
|
||||||
|
alertMsg: "User not found."
|
||||||
|
});
|
||||||
|
logOutUser();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
if (isEnableSubscription) {
|
.catch((error) => {
|
||||||
setState({ ...state, loading: false });
|
// const payload = { sessionToken: user.getSessionToken() };
|
||||||
setIsModal(true);
|
// handleSubmitbtn(payload);
|
||||||
} else {
|
setState({
|
||||||
setState({ ...state, loading: false });
|
...state,
|
||||||
setState({
|
loading: false,
|
||||||
...state,
|
alertType: "danger",
|
||||||
loading: false,
|
alertMsg: `Something went wrong.`
|
||||||
alertType: "danger",
|
});
|
||||||
alertMsg: "User not found."
|
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
||||||
});
|
console.error("Error while fetching Follow", error);
|
||||||
logOutUser();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
// const payload = { sessionToken: user.getSessionToken() };
|
|
||||||
// handleSubmitbtn(payload);
|
|
||||||
setState({
|
|
||||||
...state,
|
|
||||||
loading: false,
|
|
||||||
alertType: "danger",
|
|
||||||
alertMsg: `Something went wrong.`
|
|
||||||
});
|
});
|
||||||
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
} catch (error) {
|
||||||
console.error("Error while fetching Follow", error);
|
setState({
|
||||||
|
...state,
|
||||||
|
loading: false,
|
||||||
|
alertType: "danger",
|
||||||
|
alertMsg: `${error.message}`
|
||||||
});
|
});
|
||||||
} catch (error) {
|
console.log(error);
|
||||||
setState({
|
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
||||||
...state,
|
}
|
||||||
loading: false,
|
|
||||||
alertType: "danger",
|
|
||||||
alertMsg: `${error.message}`
|
|
||||||
});
|
|
||||||
console.log(error);
|
|
||||||
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setState({
|
||||||
|
...state,
|
||||||
|
loading: false,
|
||||||
|
alertType: "danger",
|
||||||
|
alertMsg: "Invalid username or password!"
|
||||||
|
});
|
||||||
|
console.error("Error while logging in user", error);
|
||||||
|
} finally {
|
||||||
|
setTimeout(
|
||||||
|
() => setState((prev) => ({ ...prev, alertMsg: "" })),
|
||||||
|
2000
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
setState({
|
|
||||||
...state,
|
|
||||||
loading: false,
|
|
||||||
alertType: "danger",
|
|
||||||
alertMsg: "Invalid username or password!"
|
|
||||||
});
|
|
||||||
console.error("Error while logging in user", error);
|
|
||||||
} finally {
|
|
||||||
setTimeout(() => setState((prev) => ({ ...prev, alertMsg: "" })), 2000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import React, { useState, useRef, useEffect } from "react";
|
import React, { useState, useRef, useEffect } from "react";
|
||||||
import { isEnableSubscription, isStaging, themeColor } from "../constant/const";
|
import {
|
||||||
|
emailRegex,
|
||||||
|
isEnableSubscription,
|
||||||
|
isStaging,
|
||||||
|
themeColor
|
||||||
|
} from "../constant/const";
|
||||||
import { PDFDocument } from "pdf-lib";
|
import { PDFDocument } from "pdf-lib";
|
||||||
import "../styles/signature.css";
|
import "../styles/signature.css";
|
||||||
import Parse from "parse";
|
import Parse from "parse";
|
||||||
@@ -1554,64 +1559,68 @@ function PdfRequestFiles(props) {
|
|||||||
const handlePublicUser = async (e) => {
|
const handlePublicUser = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
if (!emailRegex.test(contact.email)) {
|
||||||
const params = {
|
alert("Please enter a valid email address.");
|
||||||
...contact,
|
} else {
|
||||||
templateid: pdfDetails[0]?.objectId,
|
try {
|
||||||
role: pdfDetails[0]?.PublicRole[0]
|
const params = {
|
||||||
};
|
...contact,
|
||||||
const userRes = await axios.post(
|
templateid: pdfDetails[0]?.objectId,
|
||||||
`${localStorage.getItem(
|
role: pdfDetails[0]?.PublicRole[0]
|
||||||
"baseUrl"
|
};
|
||||||
)}/functions/publicuserlinkcontacttodoc`,
|
const userRes = await axios.post(
|
||||||
params,
|
`${localStorage.getItem(
|
||||||
{
|
"baseUrl"
|
||||||
headers: {
|
)}/functions/publicuserlinkcontacttodoc`,
|
||||||
"Content-Type": "application/json",
|
params,
|
||||||
"X-Parse-Application-Id": localStorage.getItem("parseAppId")
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (userRes?.data?.result) {
|
if (userRes?.data?.result) {
|
||||||
setPublicRes(userRes.data.result);
|
setPublicRes(userRes.data.result);
|
||||||
const isEnableOTP = pdfDetails?.[0]?.IsEnableOTP || false;
|
const isEnableOTP = pdfDetails?.[0]?.IsEnableOTP || false;
|
||||||
if (isEnableOTP) {
|
if (isEnableOTP) {
|
||||||
await SendOtp();
|
await SendOtp();
|
||||||
|
} else {
|
||||||
|
setIsPublicContact(false);
|
||||||
|
setIsPublicTemplate(false);
|
||||||
|
setDocumentId(userRes.data?.result?.docId);
|
||||||
|
const contactId = userRes.data.result?.contactId;
|
||||||
|
setSignerObjectId(contactId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setIsPublicContact(false);
|
console.log("error in public-sign to create user details");
|
||||||
setIsPublicTemplate(false);
|
setIsAlert({
|
||||||
setDocumentId(userRes.data?.result?.docId);
|
title: "Error",
|
||||||
const contactId = userRes.data.result?.contactId;
|
isShow: true,
|
||||||
setSignerObjectId(contactId);
|
alertMessage: t("something-went-wrong-mssg")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("e", e);
|
||||||
|
if (
|
||||||
|
e?.response?.data?.error === "Insufficient Credit" ||
|
||||||
|
e?.response?.data?.error === "Plan expired"
|
||||||
|
) {
|
||||||
|
handleCloseOtp();
|
||||||
|
setIsAlert({
|
||||||
|
title: t("insufficient-credits"),
|
||||||
|
isShow: true,
|
||||||
|
alertMessage: t("insufficient-credits-mssg")
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
handleCloseOtp();
|
||||||
|
setIsAlert({
|
||||||
|
title: "Error",
|
||||||
|
isShow: true,
|
||||||
|
alertMessage: t("something-went-wrong-mssg")
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log("error in public-sign to create user details");
|
|
||||||
setIsAlert({
|
|
||||||
title: "Error",
|
|
||||||
isShow: true,
|
|
||||||
alertMessage: t("something-went-wrong-mssg")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log("e", e);
|
|
||||||
if (
|
|
||||||
e?.response?.data?.error === "Insufficient Credit" ||
|
|
||||||
e?.response?.data?.error === "Plan expired"
|
|
||||||
) {
|
|
||||||
handleCloseOtp();
|
|
||||||
setIsAlert({
|
|
||||||
title: t("insufficient-credits"),
|
|
||||||
isShow: true,
|
|
||||||
alertMessage: t("insufficient-credits-mssg")
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
handleCloseOtp();
|
|
||||||
setIsAlert({
|
|
||||||
title: "Error",
|
|
||||||
isShow: true,
|
|
||||||
alertMessage: t("something-went-wrong-mssg")
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2056,6 +2056,7 @@ function PlaceHolderSign() {
|
|||||||
|
|
||||||
{/* pdf header which contain funish back button */}
|
{/* pdf header which contain funish back button */}
|
||||||
<Header
|
<Header
|
||||||
|
completeBtnTitle={t("next")}
|
||||||
isPlaceholder={true}
|
isPlaceholder={true}
|
||||||
pageNumber={pageNumber}
|
pageNumber={pageNumber}
|
||||||
allPages={allPages}
|
allPages={allPages}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { appInfo } from "../constant/appinfo";
|
|||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
||||||
import { showTenant } from "../redux/reducers/ShowTenant";
|
import { showTenant } from "../redux/reducers/ShowTenant";
|
||||||
import { isEnableSubscription } from "../constant/const";
|
import { emailRegex, isEnableSubscription } from "../constant/const";
|
||||||
import {
|
import {
|
||||||
getAppLogo,
|
getAppLogo,
|
||||||
openInNewTab,
|
openInNewTab,
|
||||||
@@ -83,92 +83,96 @@ const Signup = () => {
|
|||||||
};
|
};
|
||||||
const handleSubmit = (event) => {
|
const handleSubmit = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (lengthValid && caseDigitValid && specialCharValid) {
|
if (!emailRegex.test(email)) {
|
||||||
clearStorage();
|
alert("Please enter a valid email address.");
|
||||||
setState({ loading: true });
|
} else {
|
||||||
const userDetails = {
|
if (lengthValid && caseDigitValid && specialCharValid) {
|
||||||
name: name,
|
clearStorage();
|
||||||
email: email,
|
setState({ loading: true });
|
||||||
phone: phone,
|
const userDetails = {
|
||||||
company: company,
|
name: name,
|
||||||
jobTitle: jobTitle
|
email: email,
|
||||||
};
|
phone: phone,
|
||||||
localStorage.setItem("userDetails", JSON.stringify(userDetails));
|
company: company,
|
||||||
try {
|
jobTitle: jobTitle
|
||||||
event.preventDefault();
|
};
|
||||||
var user = new Parse.User();
|
localStorage.setItem("userDetails", JSON.stringify(userDetails));
|
||||||
user.set("name", name);
|
try {
|
||||||
user.set("email", email);
|
event.preventDefault();
|
||||||
user.set("password", password);
|
var user = new Parse.User();
|
||||||
user.set("phone", phone);
|
user.set("name", name);
|
||||||
user.set("username", email);
|
user.set("email", email);
|
||||||
let res = user.save();
|
user.set("password", password);
|
||||||
res
|
user.set("phone", phone);
|
||||||
.then(async (r) => {
|
user.set("username", email);
|
||||||
if (r) {
|
let res = user.save();
|
||||||
let roleData = appInfo.settings;
|
res
|
||||||
if (roleData && roleData.length > 0) {
|
.then(async (r) => {
|
||||||
const params = {
|
if (r) {
|
||||||
userDetails: {
|
let roleData = appInfo.settings;
|
||||||
jobTitle: jobTitle,
|
if (roleData && roleData.length > 0) {
|
||||||
company: company,
|
const params = {
|
||||||
name: name,
|
userDetails: {
|
||||||
email: email,
|
jobTitle: jobTitle,
|
||||||
phone: phone,
|
company: company,
|
||||||
role: appInfo.defaultRole
|
name: name,
|
||||||
}
|
email: email,
|
||||||
};
|
phone: phone,
|
||||||
try {
|
role: appInfo.defaultRole
|
||||||
const usersignup = await Parse.Cloud.run(
|
|
||||||
"usersignup",
|
|
||||||
params
|
|
||||||
);
|
|
||||||
if (usersignup) {
|
|
||||||
const param = new URLSearchParams(location.search);
|
|
||||||
const isFreeplan =
|
|
||||||
param?.get("subscription") === "freeplan";
|
|
||||||
if (isFreeplan) {
|
|
||||||
await handleFreePlan(r.id);
|
|
||||||
}
|
}
|
||||||
handleNavigation(r.getSessionToken(), isFreeplan);
|
};
|
||||||
|
try {
|
||||||
|
const usersignup = await Parse.Cloud.run(
|
||||||
|
"usersignup",
|
||||||
|
params
|
||||||
|
);
|
||||||
|
if (usersignup) {
|
||||||
|
const param = new URLSearchParams(location.search);
|
||||||
|
const isFreeplan =
|
||||||
|
param?.get("subscription") === "freeplan";
|
||||||
|
if (isFreeplan) {
|
||||||
|
await handleFreePlan(r.id);
|
||||||
|
}
|
||||||
|
handleNavigation(r.getSessionToken(), isFreeplan);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
alert(err.message);
|
||||||
|
setState({ loading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(async (err) => {
|
||||||
|
if (err.code === 202) {
|
||||||
|
const params = { email: email };
|
||||||
|
const res = await Parse.Cloud.run("getUserDetails", params);
|
||||||
|
// console.log("Res ", res);
|
||||||
|
if (res) {
|
||||||
|
alert(t("user-already-exist-name"));
|
||||||
|
setState({ loading: false });
|
||||||
|
} else {
|
||||||
|
// console.log("state.email ", email);
|
||||||
|
try {
|
||||||
|
await Parse.User.requestPasswordReset(email).then(
|
||||||
|
async function (res1) {
|
||||||
|
if (res1.data === undefined) {
|
||||||
|
alert(t("verification-code-sent"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
alert(err.message);
|
|
||||||
setState({ loading: false });
|
setState({ loading: false });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(async (err) => {
|
|
||||||
if (err.code === 202) {
|
|
||||||
const params = { email: email };
|
|
||||||
const res = await Parse.Cloud.run("getUserDetails", params);
|
|
||||||
// console.log("Res ", res);
|
|
||||||
if (res) {
|
|
||||||
alert(t("user-already-exist-name"));
|
|
||||||
setState({ loading: false });
|
|
||||||
} else {
|
} else {
|
||||||
// console.log("state.email ", email);
|
alert(err.message);
|
||||||
try {
|
|
||||||
await Parse.User.requestPasswordReset(email).then(
|
|
||||||
async function (res1) {
|
|
||||||
if (res1.data === undefined) {
|
|
||||||
alert(t("verification-code-sent"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
setState({ loading: false });
|
setState({ loading: false });
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
alert(err.message);
|
} catch (error) {
|
||||||
setState({ loading: false });
|
console.log("err ", error);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.log("err ", error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { NavLink, useNavigate } from "react-router-dom";
|
|||||||
import Alert from "../primitives/Alert";
|
import Alert from "../primitives/Alert";
|
||||||
import Title from "../components/Title";
|
import Title from "../components/Title";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { emailRegex } from "../constant/const";
|
||||||
const UpdateExistUserAdmin = () => {
|
const UpdateExistUserAdmin = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -35,33 +36,37 @@ const UpdateExistUserAdmin = () => {
|
|||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsSubmitLoading(true);
|
if (!emailRegex.test(formdata.email)) {
|
||||||
try {
|
alert("Please enter a valid email address.");
|
||||||
const updateUserAsAdmin = await Parse.Cloud.run(
|
} else {
|
||||||
"updateuserasadmin",
|
setIsSubmitLoading(true);
|
||||||
formdata
|
try {
|
||||||
);
|
const updateUserAsAdmin = await Parse.Cloud.run(
|
||||||
// console.log("updateUserAsAdmin ", updateUserAsAdmin);
|
"updateuserasadmin",
|
||||||
if (updateUserAsAdmin === "admin_created") {
|
formdata
|
||||||
setIsAlert({ type: "success", msg: t("admin-created") });
|
);
|
||||||
navigate("/");
|
// console.log("updateUserAsAdmin ", updateUserAsAdmin);
|
||||||
|
if (updateUserAsAdmin === "admin_created") {
|
||||||
|
setIsAlert({ type: "success", msg: t("admin-created") });
|
||||||
|
navigate("/");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err in updateuserasadmin", err.code);
|
||||||
|
if (err.code === 404) {
|
||||||
|
setIsAlert((prev) => ({ ...prev, msg: t("invalid-masterkey") }));
|
||||||
|
} else if (err.code === 101) {
|
||||||
|
setIsAlert((prev) => ({ ...prev, msg: t("user-not-found") }));
|
||||||
|
} else if (err.code === 137) {
|
||||||
|
setIsAlert((prev) => ({ ...prev, msg: t("admin-exists") }));
|
||||||
|
} else {
|
||||||
|
setErrMsg(t("something-went-wrong-mssg"));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setIsSubmitLoading(false);
|
||||||
|
setTimeout(() => {
|
||||||
|
setIsAlert(() => ({ type: "danger", msg: "" }));
|
||||||
|
}, 2000);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
console.log("err in updateuserasadmin", err.code);
|
|
||||||
if (err.code === 404) {
|
|
||||||
setIsAlert((prev) => ({ ...prev, msg: t("invalid-masterkey") }));
|
|
||||||
} else if (err.code === 101) {
|
|
||||||
setIsAlert((prev) => ({ ...prev, msg: t("user-not-found") }));
|
|
||||||
} else if (err.code === 137) {
|
|
||||||
setIsAlert((prev) => ({ ...prev, msg: t("admin-exists") }));
|
|
||||||
} else {
|
|
||||||
setErrMsg(t("something-went-wrong-mssg"));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
setIsSubmitLoading(false);
|
|
||||||
setTimeout(() => {
|
|
||||||
setIsAlert(() => ({ type: "danger", msg: "" }));
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import Loader from "./Loader";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { getTenantDetails } from "../constant/Utils";
|
import { getTenantDetails } from "../constant/Utils";
|
||||||
|
import { emailRegex } from "../constant/const";
|
||||||
const AddContact = (props) => {
|
const AddContact = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
@@ -52,54 +53,58 @@ const AddContact = (props) => {
|
|||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsLoader(true);
|
if (!emailRegex.test(email)) {
|
||||||
const user = JSON.parse(
|
alert("Please enter a valid email address.");
|
||||||
localStorage.getItem(
|
} else {
|
||||||
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
setIsLoader(true);
|
||||||
)
|
const user = JSON.parse(
|
||||||
);
|
localStorage.getItem(
|
||||||
const userId = user?.objectId || "";
|
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
||||||
const tenantDetails = await getTenantDetails(userId, props.jwttoken);
|
)
|
||||||
const tenantId = tenantDetails?.objectId || "";
|
);
|
||||||
if (tenantId) {
|
const userId = user?.objectId || "";
|
||||||
try {
|
const tenantDetails = await getTenantDetails(userId, props.jwttoken);
|
||||||
const baseURL = localStorage.getItem("baseUrl");
|
const tenantId = tenantDetails?.objectId || "";
|
||||||
const url = `${baseURL}functions/savecontact`;
|
if (tenantId) {
|
||||||
const token = props?.jwttoken
|
try {
|
||||||
? { jwttoken: props?.jwttoken }
|
const baseURL = localStorage.getItem("baseUrl");
|
||||||
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
|
const url = `${baseURL}functions/savecontact`;
|
||||||
const data = { name, email, phone, tenantId };
|
const token = props?.jwttoken
|
||||||
const headers = {
|
? { jwttoken: props?.jwttoken }
|
||||||
"Content-Type": "application/json",
|
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
|
||||||
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
const data = { name, email, phone, tenantId };
|
||||||
...token
|
const headers = {
|
||||||
};
|
"Content-Type": "application/json",
|
||||||
const axiosRes = await axios.post(url, data, { headers });
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||||
const contactRes = axiosRes?.data?.result || {};
|
...token
|
||||||
if (contactRes?.objectId) {
|
};
|
||||||
props.details(contactRes);
|
const axiosRes = await axios.post(url, data, { headers });
|
||||||
if (props.closePopup) {
|
const contactRes = axiosRes?.data?.result || {};
|
||||||
props.closePopup();
|
if (contactRes?.objectId) {
|
||||||
setIsLoader(false);
|
props.details(contactRes);
|
||||||
// Reset the form fields
|
if (props.closePopup) {
|
||||||
setAddYourself(false);
|
props.closePopup();
|
||||||
setName("");
|
setIsLoader(false);
|
||||||
setPhone("");
|
// Reset the form fields
|
||||||
setEmail("");
|
setAddYourself(false);
|
||||||
|
setName("");
|
||||||
|
setPhone("");
|
||||||
|
setEmail("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("Err", err);
|
||||||
|
setIsLoader(false);
|
||||||
|
if (err?.response?.data?.error?.includes("already exists")) {
|
||||||
|
alert(t("add-signer-alert"));
|
||||||
|
} else {
|
||||||
|
alert(t("something-went-wrong-mssg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} else {
|
||||||
console.log("Err", err);
|
|
||||||
setIsLoader(false);
|
setIsLoader(false);
|
||||||
if (err?.response?.data?.error?.includes("already exists")) {
|
alert(t("something-went-wrong-mssg"));
|
||||||
alert(t("add-signer-alert"));
|
|
||||||
} else {
|
|
||||||
alert(t("something-went-wrong-mssg"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setIsLoader(false);
|
|
||||||
alert(t("something-went-wrong-mssg"));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -128,11 +128,14 @@ export const updateMailCount = async (extUserId, plan, monthchange) => {
|
|||||||
|
|
||||||
export function formatWidgetOptions(type, options) {
|
export function formatWidgetOptions(type, options) {
|
||||||
const colorsArr = ['red', 'black', 'blue', 'yellow'];
|
const colorsArr = ['red', 'black', 'blue', 'yellow'];
|
||||||
|
const fontSizes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28];
|
||||||
const status = options?.required === true ? 'required' : 'optional' || 'required';
|
const status = options?.required === true ? 'required' : 'optional' || 'required';
|
||||||
const defaultValue = options?.default || '';
|
const defaultValue = options?.default || '';
|
||||||
const values = options?.values || [];
|
const values = options?.values || [];
|
||||||
const color = options?.color ? options.color : 'black';
|
const color = options?.color ? options.color : 'black';
|
||||||
const fontColor = colorsArr.includes(color) ? color : 'black';
|
const fontColor = colorsArr.includes(color) ? color : 'black';
|
||||||
|
const size = options?.size ? parseInt(options.size) : 12;
|
||||||
|
const fontSize = fontSizes.includes(size) ? size : 12;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'signature':
|
case 'signature':
|
||||||
return { name: 'signature', status: 'required' };
|
return { name: 'signature', status: 'required' };
|
||||||
@@ -148,13 +151,29 @@ export function formatWidgetOptions(type, options) {
|
|||||||
name: options.name || 'email',
|
name: options.name || 'email',
|
||||||
validation: { type: 'email' },
|
validation: { type: 'email' },
|
||||||
fontColor: fontColor,
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
case 'name':
|
case 'name':
|
||||||
return { status: status, name: options.name || 'name', fontColor: fontColor };
|
return {
|
||||||
|
status: status,
|
||||||
|
name: options.name || 'name',
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
|
};
|
||||||
case 'job title':
|
case 'job title':
|
||||||
return { status: status, name: options.name || 'job title', fontColor: fontColor };
|
return {
|
||||||
|
status: status,
|
||||||
|
name: options.name || 'job title',
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
|
};
|
||||||
case 'company':
|
case 'company':
|
||||||
return { status: status, name: options.name || 'company', fontColor: fontColor };
|
return {
|
||||||
|
status: status,
|
||||||
|
name: options.name || 'company',
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
|
};
|
||||||
case 'date': {
|
case 'date': {
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
let dd = String(today.getDate()).padStart(2, '0');
|
let dd = String(today.getDate()).padStart(2, '0');
|
||||||
@@ -169,6 +188,7 @@ export function formatWidgetOptions(type, options) {
|
|||||||
response: defaultValue || today,
|
response: defaultValue || today,
|
||||||
validation: { format: dateFormat || 'dd-MM-yyyy', type: 'date-format' },
|
validation: { format: dateFormat || 'dd-MM-yyyy', type: 'date-format' },
|
||||||
fontColor: fontColor,
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'textbox':
|
case 'textbox':
|
||||||
@@ -179,6 +199,7 @@ export function formatWidgetOptions(type, options) {
|
|||||||
hint: options.hint,
|
hint: options.hint,
|
||||||
validation: { type: 'regex', pattern: options?.regularexpression || '/^[a-zA-Z0-9s]+$/' },
|
validation: { type: 'regex', pattern: options?.regularexpression || '/^[a-zA-Z0-9s]+$/' },
|
||||||
fontColor: fontColor,
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
case 'checkbox': {
|
case 'checkbox': {
|
||||||
const arr = options?.values;
|
const arr = options?.values;
|
||||||
@@ -199,6 +220,7 @@ export function formatWidgetOptions(type, options) {
|
|||||||
},
|
},
|
||||||
defaultValue: selectedvalues || [],
|
defaultValue: selectedvalues || [],
|
||||||
fontColor: fontColor,
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'radio button': {
|
case 'radio button': {
|
||||||
@@ -210,6 +232,7 @@ export function formatWidgetOptions(type, options) {
|
|||||||
isHideLabel: options?.hidelabel || false,
|
isHideLabel: options?.hidelabel || false,
|
||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
fontColor: fontColor,
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
@@ -219,6 +242,7 @@ export function formatWidgetOptions(type, options) {
|
|||||||
values: values,
|
values: values,
|
||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
fontColor: fontColor,
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user