setting, session and profile fix
This commit is contained in:
parent
068142ed61
commit
a434af224c
34 changed files with 497 additions and 119 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { useRef, useState } from "react";
|
||||
import { updateAccountProfile } from "../api";
|
||||
import { getAccessToken, saveStoredAccount } from "../auth";
|
||||
|
||||
const MAX_AVATAR_BYTES = 512 * 1024;
|
||||
const ALLOWED_TYPES = new Set(["image/jpeg", "image/png", "image/webp"]);
|
||||
|
|
@ -14,7 +15,7 @@ function displayPhone(phone) {
|
|||
}
|
||||
|
||||
export default function AccountProfile({ account, onUpdated }) {
|
||||
const token = sessionStorage.getItem("agmail_access_token");
|
||||
const token = getAccessToken();
|
||||
const inputRef = useRef(null);
|
||||
const [status, setStatus] = useState({ loading: false, error: "", notice: "" });
|
||||
const fullName = `${account?.first_name || ""} ${account?.last_name || ""}`.trim();
|
||||
|
|
@ -44,7 +45,7 @@ export default function AccountProfile({ account, onUpdated }) {
|
|||
reader.readAsDataURL(file);
|
||||
});
|
||||
const updated = await updateAccountProfile({ profile_picture_url: dataUrl }, token);
|
||||
sessionStorage.setItem("agmail_account", JSON.stringify(updated));
|
||||
saveStoredAccount(updated);
|
||||
onUpdated?.(updated);
|
||||
setStatus({ loading: false, error: "", notice: "Saved" });
|
||||
} catch (error) {
|
||||
|
|
@ -56,7 +57,7 @@ export default function AccountProfile({ account, onUpdated }) {
|
|||
setStatus({ loading: true, error: "", notice: "" });
|
||||
try {
|
||||
const updated = await updateAccountProfile({ profile_picture_url: null }, token);
|
||||
sessionStorage.setItem("agmail_account", JSON.stringify(updated));
|
||||
saveStoredAccount(updated);
|
||||
onUpdated?.(updated);
|
||||
setStatus({ loading: false, error: "", notice: "Saved" });
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue