@@ -123,8 +124,12 @@ function ClientModal({ client }: { client: Client }) {
-
-
+ {client.managers.map((manager) => (
+
+ ))}
-
+
+ {client.sessions
+ .filter((session) => session.comments.length)
+ .map((session) => (
+
+
+ {isToday(new Date(session.createdAt))
+ ? "Сегодня"
+ : format(new Date(session.createdAt), "dd MMMM", {
+ locale: ru,
+ })}
+
+
+ {session.comments.map((comment) => (
+
+ ))}
+
+
+ ))}
+ {(client.sessions.length === 0 ||
+ client.sessions.filter((session) => session.comments.length)
+ .length === 0) && (
+
+
+

+
+
+
+ Пока что пусто
+
+
+ Здесь отображаются все комментарии по сеансам с текущим
+ клиентом
+
+
+
+ )}
+
);
diff --git a/src/components/modals/CreateSessionModal.tsx b/src/components/modals/CreateSessionModal.tsx
index 3696ae1..a8c6e5c 100644
--- a/src/components/modals/CreateSessionModal.tsx
+++ b/src/components/modals/CreateSessionModal.tsx
@@ -46,7 +46,7 @@ export default function CreateSessionModal({ targetServerId, client }: Props) {
useEffect(() => {
setSelectedApp(
selectedServer?.sessions?.[0]?.app ||
- selectedServer?.apps?.[0].app ||
+ selectedServer?.appsToServers?.[0].app ||
null
);
}, [selectedServer]);
@@ -244,15 +244,15 @@ export default function CreateSessionModal({ targetServerId, client }: Props) {
Выберите параметры сеанса
{selectedServer &&
- selectedServer?.apps &&
- selectedServer?.apps?.length > 0 && (
+ selectedServer?.appsToServers &&
+ selectedServer?.appsToServers?.length > 0 && (
app)}
+ projects={selectedServer?.appsToServers.map(({ app }) => app)}
selectedProject={selectedApp}
setSelectedProject={setSelectedApp}
/>
diff --git a/src/components/modals/EndSessionModal.tsx b/src/components/modals/EndSessionModal.tsx
index c1f6d6d..b1e1529 100644
--- a/src/components/modals/EndSessionModal.tsx
+++ b/src/components/modals/EndSessionModal.tsx
@@ -1,28 +1,42 @@
-import { useMutation } from "@tanstack/react-query";
-import { useQueryClient } from "@tanstack/react-query";
+import { useMutation, useQueryClient } from "@tanstack/react-query";
import useModalStore from "../../stores/useModalStore";
import { Session } from "../../types/Session";
import Button from "../Button";
import CurrentSessionModal from "./CurrentSessionModal";
import api from "../../utils/api";
import SpinIcon from "../icons/SpinIcon";
+import SessionModal from "./SessionModal";
+import { Server } from "../../types/Server";
function EndSessionModal({ session }: { session: Session }) {
const queryClient = useQueryClient();
- const { setModal } = useModalStore();
+
+ const { setModal, setPosition } = useModalStore();
const { mutate: endSession, isPending } = useMutation({
mutationKey: ["sessions", session.id],
mutationFn: () =>
- api.put(`sessions/${session.id}`, { json: { status: "ending" } }),
+ api
+ .put(`sessions/${session.id}`, { json: { status: "ending" } })
+ .json(),
onMutate: () => {
- queryClient.invalidateQueries({ queryKey: ["sessions"] });
- queryClient.invalidateQueries({ queryKey: ["last-started"] });
- queryClient.invalidateQueries({ queryKey: ["servers"] });
+ // queryClient.invalidateQueries({ queryKey: ["sessions"] });
+ // queryClient.invalidateQueries({ queryKey: ["last-started"] });
+ // queryClient.invalidateQueries({ queryKey: ["servers"] });
+ setModal(null);
},
onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: ["servers"] });
queryClient.invalidateQueries({ queryKey: ["last-sessions"] });
- setModal(null);
+ queryClient.invalidateQueries({ queryKey: ["sessions"] });
+ const servers = queryClient.getQueryData(["servers"]);
+ const updatedSession = servers
+ ?.find((s) => s.id === session.serverId)
+ ?.sessions?.find((s) => s.id === session.id);
+ if (updatedSession) {
+ setPosition("right");
+ setModal();
+ }
},
});
diff --git a/src/components/modals/SessionModal.tsx b/src/components/modals/SessionModal.tsx
index b666658..9586110 100644
--- a/src/components/modals/SessionModal.tsx
+++ b/src/components/modals/SessionModal.tsx
@@ -15,8 +15,8 @@ import DownloadIcon from "../icons/DownloadIcon";
import ShareIcon from "../icons/ShareIcon";
function SessionModal({ session }: { session: Session }) {
- const { data } = useQuery({
- queryKey: ["file-list"],
+ const { data: files } = useQuery({
+ queryKey: ["file-list", session.id],
queryFn: () =>
api
.get("files", {
@@ -122,13 +122,13 @@ function SessionModal({ session }: { session: Session }) {
- {data && (
+ {files && (
Документы по сеансу
-
+
-
+