Reply type fixes
This commit is contained in:
parent
7071f0c64a
commit
79653705fe
3 changed files with 16 additions and 9 deletions
|
|
@ -16,7 +16,7 @@ interface ArticleCreateDialogProps {
|
||||||
ticketID: string;
|
ticketID: string;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
closeDialog: () => void;
|
closeDialog: () => void;
|
||||||
kind: "reply" | "note";
|
kind: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ArticleCreateDialog: FC<ArticleCreateDialogProps> = ({
|
export const ArticleCreateDialog: FC<ArticleCreateDialogProps> = ({
|
||||||
|
|
@ -26,8 +26,8 @@ export const ArticleCreateDialog: FC<ArticleCreateDialogProps> = ({
|
||||||
kind,
|
kind,
|
||||||
}) => {
|
}) => {
|
||||||
const [body, setBody] = useState("");
|
const [body, setBody] = useState("");
|
||||||
const backgroundColor = kind === "reply" ? "#1982FC" : "#FFB620";
|
const backgroundColor = kind === "note" ? "#FFB620" : "#1982FC";
|
||||||
const color = kind === "reply" ? "white" : "black";
|
const color = kind === "note" ? "black" : "white";
|
||||||
const { fetcher } = useSWRConfig();
|
const { fetcher } = useSWRConfig();
|
||||||
const createArticle = async () => {
|
const createArticle = async () => {
|
||||||
await fetcher({
|
await fetcher({
|
||||||
|
|
@ -37,7 +37,7 @@ export const ArticleCreateDialog: FC<ArticleCreateDialogProps> = ({
|
||||||
input: {
|
input: {
|
||||||
article: {
|
article: {
|
||||||
body,
|
body,
|
||||||
type: kind === "note" ? "note" : "phone",
|
type: kind,
|
||||||
internal: kind === "note",
|
internal: kind === "note",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -51,7 +51,7 @@ export const ArticleCreateDialog: FC<ArticleCreateDialogProps> = ({
|
||||||
<Dialog open={open} maxWidth="sm" fullWidth>
|
<Dialog open={open} maxWidth="sm" fullWidth>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<TextField
|
<TextField
|
||||||
label={kind === "reply" ? "Write reply" : "Write internal note"}
|
label={kind === "note" ? "Write internal note" : "Write reply"}
|
||||||
multiline
|
multiline
|
||||||
rows={10}
|
rows={10}
|
||||||
fullWidth
|
fullWidth
|
||||||
|
|
@ -92,7 +92,7 @@ export const ArticleCreateDialog: FC<ArticleCreateDialogProps> = ({
|
||||||
}}
|
}}
|
||||||
onClick={createArticle}
|
onClick={createArticle}
|
||||||
>
|
>
|
||||||
{kind === "reply" ? "Send Reply" : "Save Note"}
|
{kind === "note" ? "Save Note" : "Send Reply"}
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,16 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
|
||||||
|
|
||||||
const ticket = ticketData?.ticket;
|
const ticket = ticketData?.ticket;
|
||||||
const ticketArticles = ticketArticlesData?.ticketArticles;
|
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 [dialogOpen, setDialogOpen] = useState(false);
|
||||||
const [articleKind, setArticleKind] = useState<"reply" | "note">("reply");
|
const [articleKind, setArticleKind] = useState("phone");
|
||||||
const closeDialog = () => setDialogOpen(false);
|
const closeDialog = () => setDialogOpen(false);
|
||||||
|
|
||||||
const shouldRender =
|
const shouldRender =
|
||||||
|
|
@ -139,7 +147,7 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
|
||||||
mt: 2,
|
mt: 2,
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setArticleKind("reply");
|
setArticleKind(mostRecentExternalArticleKind);
|
||||||
setDialogOpen(true);
|
setDialogOpen(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ export default withAuth(
|
||||||
const path = parsedURL.pathname;
|
const path = parsedURL.pathname;
|
||||||
console.log({ p: parsedURL.pathname });
|
console.log({ p: parsedURL.pathname });
|
||||||
if (noAuthPaths.some((p: string) => path.startsWith(p))) {
|
if (noAuthPaths.some((p: string) => path.startsWith(p))) {
|
||||||
console.log({ a: "no auth" });
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue