mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-24 05:54: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) {
|
export function UserContent({ userProfile }: ProfileContentProps) {
|
||||||
const { t, i18n } = useTranslation("user_profile");
|
const { t, i18n } = useTranslation("user_profile");
|
||||||
|
|
||||||
const { userDetails, profileBackground, signOut } = useUserDetails();
|
const { userDetails, profileBackground, signOut, updateUser } =
|
||||||
|
useUserDetails();
|
||||||
|
|
||||||
const [showEditProfileModal, setShowEditProfileModal] = useState(false);
|
const [showEditProfileModal, setShowEditProfileModal] = useState(false);
|
||||||
|
|
||||||
@ -79,6 +80,7 @@ export function UserContent({ userProfile }: ProfileContentProps) {
|
|||||||
<UserEditProfileModal
|
<UserEditProfileModal
|
||||||
visible={showEditProfileModal}
|
visible={showEditProfileModal}
|
||||||
onClose={() => setShowEditProfileModal(false)}
|
onClose={() => setShowEditProfileModal(false)}
|
||||||
|
updateUser={updateUser}
|
||||||
userProfile={userProfile}
|
userProfile={userProfile}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -4,22 +4,27 @@ import * as styles from "./user.css";
|
|||||||
import { PersonIcon } from "@primer/octicons-react";
|
import { PersonIcon } from "@primer/octicons-react";
|
||||||
import { SPACING_UNIT } from "@renderer/theme.css";
|
import { SPACING_UNIT } from "@renderer/theme.css";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { useToast } from "@renderer/hooks";
|
||||||
|
|
||||||
export interface UserEditProfileModalProps {
|
export interface UserEditProfileModalProps {
|
||||||
userProfile: UserProfile;
|
userProfile: UserProfile;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
updateUser: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UserEditProfileModal = ({
|
export const UserEditProfileModal = ({
|
||||||
userProfile,
|
userProfile,
|
||||||
visible,
|
visible,
|
||||||
onClose,
|
onClose,
|
||||||
|
updateUser,
|
||||||
}: UserEditProfileModalProps) => {
|
}: UserEditProfileModalProps) => {
|
||||||
const [displayName, setDisplayName] = useState(userProfile.displayName);
|
const [displayName, setDisplayName] = useState(userProfile.displayName);
|
||||||
const [newImagePath, setNewImagePath] = useState<string | null>(null);
|
const [newImagePath, setNewImagePath] = useState<string | null>(null);
|
||||||
const [newImageBase64, setNewImageBase64] = useState<string | null>(null);
|
const [newImageBase64, setNewImageBase64] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const { showSuccessToast, showErrorToast } = useToast();
|
||||||
|
|
||||||
const handleChangeProfileAvatar = async () => {
|
const handleChangeProfileAvatar = async () => {
|
||||||
const { filePaths } = await window.electron.showOpenDialog({
|
const { filePaths } = await window.electron.showOpenDialog({
|
||||||
properties: ["openFile"],
|
properties: ["openFile"],
|
||||||
@ -43,13 +48,17 @@ export const UserEditProfileModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveProfile = async () => {
|
const handleSaveProfile = async () => {
|
||||||
await window.electron
|
window.electron
|
||||||
.updateProfile(displayName, newImagePath)
|
.updateProfile(displayName, newImagePath)
|
||||||
.catch((err) => {
|
.then(() => {
|
||||||
console.log("errro", err);
|
updateUser();
|
||||||
|
setNewImagePath(null);
|
||||||
|
showSuccessToast("Sucesso");
|
||||||
|
onClose();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
showErrorToast("Erro");
|
||||||
});
|
});
|
||||||
setNewImagePath(null);
|
|
||||||
onClose();
|
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Loading…
Reference in New Issue
Block a user