diff --git a/apps/link/app/(main)/tickets/[id]/@detail/_components/ArticleCreateDialog.tsx b/apps/link/app/(main)/tickets/[id]/@detail/_components/ArticleCreateDialog.tsx index f70a5d6..00a488b 100644 --- a/apps/link/app/(main)/tickets/[id]/@detail/_components/ArticleCreateDialog.tsx +++ b/apps/link/app/(main)/tickets/[id]/@detail/_components/ArticleCreateDialog.tsx @@ -16,7 +16,7 @@ interface ArticleCreateDialogProps { ticketID: string; open: boolean; closeDialog: () => void; - kind: "reply" | "note"; + kind: string; } export const ArticleCreateDialog: FC = ({ @@ -26,8 +26,8 @@ export const ArticleCreateDialog: FC = ({ kind, }) => { const [body, setBody] = useState(""); - const backgroundColor = kind === "reply" ? "#1982FC" : "#FFB620"; - const color = kind === "reply" ? "white" : "black"; + const backgroundColor = kind === "note" ? "#FFB620" : "#1982FC"; + const color = kind === "note" ? "black" : "white"; const { fetcher } = useSWRConfig(); const createArticle = async () => { await fetcher({ @@ -37,7 +37,7 @@ export const ArticleCreateDialog: FC = ({ input: { article: { body, - type: kind === "note" ? "note" : "phone", + type: kind, internal: kind === "note", }, }, @@ -51,7 +51,7 @@ export const ArticleCreateDialog: FC = ({ = ({ }} onClick={createArticle} > - {kind === "reply" ? "Send Reply" : "Save Note"} + {kind === "note" ? "Save Note" : "Send Reply"} diff --git a/apps/link/app/(main)/tickets/[id]/@detail/_components/TicketDetail.tsx b/apps/link/app/(main)/tickets/[id]/@detail/_components/TicketDetail.tsx index 6dfb8cf..3d39926 100644 --- a/apps/link/app/(main)/tickets/[id]/@detail/_components/TicketDetail.tsx +++ b/apps/link/app/(main)/tickets/[id]/@detail/_components/TicketDetail.tsx @@ -45,8 +45,16 @@ export const TicketDetail: FC = ({ id }) => { const ticket = ticketData?.ticket; const ticketArticles = ticketArticlesData?.ticketArticles; + const externalArticles = ticketArticles?.edges.filter( + ({ node: article }: any) => !article.internal, + ); + const mostRecentExternalArticle = externalArticles?.length + ? externalArticles[externalArticles.length - 1].node + : null; + const mostRecentExternalArticleKind = + mostRecentExternalArticle?.type?.name ?? "phone"; const [dialogOpen, setDialogOpen] = useState(false); - const [articleKind, setArticleKind] = useState<"reply" | "note">("reply"); + const [articleKind, setArticleKind] = useState("phone"); const closeDialog = () => setDialogOpen(false); const shouldRender = @@ -139,7 +147,7 @@ export const TicketDetail: FC = ({ id }) => { mt: 2, }} onClick={() => { - setArticleKind("reply"); + setArticleKind(mostRecentExternalArticleKind); setDialogOpen(true); }} > diff --git a/apps/link/middleware.ts b/apps/link/middleware.ts index c064c4d..d9a000e 100644 --- a/apps/link/middleware.ts +++ b/apps/link/middleware.ts @@ -58,7 +58,6 @@ export default withAuth( const path = parsedURL.pathname; console.log({ p: parsedURL.pathname }); if (noAuthPaths.some((p: string) => path.startsWith(p))) { - console.log({ a: "no auth" }); return true; }