mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 11:42:21 +03:00
feat: add sign out confirm modal
This commit is contained in:
parent
dc662b1c7d
commit
4dd0e43611
@ -240,6 +240,9 @@
|
|||||||
"save": "Save",
|
"save": "Save",
|
||||||
"edit_profile": "Edit Profile",
|
"edit_profile": "Edit Profile",
|
||||||
"saved_successfully": "Saved successfully",
|
"saved_successfully": "Saved successfully",
|
||||||
"try_again": "Please, try again"
|
"try_again": "Please, try again",
|
||||||
|
"signout_modal_title": "Are you sure?",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"signout": "Sign Out"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,6 +240,9 @@
|
|||||||
"save": "Salvar",
|
"save": "Salvar",
|
||||||
"edit_profile": "Editar Perfil",
|
"edit_profile": "Editar Perfil",
|
||||||
"saved_successfully": "Salvo com sucesso",
|
"saved_successfully": "Salvo com sucesso",
|
||||||
"try_again": "Por favor, tente novamente"
|
"try_again": "Por favor, tente novamente",
|
||||||
|
"cancel": "Cancelar",
|
||||||
|
"signout": "Sair da conta",
|
||||||
|
"signout_modal_title": "Tem certeza?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import { buildGameDetailsPath } from "@renderer/helpers";
|
|||||||
import { PersonIcon, TelescopeIcon } from "@primer/octicons-react";
|
import { PersonIcon, TelescopeIcon } from "@primer/octicons-react";
|
||||||
import { Button } from "@renderer/components";
|
import { Button } from "@renderer/components";
|
||||||
import { UserEditProfileModal } from "./user-edit-modal";
|
import { UserEditProfileModal } from "./user-edit-modal";
|
||||||
|
import { UserSignOutModal } from "./user-signout-modal";
|
||||||
|
|
||||||
const MAX_MINUTES_TO_SHOW_IN_PLAYTIME = 120;
|
const MAX_MINUTES_TO_SHOW_IN_PLAYTIME = 120;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ export function UserContent({
|
|||||||
const { userDetails, profileBackground, signOut } = useUserDetails();
|
const { userDetails, profileBackground, signOut } = useUserDetails();
|
||||||
|
|
||||||
const [showEditProfileModal, setShowEditProfileModal] = useState(false);
|
const [showEditProfileModal, setShowEditProfileModal] = useState(false);
|
||||||
|
const [showSignOutModal, setShowSignOutModal] = useState(false);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ export function UserContent({
|
|||||||
setShowEditProfileModal(true);
|
setShowEditProfileModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSignout = async () => {
|
const handleConfirmSignout = async () => {
|
||||||
signOut();
|
signOut();
|
||||||
navigate("/");
|
navigate("/");
|
||||||
};
|
};
|
||||||
@ -87,6 +89,12 @@ export function UserContent({
|
|||||||
userProfile={userProfile}
|
userProfile={userProfile}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<UserSignOutModal
|
||||||
|
visible={showSignOutModal}
|
||||||
|
onClose={() => setShowSignOutModal(false)}
|
||||||
|
onConfirm={handleConfirmSignout}
|
||||||
|
/>
|
||||||
|
|
||||||
<section
|
<section
|
||||||
className={styles.profileContentBox}
|
className={styles.profileContentBox}
|
||||||
style={{
|
style={{
|
||||||
@ -124,7 +132,10 @@ export function UserContent({
|
|||||||
Editar perfil
|
Editar perfil
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button theme="danger" onClick={handleSignout}>
|
<Button
|
||||||
|
theme="danger"
|
||||||
|
onClick={() => setShowSignOutModal(true)}
|
||||||
|
>
|
||||||
{t("sign_out")}
|
{t("sign_out")}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
|
37
src/renderer/src/pages/user/user-signout-modal.tsx
Normal file
37
src/renderer/src/pages/user/user-signout-modal.tsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { Button, Modal } from "@renderer/components";
|
||||||
|
import * as styles from "./user.css";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
export interface UserEditProfileModalProps {
|
||||||
|
visible: boolean;
|
||||||
|
onConfirm: () => void;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const UserSignOutModal = ({
|
||||||
|
visible,
|
||||||
|
onConfirm,
|
||||||
|
onClose,
|
||||||
|
}: UserEditProfileModalProps) => {
|
||||||
|
const { t } = useTranslation("user_profile");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Modal
|
||||||
|
visible={visible}
|
||||||
|
title={t("signout_modal_title")}
|
||||||
|
onClose={onClose}
|
||||||
|
>
|
||||||
|
<div className={styles.signOutModalButtonsContainer}>
|
||||||
|
<Button onClick={onConfirm} theme="outline">
|
||||||
|
{t("signout")}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button onClick={onClose} theme="primary">
|
||||||
|
{t("cancel")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
@ -191,3 +191,11 @@ export const noDownloads = style({
|
|||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
gap: `${SPACING_UNIT}px`,
|
gap: `${SPACING_UNIT}px`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const signOutModalButtonsContainer = style({
|
||||||
|
display: "flex",
|
||||||
|
width: "100%",
|
||||||
|
justifyContent: "end",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: `${SPACING_UNIT}px`,
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user