Skip to content

Commit 83fe889

Browse files
fix: public toggle issue,cloud function error handling
1 parent dfc6da3 commit 83fe889

File tree

5 files changed

+264
-220
lines changed

5 files changed

+264
-220
lines changed

apps/OpenSign/src/pages/UserProfile.js

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function UserProfile() {
9494
return res;
9595
}
9696
} catch (e) {
97-
console.log("extend error");
97+
console.log("error in getpublicusername cloud function");
9898
}
9999
};
100100
const handleSubmit = async (e) => {
@@ -153,25 +153,15 @@ function UserProfile() {
153153
const extClass = localStorage.getItem("extended_class");
154154
const extData = JSON.parse(localStorage.getItem("Extand_Class"));
155155
const ExtUserId = extData[0].objectId;
156-
let body;
157-
if (publicUserName) {
158-
body = {
159-
Phone: obj?.Phone || "",
160-
Name: obj.Name,
161-
HeaderDocId: isDisableDocId,
162-
JobTitle: jobTitle,
163-
Company: company,
164-
UserName: publicUserName
165-
};
166-
} else {
167-
body = {
168-
Phone: obj?.Phone || "",
169-
Name: obj.Name,
170-
HeaderDocId: isDisableDocId,
171-
JobTitle: jobTitle,
172-
Company: company
173-
};
174-
}
156+
const body = {
157+
Phone: obj?.Phone || "",
158+
Name: obj.Name,
159+
HeaderDocId: isDisableDocId,
160+
JobTitle: jobTitle,
161+
Company: company,
162+
UserName: publicUserName || ""
163+
};
164+
175165
await axios.put(
176166
parseBaseUrl + "classes/" + extClass + "/" + ExtUserId,
177167
body,
@@ -282,7 +272,7 @@ function UserProfile() {
282272
setOtpLoader(false);
283273
alert("OTP sent on you email");
284274
};
285-
//function to handle onchange user name nad restict 6 characters username for free users
275+
//function to handle onchange username and restrict 6-characters username for free users
286276
const handleOnchangeUserName = (e) => {
287277
const value = e.target.value;
288278
if (value.length > 6 && !isSubscribe) {
@@ -294,6 +284,15 @@ function UserProfile() {
294284
setPublicUserName(e.target.value);
295285
}
296286
};
287+
const handleCancel = () => {
288+
setEditMode(false);
289+
SetName(localStorage.getItem("username"));
290+
SetPhone(UserProfile && UserProfile.phone);
291+
setImage(localStorage.getItem("profileImg"));
292+
setPublicUserName(extendUser && extendUser?.[0]?.UserName);
293+
setCompany(extendUser && extendUser?.[0]?.Company);
294+
setJobTitle(extendUser?.[0]?.JobTitle);
295+
};
297296
return (
298297
<React.Fragment>
299298
<Title title={"Profile"} />
@@ -450,22 +449,37 @@ function UserProfile() {
450449
)}
451450
</span>
452451
</li>
453-
{/* {!isEnableSubscription && ( */}
454-
<li className="flex justify-between items-center border-t-[1px] border-gray-300 py-2 break-all">
455-
<span className="font-semibold">Public profile:</span>
456-
<div className="flex items-center">
457-
<span>opensign.me/</span>
458-
459-
<input
460-
onChange={handleOnchangeUserName}
461-
value={publicUserName}
462-
disabled={!editmode}
463-
placeholder="enter user name"
464-
className="border-[1px] border-gray-200 rounded-[3px]"
465-
/>
466-
</div>
467-
</li>
468-
{/* )} */}
452+
{!isEnableSubscription && (
453+
<li className="flex justify-between items-center border-t-[1px] border-gray-300 py-2 break-all">
454+
<span className="font-semibold">
455+
Public profile :{" "}
456+
<Tooltip
457+
message={`this is your public URL. Copy or share it
458+
with the signer, and you will be able to see
459+
all your publicly set templates.`}
460+
/>
461+
</span>
462+
<div className="flex items-center">
463+
<span>opensign.me/</span>
464+
{editmode ? (
465+
<input
466+
onChange={handleOnchangeUserName}
467+
value={publicUserName}
468+
disabled={!editmode}
469+
placeholder="enter user name"
470+
className="border-[1px] border-gray-200 rounded-[3px]"
471+
/>
472+
) : (
473+
<input
474+
value={extendUser?.[0]?.UserName}
475+
disabled
476+
placeholder="enter user name"
477+
className="border-[1px] border-gray-200 rounded-[3px]"
478+
/>
479+
)}
480+
</div>
481+
</li>
482+
)}
469483
<li className="border-y-[1px] border-gray-300 break-all">
470484
<div className="flex justify-between items-center py-2">
471485
<span
@@ -536,7 +550,7 @@ function UserProfile() {
536550
type="button"
537551
onClick={() => {
538552
if (editmode) {
539-
setEditMode(false);
553+
handleCancel();
540554
} else {
541555
navigate("/changepassword");
542556
}

0 commit comments

Comments
 (0)