Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: something went wrong error in signpdf #1018

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/OpenSign/src/components/AddTeam.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ const AddTeam = (props) => {
};

return (
<div className="shadow-md rounded-box my-[1px] p-3 bg-[#ffffff]">
<div className="shadow-md rounded-box my-[1px] p-3 bg-base-100 relative">
<Title title="Add Team" />
{isLoader && (
<div className="fixed inset-0 flex justify-center items-center bg-black bg-opacity-30 z-50 rounded-box">
<div className="absolute w-full h-full inset-0 flex justify-center items-center bg-base-content/30 z-50">
<Loader />
</div>
)}
Expand Down
4 changes: 1 addition & 3 deletions apps/OpenSign/src/components/AddUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ const AddUser = (props) => {
};
const checkUserExist = async () => {
try {
const res = await Parse.Cloud.run("getUserDetails", {
email: formdata.email
});
const res = await Parse.Cloud.run("getUserDetails");
if (res) {
return true;
} else {
Expand Down
16 changes: 3 additions & 13 deletions apps/OpenSign/src/components/dashboard/DashboardCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@ const DashboardCard = (props) => {
sessionToken: localStorage.getItem("accesstoken")
};
let body = {};
let currentUser;
let currentUser1 = Parse.User.current();
currentUser = currentUser1.id;
let res;
if (localStorage.getItem("Extand_Class")) {
let data = JSON.parse(localStorage.getItem("Extand_Class"));
res = data[0];
} else {
res = await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
});
res = await Parse.Cloud.run("getUserDetails");
if (res) res = res.toJSON();
}
if (res) {
Expand Down Expand Up @@ -94,9 +89,7 @@ const DashboardCard = (props) => {
let data = JSON.parse(localStorage.getItem("Extand_Class"));
resr = data[0];
} else {
resr = await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
});
resr = await Parse.Cloud.run("getUserDetails");
if (resr) resr = resr.toJSON();
}

Expand Down Expand Up @@ -218,15 +211,12 @@ const DashboardCard = (props) => {

if (restr.includes("#")) {
try {
const currentUser = Parse.User.current();
let res;
if (localStorage.getItem("Extand_Class")) {
let data = JSON.parse(localStorage.getItem("Extand_Class"));
res = data[0];
} else {
let resr = await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
});
let resr = await Parse.Cloud.run("getUserDetails");
if (res) res = resr.toJSON();
}

Expand Down
48 changes: 15 additions & 33 deletions apps/OpenSign/src/constant/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Parse from "parse";
import { appInfo } from "./appinfo";
import { saveAs } from "file-saver";
import printModule from "print-js";
import { validplan } from "../json/plansArr";

export const fontsizeArr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28];
export const fontColorArr = ["red", "black", "blue", "yellow"];
Expand Down Expand Up @@ -90,13 +91,7 @@ export async function checkIsSubscribedTeam() {
if (res.plan === "freeplan") {
return false;
} else if (res.billingDate) {
const plan =
res.plan === "team-weekly" ||
res.plan === "team-yearly" ||
res.plan === "teams-monthly" ||
res.plan === "teams-yearly" ||
res.plan === "enterprise-monthly" ||
res.plan === "enterprise-yearly";
const plan = validplan[res.plan] || false;
if (plan && new Date(res.billingDate) > new Date()) {
return true;
} else {
Expand Down Expand Up @@ -192,32 +187,19 @@ export const pdfNewWidthFun = (divRef) => {
};

//`contractUsers` function is used to get contract_User details
export const contractUsers = async (email) => {
const data = {
email: email
};
const userDetails = await axios
.post(`${localStorage.getItem("baseUrl")}functions/getUserDetails`, data, {
headers: {
"Content-Type": "application/json",
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
sessionToken: localStorage.getItem("accesstoken")
}
})
.then((Listdata) => {
const json = Listdata.data;
let data = [];
if (json && json.result) {
data.push(json.result);
}
return data;
})
.catch((err) => {
console.log("Err in getUserDetails cloud function", err);
return "Error: Something went wrong!";
});

return userDetails;
export const contractUsers = async () => {
try {
const userDetails = await Parse.Cloud.run("getUserDetails");
let data = [];
if (userDetails) {
const json = JSON.parse(JSON.stringify(userDetails));
data.push(json);
}
return data;
} catch (err) {
console.log("Err in getUserDetails cloud function", err);
return "Error: Something went wrong!";
}
};

//function for resize image and update width and height for mulitisigners
Expand Down
8 changes: 8 additions & 0 deletions apps/OpenSign/src/json/plansArr.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,12 @@ const plans = [
}
];

export const validplan = {
"team-weekly": true,
"team-yearly": true,
"teams-monthly": true,
"teams-yearly": true,
"enterprise-monthly": true,
"enterprise-yearly": true
};
export default plans;
5 changes: 1 addition & 4 deletions apps/OpenSign/src/layout/HomeLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,7 @@ const HomeLayout = () => {
};

async function checkTourStatus() {
const currentUser = Parse.User.current();
const cloudRes = await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
});
const cloudRes = await Parse.Cloud.run("getUserDetails");
const res = { data: cloudRes.toJSON() };
if (res.data && res.data.TourStatus && res.data.TourStatus.length > 0) {
const tourStatus = res.data.TourStatus;
Expand Down
5 changes: 1 addition & 4 deletions apps/OpenSign/src/pages/AddAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ const AddAdmin = () => {
// Check extended class user role and tenentId
try {
const userSettings = appInfo.settings;
const currentUser = Parse.User.current();
const extUser = await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
});
const extUser = await Parse.Cloud.run("getUserDetails");
if (extUser) {
const IsDisabled = extUser?.get("IsDisabled") || false;
if (!IsDisabled) {
Expand Down
3 changes: 2 additions & 1 deletion apps/OpenSign/src/pages/GuestLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ function GuestLogin() {
setLoading(false);
} else {
let _user = user.data.result;
await Parse.User.become(_user.sessionToken);
const parseId = localStorage.getItem("parseAppId");
const contractUserDetails = await contractUsers(_user.email);
const contractUserDetails = await contractUsers();
localStorage.setItem("UserInformation", JSON.stringify(_user));
localStorage.setItem(
`Parse/${parseId}/currentUser`,
Expand Down
14 changes: 3 additions & 11 deletions apps/OpenSign/src/pages/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ function Login() {
// Check extended class user role and tenentId
try {
const userSettings = appInfo.settings;
const currentUser = Parse.User.current();
await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
})
await Parse.Cloud.run("getUserDetails")
.then(async (extUser) => {
if (extUser) {
const IsDisabled = extUser?.get("IsDisabled") || false;
Expand Down Expand Up @@ -279,10 +276,7 @@ function Login() {
// Check extended class user role and tenentId
try {
const userSettings = appInfo.settings;
const currentUser = Parse.User.current();
await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
})
await Parse.Cloud.run("getUserDetails")
.then(async (extUser) => {
if (extUser) {
const IsDisabled = extUser?.get("IsDisabled") || false;
Expand Down Expand Up @@ -408,9 +402,7 @@ function Login() {
localStorage.setItem("profileImg", "");
}
const userSettings = appInfo.settings;
await Parse.Cloud.run("getUserDetails", {
email: _user.email
}).then(async (extUser) => {
await Parse.Cloud.run("getUserDetails").then(async (extUser) => {
if (extUser) {
const IsDisabled = extUser?.get("IsDisabled") || false;
if (!IsDisabled) {
Expand Down
5 changes: 1 addition & 4 deletions apps/OpenSign/src/pages/Opensigndrive.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,7 @@ function Opensigndrive() {
};
//function to use check tour status of open sign drive
async function checkTourStatus() {
const currentUser = Parse.User.current();
const cloudRes = await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
});
const cloudRes = await Parse.Cloud.run("getUserDetails");
const res = { data: cloudRes.toJSON() };
if (res.data && res.data.TourStatus && res.data.TourStatus.length > 0) {
const tourStatus = res.data.TourStatus;
Expand Down
15 changes: 5 additions & 10 deletions apps/OpenSign/src/pages/PdfRequestFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,8 @@ function PdfRequestFiles(props) {
setRequestSignTour(true);
} else {
//else condition to check current user exist in contracts_Users class and check tour message status
//if not then check user exist in contracts_Contactbook class and check tour message status
const localuser = localStorage.getItem(
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
);
const currentUser = JSON.parse(localuser);
const currentUserEmail = currentUser.email;
const res = await contractUsers(currentUserEmail);
//if not then check user exist in contracts_Contactbook class and check tour message statu
const res = await contractUsers();
if (res === "Error: Something went wrong!") {
setHandleError("Error: Something went wrong!");
} else if (res[0] && res?.length) {
Expand Down Expand Up @@ -869,8 +864,7 @@ function PdfRequestFiles(props) {
//get ExistUserPtr object id of user class to get tenantDetails
const objectId = pdfDetails?.[0]?.ExtUserPtr?.UserId?.objectId;
//get ExistUserPtr email to get userDetails
const currentUserEmail = pdfDetails?.[0]?.ExtUserPtr?.Email;
const res = await contractUsers(currentUserEmail);
const res = await contractUsers();
let activeMailAdapter = "";
if (res === "Error: Something went wrong!") {
setHandleError("Error: Something went wrong!");
Expand Down Expand Up @@ -1546,7 +1540,8 @@ function PdfRequestFiles(props) {
} else {
let _user = user.data.result;
const parseId = localStorage.getItem("parseAppId");
const contractUserDetails = await contractUsers(_user.email);
await Parse.User.become(_user.sessionToken);
const contractUserDetails = await contractUsers();
localStorage.setItem("UserInformation", JSON.stringify(_user));
localStorage.setItem(
`Parse/${parseId}/currentUser`,
Expand Down
9 changes: 2 additions & 7 deletions apps/OpenSign/src/pages/Pgsignup.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ const PgSignUp = () => {
if (res) {
localStorage.removeItem("userDetails");
try {
const extUser = await Parse.Cloud.run("getUserDetails", {
email: userDetails.email
});
const extUser = await Parse.Cloud.run("getUserDetails");
const userRole = extUser?.get("UserRole");
const _currentRole = userRole;
const _role = _currentRole.replace("contracts_", "");
Expand Down Expand Up @@ -230,10 +228,7 @@ const PgSignUp = () => {
// Check extended class user role and tenentId
try {
const userSettings = appInfo.settings;
const currentUser = Parse.User.current();
const extUser = await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
});
const extUser = await Parse.Cloud.run("getUserDetails");
if (extUser) {
const IsDisabled = extUser?.get("IsDisabled") || false;
if (!IsDisabled) {
Expand Down
3 changes: 1 addition & 2 deletions apps/OpenSign/src/pages/PlaceHolderSign.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,7 @@ function PlaceHolderSign() {
};
setIsLoading(loadObj);
}
const currentUserEmail = documentData[0]?.ExtUserPtr?.Email;
const res = await contractUsers(currentUserEmail);
const res = await contractUsers();
if (res === "Error: Something went wrong!") {
const loadObj = {
isLoad: false
Expand Down
5 changes: 1 addition & 4 deletions apps/OpenSign/src/pages/SSOVerify.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ const SSOVerify = () => {
// Check extended class user role and tenentId
try {
const userSettings = appInfo.settings;
const currentUser = Parse.User.current();
await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
})
await Parse.Cloud.run("getUserDetails")
.then(async (extUser) => {
if (extUser) {
const IsDisabled = extUser?.get("IsDisabled") || false;
Expand Down
5 changes: 1 addition & 4 deletions apps/OpenSign/src/pages/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ const Signup = () => {
// Check extended class user role and tenentId
try {
const userSettings = appInfo.settings;
const currentUser = Parse.User.current();
await Parse.Cloud.run("getUserDetails", {
email: currentUser.get("email")
})
await Parse.Cloud.run("getUserDetails")
.then(async (extUser) => {
if (extUser) {
const IsDisabled = extUser?.get("IsDisabled") || false;
Expand Down
2 changes: 1 addition & 1 deletion apps/OpenSign/src/pages/SignyourselfPdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function SignYourSelf() {
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
});
const contractUsersRes = await contractUsers(jsonSender.email);
const contractUsersRes = await contractUsers();
if (contractUsersRes === "Error: Something went wrong!") {
const loadObj = {
isLoad: false
Expand Down
14 changes: 3 additions & 11 deletions apps/OpenSign/src/pages/TemplatePlaceholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,6 @@ const TemplatePlaceholder = () => {
const [fontColor, setFontColor] = useState();
const [zoomPercent, setZoomPercent] = useState(0);
const [scale, setScale] = useState(1);
const senderUser =
localStorage.getItem(
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
) &&
localStorage.getItem(
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
);
const jsonSender = JSON.parse(senderUser);

useEffect(() => {
fetchTemplate();
Expand Down Expand Up @@ -317,7 +309,7 @@ const TemplatePlaceholder = () => {
setHandleError("Error: Something went wrong!");
}
}
const res = await contractUsers(jsonSender.email);
const res = await contractUsers();
if (res[0] && res.length) {
setSignerUserId(res[0].objectId);
setCurrentEmail(res[0].Email);
Expand Down Expand Up @@ -1544,8 +1536,8 @@ const TemplatePlaceholder = () => {
/>
</div>
) : (
<div className="w-[23%] bg-[#FFFFFF] min-h-screen overflow-y-auto hide-scrollbar">
<div className={`max-h-screen`}>
<div className="w-[23%] bg-base-100 min-h-screen overflow-y-auto hide-scrollbar">
<div className="max-h-screen">
<SignerListPlace
isMailSend={isMailSend}
signerPos={signerPos}
Expand Down
6 changes: 3 additions & 3 deletions apps/OpenSign/src/pages/UserList.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ const UserList = () => {
<thead className="text-[14px]">
<tr className="border-y-[1px]">
{heading?.map((item, index) => (
<React.Fragment key={index}>
<th className="px-4 py-2">{item}</th>
</React.Fragment>
<th key={index} className="px-4 py-2">
{item}
</th>
))}
</tr>
</thead>
Expand Down
4 changes: 1 addition & 3 deletions apps/OpenSign/src/pages/UserProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,7 @@ function UserProfile() {
) : (
<div className="flex justify-center items-center w-full relative">
{userNameError && (
<div
className={`z-[1000] fixed top-[50%] transform border-[1px] text-sm border-[#f0a8a8] bg-[#f4bebe] text-[#c42121] rounded py-[.75rem] px-[1.25rem]`}
>
<div className="z-[1000] fixed top-[50%] transform border-[1px] text-sm border-[#f0a8a8] bg-[#f4bebe] text-[#c42121] rounded py-[.75rem] px-[1.25rem]">
{userNameError}
</div>
)}
Expand Down
Loading