fix/confirm-pack-delete: adjust code

This commit is contained in:
Guilherme Viana 2024-04-15 15:42:31 -03:00
parent 99ad11a3e5
commit 8836984454
2 changed files with 11 additions and 25 deletions

View File

@ -2,51 +2,39 @@ import { Button, Modal } from "@renderer/components";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import * as styles from "./delete-modal.css"; import * as styles from "./delete-modal.css";
type DeleteModalProps = { interface DeleteModalProps {
visible: boolean; visible: boolean;
title: string;
description: string;
onClose: () => void; onClose: () => void;
deleting: boolean; deleting: boolean;
deleteGame: () => void; deleteGame: () => void;
}; }
export function DeleteModal({ export function DeleteModal({
description,
onClose, onClose,
title,
visible, visible,
deleting, deleting,
deleteGame, deleteGame,
}: DeleteModalProps) { }: DeleteModalProps) {
const { t } = useTranslation("game_details"); const { t } = useTranslation("game_details");
function handleDeleteGame() {
deleteGame();
onClose();
}
return ( return (
<Modal <Modal
visible={visible} visible={visible}
title={title} title={t("delete_modal_title")}
description={description} description={t("delete_modal_description")}
onClose={onClose} onClose={onClose}
> >
<div className={styles.deleteActionsButtonsCtn}> <div className={styles.deleteActionsButtonsCtn}>
<Button <Button onClick={handleDeleteGame} theme="outline" disabled={deleting}>
onClick={() => {
deleteGame();
onClose();
}}
theme="outline"
disabled={deleting}
>
{t("delete")} {t("delete")}
</Button> </Button>
<Button <Button onClick={onClose} theme="primary" disabled={deleting}>
onClick={() => {
onClose();
}}
theme="primary"
disabled={deleting}
>
{t("cancel")} {t("cancel")}
</Button> </Button>
</div> </div>

View File

@ -179,8 +179,6 @@ export function HeroPanel({
<DeleteModal <DeleteModal
visible={showDeleteModal} visible={showDeleteModal}
title={t("delete_modal_title")}
description={t("delete_modal_description")}
onClose={() => setShowDeleteModal(false)} onClose={() => setShowDeleteModal(false)}
deleting={deleting} deleting={deleting}
deleteGame={() => deleteGame(game.id).then(getGame)} deleteGame={() => deleteGame(game.id).then(getGame)}