feat: add sign out confirm modal

This commit is contained in:
Zamitto 2024-06-19 11:14:06 -03:00
parent dc662b1c7d
commit 4dd0e43611
5 changed files with 66 additions and 4 deletions

View File

@ -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"
} }
} }

View File

@ -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?"
} }
} }

View File

@ -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>
</> </>

View 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>
</>
);
};

View File

@ -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`,
});