GraphQL and MUI license updates

This commit is contained in:
Darren Clarke 2023-07-17 12:23:12 +00:00 committed by GitHub
parent 90143e5e41
commit 21db95a8e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 811 additions and 207 deletions

View file

@ -3,6 +3,7 @@
import { FC, useState } from "react";
import useSWR from "swr";
import { getTicketQuery } from "app/_graphql/getTicketQuery";
import { getTicketArticlesQuery } from "app/_graphql/getTicketArticlesQuery";
import {
Grid,
Box,
@ -34,18 +35,26 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
},
{ refreshInterval: 100000 }
);
const { data: ticketArticlesData, error: ticketArticlesError }: any = useSWR(
{
document: getTicketArticlesQuery,
variables: { ticketId: `gid://zammad/Ticket/${id}` },
},
{ refreshInterval: 2000 }
);
console.log({ ticketData, ticketError });
const ticket = ticketData?.ticket;
const ticketArticles = ticketArticlesData?.ticketArticles;
const [dialogOpen, setDialogOpen] = useState(false);
const [articleKind, setArticleKind] = useState<"reply" | "note">("reply");
const closeDialog = () => setDialogOpen(false);
const shouldRender = ticketData && !ticketError;
const shouldRender =
ticketData && !ticketError && ticketArticlesData && !ticketArticlesError;
return (
shouldRender && (
<>
<Box sx={{ height: "100%", width: "100%" }}>
<MainContainer>
<ChatContainer>
<ConversationHeader>
@ -73,13 +82,13 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
</ConversationHeader.Content>
</ConversationHeader>
<MessageList style={{ marginBottom: 80 }}>
{ticket.articles.edges.map(({ node: article }: any) => (
{ticketArticles.edges.map(({ node: article }: any) => (
<Message
key={article.id}
className={
article.internal
? "internal-note"
: article.sender.name === "Agent"
: article?.sender?.name === "Agent"
? "outgoing-message"
: "incoming-message"
}
@ -171,7 +180,7 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
closeDialog={closeDialog}
kind={articleKind}
/>
</>
</Box>
)
);
};