Add more graphql support to Link
This commit is contained in:
parent
d7f8c87ccb
commit
60f6061d49
14 changed files with 251 additions and 159 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { FC, useState } from "react";
|
||||
import { Grid, Button, Dialog, DialogActions, DialogContent, TextField } from "@mui/material";
|
||||
// import { request, gql } from "graphql-request";
|
||||
import { useSWRConfig } from "swr";
|
||||
import { updateTicketMutation } from "graphql/updateTicketMutation";
|
||||
|
||||
interface ArticleCreateDialogProps {
|
||||
ticketID: string;
|
||||
|
|
@ -10,54 +11,25 @@ interface ArticleCreateDialogProps {
|
|||
}
|
||||
|
||||
export const ArticleCreateDialog: FC<ArticleCreateDialogProps> = ({ ticketID, open, closeDialog, kind }) => {
|
||||
console.log({ ticketID })
|
||||
const [body, setBody] = useState("");
|
||||
const backgroundColor = kind === "reply" ? "#1982FC" : "#FFB620";
|
||||
const color = kind === "reply" ? "white" : "black";
|
||||
const origin = typeof window !== 'undefined' && window.location.origin
|
||||
? window.location.origin
|
||||
: '';
|
||||
const { fetcher } = useSWRConfig();
|
||||
const createArticle = async () => {
|
||||
// const token = document?.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||
// console.log({ token })
|
||||
const res = await fetch(`${origin}/api/v1/ticket_articles`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-CSRF-Token": "BG3wYuvTgi4ALfaZ-Mdq6i08wRFRJHeCPJbfGjfVarLRhwaxRC8J-AZvGiSNOiWrN38WT3C9WGLhcmaMb0AqBQ",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
ticket_id: ticketID,
|
||||
body,
|
||||
internal: kind === "note",
|
||||
sender: "Agent",
|
||||
}),
|
||||
});
|
||||
console.log({ res })
|
||||
/*
|
||||
const document = gql`
|
||||
|
||||
mutation {
|
||||
ticketUpdate(
|
||||
await fetcher(
|
||||
{
|
||||
document: updateTicketMutation,
|
||||
variables: {
|
||||
ticketId: `gid://zammad/Ticket/${ticketID}`,
|
||||
input: {
|
||||
ticketId: "1"
|
||||
body: "This is a test article"
|
||||
internal: false
|
||||
}
|
||||
) {
|
||||
article {
|
||||
id
|
||||
article: {
|
||||
body,
|
||||
type: kind === "note" ? "note" : "phone",
|
||||
internal: kind === "note"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const data = await request({
|
||||
url: `${origin}/graphql`,
|
||||
document,
|
||||
});
|
||||
|
||||
console.log({ data })
|
||||
*/
|
||||
});
|
||||
closeDialog();
|
||||
setBody("");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue