fix: select Folder Modal doesn't close

This commit is contained in:
Hydra 2024-04-20 21:11:01 -03:00 committed by José Luís
parent bd2ad383c6
commit 2e53523076
2 changed files with 11 additions and 4 deletions

View File

@ -51,6 +51,7 @@ export function GameDetails() {
const { t, i18n } = useTranslation("game_details"); const { t, i18n } = useTranslation("game_details");
const [showRepacksModal, setShowRepacksModal] = useState(false); const [showRepacksModal, setShowRepacksModal] = useState(false);
const [showSelectFolderModal, setShowSelectFolderModal] = useState(false);
const randomGameObjectID = useRef<string | null>(null); const randomGameObjectID = useRef<string | null>(null);
@ -153,6 +154,7 @@ export function GameDetails() {
).then(() => { ).then(() => {
getGame(); getGame();
setShowRepacksModal(false); setShowRepacksModal(false);
setShowSelectFolderModal(false);
}); });
}; };
@ -177,6 +179,8 @@ export function GameDetails() {
visible={showRepacksModal} visible={showRepacksModal}
gameDetails={gameDetails} gameDetails={gameDetails}
startDownload={handleStartDownload} startDownload={handleStartDownload}
showSelectFolderModal={showSelectFolderModal}
setShowSelectFolderModal={setShowSelectFolderModal}
onClose={() => setShowRepacksModal(false)} onClose={() => setShowRepacksModal(false)}
/> />
)} )}

View File

@ -16,6 +16,8 @@ import { SelectFolderModal } from "./select-folder-modal";
export interface RepacksModalProps { export interface RepacksModalProps {
visible: boolean; visible: boolean;
gameDetails: ShopDetails; gameDetails: ShopDetails;
showSelectFolderModal: boolean;
setShowSelectFolderModal: (value: boolean) => void;
startDownload: (repackId: number, downloadPath: string) => Promise<void>; startDownload: (repackId: number, downloadPath: string) => Promise<void>;
onClose: () => void; onClose: () => void;
} }
@ -23,10 +25,11 @@ export interface RepacksModalProps {
export function RepacksModal({ export function RepacksModal({
visible, visible,
gameDetails, gameDetails,
showSelectFolderModal,
setShowSelectFolderModal,
startDownload, startDownload,
onClose, onClose,
}: RepacksModalProps) { }: RepacksModalProps) {
const [openSelectFolderModal, setOpenSelectFolderModal] = useState(false);
const [diskFreeSpace, setDiskFreeSpace] = useState<DiskSpace>(null); const [diskFreeSpace, setDiskFreeSpace] = useState<DiskSpace>(null);
const [filteredRepacks, setFilteredRepacks] = useState<GameRepack[]>([]); const [filteredRepacks, setFilteredRepacks] = useState<GameRepack[]>([]);
const [repack, setRepack] = useState<GameRepack>(null); const [repack, setRepack] = useState<GameRepack>(null);
@ -53,7 +56,7 @@ export function RepacksModal({
const handleRepackClick = (repack: GameRepack) => { const handleRepackClick = (repack: GameRepack) => {
setRepack(repack); setRepack(repack);
setOpenSelectFolderModal(true); setShowSelectFolderModal(true);
}; };
const handleFilter: React.ChangeEventHandler<HTMLInputElement> = (event) => { const handleFilter: React.ChangeEventHandler<HTMLInputElement> = (event) => {
@ -76,8 +79,8 @@ export function RepacksModal({
onClose={onClose} onClose={onClose}
> >
<SelectFolderModal <SelectFolderModal
visible={openSelectFolderModal} visible={showSelectFolderModal}
onClose={() => setOpenSelectFolderModal(false)} onClose={() => setShowSelectFolderModal(false)}
gameDetails={gameDetails} gameDetails={gameDetails}
startDownload={startDownload} startDownload={startDownload}
repack={repack} repack={repack}