diff --git a/src/renderer/src/pages/user/user-content.tsx b/src/renderer/src/pages/user/user-content.tsx index 739afda7..035a56b1 100644 --- a/src/renderer/src/pages/user/user-content.tsx +++ b/src/renderer/src/pages/user/user-content.tsx @@ -22,7 +22,8 @@ export interface ProfileContentProps { export function UserContent({ userProfile }: ProfileContentProps) { const { t, i18n } = useTranslation("user_profile"); - const { userDetails, profileBackground, signOut } = useUserDetails(); + const { userDetails, profileBackground, signOut, updateUser } = + useUserDetails(); const [showEditProfileModal, setShowEditProfileModal] = useState(false); @@ -79,6 +80,7 @@ export function UserContent({ userProfile }: ProfileContentProps) { setShowEditProfileModal(false)} + updateUser={updateUser} userProfile={userProfile} /> diff --git a/src/renderer/src/pages/user/user-edit-modal.tsx b/src/renderer/src/pages/user/user-edit-modal.tsx index 195639c1..bba70366 100644 --- a/src/renderer/src/pages/user/user-edit-modal.tsx +++ b/src/renderer/src/pages/user/user-edit-modal.tsx @@ -4,22 +4,27 @@ import * as styles from "./user.css"; import { PersonIcon } from "@primer/octicons-react"; import { SPACING_UNIT } from "@renderer/theme.css"; import { useState } from "react"; +import { useToast } from "@renderer/hooks"; export interface UserEditProfileModalProps { userProfile: UserProfile; visible: boolean; onClose: () => void; + updateUser: () => Promise; } export const UserEditProfileModal = ({ userProfile, visible, onClose, + updateUser, }: UserEditProfileModalProps) => { const [displayName, setDisplayName] = useState(userProfile.displayName); const [newImagePath, setNewImagePath] = useState(null); const [newImageBase64, setNewImageBase64] = useState(null); + const { showSuccessToast, showErrorToast } = useToast(); + const handleChangeProfileAvatar = async () => { const { filePaths } = await window.electron.showOpenDialog({ properties: ["openFile"], @@ -43,13 +48,17 @@ export const UserEditProfileModal = ({ }; const handleSaveProfile = async () => { - await window.electron + window.electron .updateProfile(displayName, newImagePath) - .catch((err) => { - console.log("errro", err); + .then(() => { + updateUser(); + setNewImagePath(null); + showSuccessToast("Sucesso"); + onClose(); + }) + .catch(() => { + showErrorToast("Erro"); }); - setNewImagePath(null); - onClose(); }; return ( <>