profile-image
This commit is contained in:
@@ -26,7 +26,7 @@ export function AccountCard({
|
||||
}: {
|
||||
onDeleteAvatar: () => Promise<void>;
|
||||
onEditAccount: () => void;
|
||||
onEditAvatar: () => void;
|
||||
onEditAvatar: () => Promise<boolean>;
|
||||
onEditPassword: () => void;
|
||||
onSelectAvatar: (file: File) => void;
|
||||
savingAvatar: boolean;
|
||||
@@ -76,9 +76,11 @@ export function AccountCard({
|
||||
disabled={savingAvatar}
|
||||
icon={user.avatarUrl ? LuPencil : LuImagePlus}
|
||||
label={user.avatarUrl ? "Modifica avatar" : "Carica avatar"}
|
||||
onClick={() =>
|
||||
user.avatarUrl ? onEditAvatar() : inputRef.current?.click()
|
||||
}
|
||||
onClick={async () => {
|
||||
if (!user.avatarUrl || !(await onEditAvatar())) {
|
||||
inputRef.current?.click();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{user.avatarUrl ? (
|
||||
<ListCardAction
|
||||
|
||||
@@ -88,7 +88,7 @@ export function ProfilePageClient({ user }: { user: UserSession }) {
|
||||
}
|
||||
|
||||
async function editAvatar() {
|
||||
if (!account.avatarUrl) return;
|
||||
if (!account.avatarUrl) return false;
|
||||
setSavingAvatar(true);
|
||||
try {
|
||||
const response = await fetch(account.avatarUrl, { cache: "no-store" });
|
||||
@@ -97,8 +97,10 @@ export function ProfilePageClient({ user }: { user: UserSession }) {
|
||||
setSelectedAvatar(
|
||||
new File([blob], avatarFilename(blob.type), { type: blob.type }),
|
||||
);
|
||||
return true;
|
||||
} catch (error) {
|
||||
notify(errorMessage(error), "error");
|
||||
return false;
|
||||
} finally {
|
||||
setSavingAvatar(false);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,11 @@ export function MobileSidebar({
|
||||
ref={panelRef}
|
||||
>
|
||||
<SidebarBrand />
|
||||
<SidebarLinks className="mt-8" pathname={pathname} onNavigate={onClose} />
|
||||
<SidebarLinks
|
||||
className="mt-8"
|
||||
pathname={pathname}
|
||||
onNavigate={onClose}
|
||||
/>
|
||||
<SidebarAccount onLogout={onLogout} user={user} />
|
||||
</aside>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user