mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
update user
This commit is contained in:
parent
59b2096d06
commit
e467bbff66
@ -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) {
|
||||
<UserEditProfileModal
|
||||
visible={showEditProfileModal}
|
||||
onClose={() => setShowEditProfileModal(false)}
|
||||
updateUser={updateUser}
|
||||
userProfile={userProfile}
|
||||
/>
|
||||
|
||||
|
@ -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<void>;
|
||||
}
|
||||
|
||||
export const UserEditProfileModal = ({
|
||||
userProfile,
|
||||
visible,
|
||||
onClose,
|
||||
updateUser,
|
||||
}: UserEditProfileModalProps) => {
|
||||
const [displayName, setDisplayName] = useState(userProfile.displayName);
|
||||
const [newImagePath, setNewImagePath] = useState<string | null>(null);
|
||||
const [newImageBase64, setNewImageBase64] = useState<string | null>(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 (
|
||||
<>
|
||||
|
Loading…
Reference in New Issue
Block a user