From a88ff44ebd85b27e561fb60390413a4bdfab7a67 Mon Sep 17 00:00:00 2001 From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com> Date: Fri, 16 Jan 2026 10:30:13 +0700 Subject: [PATCH] Update modal terminal --- FRONTEND/src/App.tsx | 3 + .../src/components/Modal/ModalRunScenario.tsx | 17 ++- .../src/components/Modal/ModalTerminal.tsx | 103 ++++++++++-------- 3 files changed, 75 insertions(+), 48 deletions(-) diff --git a/FRONTEND/src/App.tsx b/FRONTEND/src/App.tsx index 22cab6c..024fadd 100644 --- a/FRONTEND/src/App.tsx +++ b/FRONTEND/src/App.tsx @@ -890,6 +890,9 @@ function App() { listLicense={listLicense} getListIos={getListIos} getListLicense={getListLicense} + setScenarios={setScenarios} + listBrands={listBrands} + listCategories={listCategories} /> {/* void; - station: TStation; + station: TStation | undefined; listBrands: TBrands[]; listCategories: TCategories[]; }) => { @@ -57,6 +57,15 @@ const ModalRunScenario = ({ const [inputSeries, setInputSeries] = useState([]); const [inputTitle, setInputTitle] = useState(""); + useEffect(() => { + if (!open) { + setOptionBrand(""); + setOptionCategory(""); + setInputSeries([]); + setInputTitle(""); + } + }, [open]); + const filteredScenarios = () => { let listScenarios = [...scenarios]; if (inputTitle.trim()) @@ -497,8 +506,8 @@ const ModalRunScenario = ({ ) socket?.emit("run_all_dpelp", { lineIds: selectedLines?.map((el) => el.id), - stationName: station.name, - stationId: Number(station.id), + stationName: station?.name, + stationId: Number(station?.id), scenarioName: scenario.title, }); diff --git a/FRONTEND/src/components/Modal/ModalTerminal.tsx b/FRONTEND/src/components/Modal/ModalTerminal.tsx index 02502c0..40af55b 100644 --- a/FRONTEND/src/components/Modal/ModalTerminal.tsx +++ b/FRONTEND/src/components/Modal/ModalTerminal.tsx @@ -18,6 +18,8 @@ import type { FileInfo, IScenario, SwitchPortsProps, + TBrands, + TCategories, TDataTicket, TextFSM, TextTSMLicense, @@ -36,7 +38,7 @@ import { IconPlug, IconSettings, } from "@tabler/icons-react"; -import { ButtonDPELP, ButtonScenario } from "../ButtonAction"; +import { ButtonDPELP } from "../ButtonAction"; import CopyIcon from "../CopyIcon"; import moment from "moment"; import axios from "axios"; @@ -46,6 +48,8 @@ import { listBaudDefault } from "../../untils/constanst"; import { motion } from "motion/react"; import ModalSelectIOS from "./ModalSelectIOS"; import ModalSelectLicense from "./ModalSelectLicense"; +import ModalRunScenario from "./ModalRunScenario"; +import DrawerScenario from "./ModalScenario"; const apiUrl = import.meta.env.VITE_BACKEND_URL; const INIT_TICKET = { @@ -69,6 +73,9 @@ const ModalTerminal = ({ listLicense, getListLicense, getListIos, + listBrands, + listCategories, + setScenarios, }: { opened: boolean; onClose: () => void; @@ -81,6 +88,9 @@ const ModalTerminal = ({ listLicense: FileInfo[]; getListLicense: () => void; getListIos: () => void; + listBrands: TBrands[]; + listCategories: TCategories[]; + setScenarios: (value: React.SetStateAction) => void; }) => { const user = useMemo(() => { return localStorage.getItem("user") && @@ -101,6 +111,8 @@ const ModalTerminal = ({ useState(false); const [openSelectIos, setOpenSelectIos] = useState(false); const [openSelectLicense, setOpenSelectLicense] = useState(false); + const [openScenarioModal, setOpenScenarioModal] = useState(false); + const [openDrawerScenario, setOpenDrawerScenario] = useState(false); useEffect(() => { if (opened && line?.tickets && line?.tickets?.length > 0) { @@ -466,8 +478,17 @@ const ModalTerminal = ({ return ( { + if (openDrawerScenario) { + setOpenDrawerScenario(false); + return; + } + if (openScenarioModal) { + setOpenScenarioModal(false); + return; + } if (openSelectIos) return; onClose(); if ( @@ -1164,49 +1185,18 @@ const ModalTerminal = ({ (el) => el.title.toUpperCase() === "DPELP" )} /> - - - - - - - {scenarios.map((el, i) => ( - { - // setSelectedLines([]); - setIsDisable(true); - setTimeout(() => { - setIsDisable(false); - }, 5000); - }} - scenario={el} - station={stationItem} - /> - ))} - - - +