diff --git a/src/components/ModalContainer.tsx b/src/components/ModalContainer.tsx index f812998..0810626 100644 --- a/src/components/ModalContainer.tsx +++ b/src/components/ModalContainer.tsx @@ -45,7 +45,7 @@ function ModalContainer() { initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} - className='h-full' + className="h-full" >
-
-
+
+
setModal(null)} />
{modal} setModal(null)} > - + diff --git a/src/components/NewInput.tsx b/src/components/NewInput.tsx index 5fccc82..3e70bb9 100644 --- a/src/components/NewInput.tsx +++ b/src/components/NewInput.tsx @@ -13,11 +13,11 @@ function NewInput({ ...props }: NewInputProps) { return ( -
-
+
+
{placeholder && ( {placeholder} )} {isError && ( -

+

{errorMessage}

)} diff --git a/src/components/TableSelector.tsx b/src/components/TableSelector.tsx index b23bcf3..d211509 100644 --- a/src/components/TableSelector.tsx +++ b/src/components/TableSelector.tsx @@ -24,13 +24,15 @@ function TableSelector({ onSelect(table); }} className={clsx( - "rounded-[0.833vw] outline-none p-[1.111vw] space-y-[0.278vw] disabled:text-[#D6D6D6] disabled:cursor-not-allowed enabled:cursor-pointer enabled:hover:bg-[#F0F0F0] transition-colors shrink-0", + "rounded-[0.833vw] outline-none p-[1.111vw] space-y-[0.278vw] disabled:text-[#D6D6D6] enabled:cursor-pointer disabled:!cursor-not-allowed enabled:hover:bg-[#F0F0F0] transition-colors shrink-0", selectedTable?.id === table.id && "bg-[#F6F6F6]" )} > -

{table.name}

+

{table.name}

{table.status === "offline" ? ( -

Недоступен

+

+ Недоступен +

) : table.sessions && table.sessions.length > 0 && table.sessions[0].status !== "ended" ? ( diff --git a/src/components/modals/CreateSessionModal.tsx b/src/components/modals/CreateSessionModal.tsx index b644e50..f9933fe 100644 --- a/src/components/modals/CreateSessionModal.tsx +++ b/src/components/modals/CreateSessionModal.tsx @@ -18,9 +18,9 @@ interface Props { export default function CreateSessionModal({ targetServerId }: Props) { const { setModal } = useModalStore(); - const [name, setName] = useState(""); - const [phone, setPhone] = useState(""); - const [email, setEmail] = useState(""); + const [name, setName] = useState(null); + const [phone, setPhone] = useState(null); + const [email, setEmail] = useState(null); const [isSessionExists, setIsSessionExists] = useState(false); const queryClient = useQueryClient(); @@ -120,26 +120,54 @@ export default function CreateSessionModal({ targetServerId }: Props) { } endSession(undefined, { - onSuccess: () => { - createClient(undefined, { - onSuccess: (client) => { - createSession({ - clientId: client.id, - serverId: selectedServer.id, - appId: selectedApp.id, - }); - }, - onError: (error) => { - console.log(error); - }, - }); - }, + // onSuccess: () => { + // createClient(undefined, { + // onSuccess: (client) => { + // createSession({ + // clientId: client.id, + // serverId: selectedServer.id, + // appId: selectedApp.id, + // }); + // }, + // onError: (error) => { + // console.log(error); + // }, + // }); + // }, onError: (error) => { console.log("Ошибка при завершении сессии:", error); }, }); } + useEffect(() => { + console.log(servers, selectedServer, selectedApp, isSessionExists); + if ( + selectedServer && + servers?.find((server) => server.id === selectedServer?.id)?.sessions?.[0] + ?.status === "ended" && + selectedApp && + isSessionExists + ) { + createClient(undefined, { + onSuccess: (client) => { + createSession({ + clientId: client.id, + serverId: selectedServer?.id, + appId: selectedApp.id, + }); + }, + }); + } + }, [ + selectedApp, + servers, + createClient, + createSession, + isSessionExists, + selectedServer, + ]); + const ref = useRef(null); return ( @@ -162,20 +190,20 @@ export default function CreateSessionModal({ targetServerId }: Props) {

Укажите данные клиента

setPhone(e.target.value)} placeholder="Номер телефона" required /> setName(e.target.value)} placeholder="Имя" required /> setEmail(e.target.value)} placeholder="Электронная почта" /> diff --git a/src/components/modals/CurrentSessionModal.tsx b/src/components/modals/CurrentSessionModal.tsx index 6d36050..d85a5d8 100644 --- a/src/components/modals/CurrentSessionModal.tsx +++ b/src/components/modals/CurrentSessionModal.tsx @@ -103,7 +103,7 @@ function CurrentSessionModal({ session }: { session: ISession }) {

Детали

-
+

Менеджер:

{session.owner.fullname}

@@ -118,6 +118,7 @@ function CurrentSessionModal({ session }: { session: ISession }) {
{ @@ -128,6 +129,7 @@ function CurrentSessionModal({ session }: { session: ISession }) { Завершить сеанс setModal(null)}