fix: ConfirmModal-Zustand in Redux ausgelagert zur Stabilisierung
- Neuen confirmModalSlice erstellt für globale Steuerung des Bestätigungsdialogs - Zustand wird nun nicht mehr durch Re-Renders oder Komponentenneuaufbau zurückgesetzt - ConfirmModal in KueEinstellung.tsx vollständig an Redux angebunden - Flackern und automatisches Schließen nach 10–15 Sekunden dauerhaft behoben
This commit is contained in:
@@ -9,6 +9,10 @@ import firmwareUpdate from "../handlers/firmwareUpdate";
|
||||
import ProgressModal from "@/components/main/settingsPageComponents/modals/ProgressModal";
|
||||
import { toast } from "react-toastify";
|
||||
import ConfirmModal from "@/components/common/ConfirmModal";
|
||||
import {
|
||||
openConfirmModal,
|
||||
closeConfirmModal,
|
||||
} from "@/redux/slices/confirmModalSlice";
|
||||
|
||||
interface Props {
|
||||
slot: number;
|
||||
@@ -49,7 +53,9 @@ export default function KueEinstellung({
|
||||
);
|
||||
const [isAdminLoggedIn] = useState(() => reduxAdmin);
|
||||
|
||||
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
||||
const showConfirmModal = useSelector(
|
||||
(state: RootState) => state.confirmModal.open
|
||||
);
|
||||
|
||||
const [isUpdating, setIsUpdating] = useState(false);
|
||||
const [progress, setProgress] = useState(0);
|
||||
@@ -243,7 +249,7 @@ export default function KueEinstellung({
|
||||
{isAdminLoggedIn && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => setShowConfirmModal(true)}
|
||||
onClick={() => dispatch(openConfirmModal())}
|
||||
className="bg-littwin-blue text-white px-4 py-2 rounded flex items-center"
|
||||
>
|
||||
Firmware Update
|
||||
@@ -255,9 +261,9 @@ export default function KueEinstellung({
|
||||
open={showConfirmModal}
|
||||
title="Firmware-Update starten?"
|
||||
message="⚠️ Das Firmware-Update kann einige Minuten dauern. Möchten Sie wirklich fortfahren?"
|
||||
onCancel={() => setShowConfirmModal(false)}
|
||||
onCancel={() => dispatch(closeConfirmModal())}
|
||||
onConfirm={async () => {
|
||||
setShowConfirmModal(false);
|
||||
dispatch(closeConfirmModal());
|
||||
toast.info("Firmware-Update gestartet. Bitte warten...");
|
||||
setIsUpdating(true);
|
||||
setProgress(0);
|
||||
|
||||
Reference in New Issue
Block a user