Merge pull request #1401 from OpenSignLabs/validation

fix: drattemplate ui changes, signers not visible in list, alert message
This commit is contained in:
Amol
2024-10-31 13:13:00 +05:30
committed by GitHub
7 changed files with 43 additions and 33 deletions
@@ -5,11 +5,8 @@ import { isEnableSubscription } from "../../constant/const";
import { useTranslation } from "react-i18next";
import { Tooltip } from "react-tooltip";
// import SelectFolder from "../../premitives/SelectFolder";
const EditTemplate = ({ template, onSuccess }) => {
const EditTemplate = ({ template, onSuccess, jwttoken }) => {
const { t } = useTranslation();
// const [folder, setFolder] = useState({ ObjectId: "", Name: "" });
const [formData, setFormData] = useState({
Name: template?.Name || "",
Note: template?.Note || "",
@@ -29,17 +26,13 @@ const EditTemplate = ({ template, onSuccess }) => {
}, []);
const fetchSubscription = async () => {
if (isEnableSubscription) {
const subscribe = await checkIsSubscribed();
const subscribe = await checkIsSubscribed(jwttoken);
setIsSubscribe(subscribe.isValid);
}
};
const handleStrInput = (e) => {
setFormData({ ...formData, [e.target.name]: e.target.value });
};
// const handleFolder = (data) => {
// console.log("handleFolder ", data)
// setFolder(data);
// };
// Define a function to handle form submission
const handleSubmit = async (e) => {
@@ -85,7 +78,7 @@ const EditTemplate = ({ template, onSuccess }) => {
</div>
<div className="mb-[0.35rem]">
<label htmlFor="name" className="text-[13px]">
{t("name")}
{t("Title")}
<span className="text-[13px] text-[red]"> *</span>
</label>
<input
@@ -158,7 +151,6 @@ const EditTemplate = ({ template, onSuccess }) => {
}
>
{t("auto-reminder")}
{" "}
{!isSubscribe && isEnableSubscription && <Upgrade />}
</span>
<label
+12 -8
View File
@@ -40,7 +40,8 @@ function Header({
handleRotationFun,
isDisableRotate,
templateId,
setIsDownloadModal
setIsDownloadModal,
disabledBackBtn
}) {
const { t } = useTranslation();
const filterPrefill =
@@ -48,6 +49,7 @@ function Header({
const isMobile = window.innerWidth < 767;
const [isDownloading, setIsDownloading] = useState("");
const isGuestSigner = localStorage.getItem("isGuestSigner");
const enabledBackBtn = disabledBackBtn === true ? false : true;
//function for show decline alert
const handleDeclinePdfAlert = async () => {
@@ -332,13 +334,15 @@ function Header({
<i className="fa-light fa-gear fa-lg"></i>
</button>
)}
<button
onClick={() => window.history.go(-2)}
type="button"
className="op-btn op-btn-ghost op-btn-sm mr-[3px]"
>
{t("back")}
</button>
{enabledBackBtn && (
<button
onClick={() => window.history.go(-2)}
type="button"
className="op-btn op-btn-ghost op-btn-sm mr-[3px]"
>
{t("back")}
</button>
)}
<button
disabled={isMailSend && true}
data-tut="headerArea"
@@ -33,16 +33,16 @@ const SelectSigners = (props) => {
try {
const baseURL = localStorage.getItem("baseUrl");
const url = `${baseURL}functions/getsigners`;
const token = props?.jwttoken
? { jwttoken: props?.jwttoken }
const token = props.jwttoken
? { jwttoken: props.jwttoken }
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
const headers = {
"Content-Type": "application/json",
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
...token
};
const search = inputValue;
const axiosRes = await axios.post(url, { search }, { headers });
const searchEmail = inputValue;
const axiosRes = await axios.post(url, { searchEmail }, { headers });
const contactRes = axiosRes?.data?.result || [];
if (contactRes) {
const res = JSON.parse(JSON.stringify(contactRes));
+2 -2
View File
@@ -126,9 +126,9 @@ export async function fetchSubscriptionInfo() {
}
}
//function to get subcripition details from subscription class
export async function checkIsSubscribed() {
export async function checkIsSubscribed(jwttoken) {
try {
const res = await fetchSubscription();
const res = await fetchSubscription("", "", false, false, jwttoken);
if (res.plan === "freeplan") {
return { plan: res.plan, isValid: false, adminId: res?.adminId };
} else if (res.billingDate) {
+4 -2
View File
@@ -732,7 +732,7 @@ const DraftTemplate = () => {
} else {
// setIsPublicError(true);
alert(
"Only one signer without a role is allowed, and it should be at the first index."
"To make your template public, it must either contain a single role, or, if it includes multiple roles, all additional roles must already be assigned to signers. The unassigned public role should remain empty and must be placed in the first position. \nVisit below link to know more - \nhttps://docs.opensignlabs.com/docs/help/Templates/make-template-public"
);
}
} else {
@@ -1302,7 +1302,7 @@ const DraftTemplate = () => {
} else {
// setIsPublicError(true);
alert(
"Only one signer without a role is allowed, and it should be at the first index."
"To make your template public, it must either contain a single role, or, if it includes multiple roles, all additional roles must already be assigned to signers. The unassigned public role should remain empty and must be placed in the first position. \nVisit below link to know more - \nhttps://docs.opensignlabs.com/docs/help/Templates/make-template-public"
);
}
};
@@ -1614,6 +1614,7 @@ const DraftTemplate = () => {
{/* pdf header which contain funish back button */}
<Header
completeBtnTitle={t("send")}
disabledBackBtn={true}
isPlaceholder={true}
pageNumber={pageNumber}
allPages={allPages}
@@ -1800,6 +1801,7 @@ const DraftTemplate = () => {
<EditTemplate
template={pdfDetails?.[0]}
onSuccess={handleEditTemplateForm}
jwttoken={jwttoken}
/>
</ModalUi>
<WidgetNameModal
+17 -4
View File
@@ -127,9 +127,12 @@ export const updateMailCount = async (extUserId, plan, monthchange) => {
};
export function formatWidgetOptions(type, options) {
const colorsArr = ['red', 'black', 'blue', 'yellow'];
const status = options?.required === true ? 'required' : 'optional' || 'required';
const defaultValue = options?.default || '';
const values = options?.values || [];
const color = options?.color ? options.color : 'black';
const fontColor = colorsArr.includes(color) ? color : 'black';
switch (type) {
case 'signature':
return { name: 'signature', status: 'required' };
@@ -140,13 +143,18 @@ export function formatWidgetOptions(type, options) {
case 'image':
return { status: status, name: options.name || 'image' };
case 'email':
return { status: status, name: options.name || 'email', validation: { type: 'email' } };
return {
status: status,
name: options.name || 'email',
validation: { type: 'email' },
fontColor: fontColor,
};
case 'name':
return { status: status, name: options.name || 'name' };
return { status: status, name: options.name || 'name', fontColor: fontColor };
case 'job title':
return { status: status, name: options.name || 'job title' };
return { status: status, name: options.name || 'job title', fontColor: fontColor };
case 'company':
return { status: status, name: options.name || 'company' };
return { status: status, name: options.name || 'company', fontColor: fontColor };
case 'date': {
let today = new Date();
let dd = String(today.getDate()).padStart(2, '0');
@@ -160,6 +168,7 @@ export function formatWidgetOptions(type, options) {
name: options.name || 'date',
response: defaultValue || today,
validation: { format: dateFormat || 'dd-MM-yyyy', type: 'date-format' },
fontColor: fontColor,
};
}
case 'textbox':
@@ -169,6 +178,7 @@ export function formatWidgetOptions(type, options) {
defaultValue: defaultValue,
hint: options.hint,
validation: { type: 'regex', pattern: options?.regularexpression || '/^[a-zA-Z0-9s]+$/' },
fontColor: fontColor,
};
case 'checkbox': {
const arr = options?.values;
@@ -188,6 +198,7 @@ export function formatWidgetOptions(type, options) {
maxRequiredCount: options?.validation?.maxselections || 0,
},
defaultValue: selectedvalues || [],
fontColor: fontColor,
};
}
case 'radio button': {
@@ -198,6 +209,7 @@ export function formatWidgetOptions(type, options) {
isReadOnly: options?.readonly || false,
isHideLabel: options?.hidelabel || false,
defaultValue: defaultValue,
fontColor: fontColor,
};
}
case 'dropdown':
@@ -206,6 +218,7 @@ export function formatWidgetOptions(type, options) {
name: options.name || 'dropdown',
values: values,
defaultValue: defaultValue,
fontColor: fontColor,
};
default:
break;
@@ -13,14 +13,13 @@ export default async function getSigners(request) {
className: '_User',
objectId: request?.user?.id,
});
if (search) {
contactbook.matches('Name', new RegExp(search, 'i'));
} else if (searchEmail) {
contactbook.matches('Email', new RegExp(searchEmail, 'i'));
}
contactbook.notEqualTo('IsDeleted', true);
const contactRes = await contactbook.find();
const contactRes = await contactbook.find({ sessionToken: request.user.getSessionToken() });
const _contactRes = JSON.parse(JSON.stringify(contactRes));
return _contactRes;
} else if (jwttoken) {