Link ticket fixes #1
This commit is contained in:
parent
1443a61164
commit
d9ce2f5883
21 changed files with 617 additions and 583 deletions
|
|
@ -33,7 +33,7 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
|
|||
document: getTicketQuery,
|
||||
variables: { ticketId: `gid://zammad/Ticket/${id}` },
|
||||
},
|
||||
{ refreshInterval: 100000 },
|
||||
{ refreshInterval: 10000 },
|
||||
);
|
||||
const { data: ticketArticlesData, error: ticketArticlesError }: any = useSWR(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { MuiChipsInput } from "mui-chips-input";
|
|||
import useSWR, { useSWRConfig } from "swr";
|
||||
import { getTicketQuery } from "../../../../../_graphql/getTicketQuery";
|
||||
import { updateTicketMutation } from "../../../../../_graphql/updateTicketMutation";
|
||||
import { updateTagsMutation } from "../../../../../_graphql/updateTagsMutation";
|
||||
import "@chatscope/chat-ui-kit-styles/dist/default/styles.min.css";
|
||||
|
||||
interface TicketEditProps {
|
||||
|
|
@ -43,7 +44,7 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
document: getTicketQuery,
|
||||
variables: { ticketId: `gid://zammad/Ticket/${id}` },
|
||||
},
|
||||
{ refreshInterval: 100000 },
|
||||
{ refreshInterval: 10000 },
|
||||
);
|
||||
useEffect(() => {
|
||||
const ticket = ticketData?.ticket;
|
||||
|
|
@ -59,14 +60,8 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
setSelectedTags(ticket.tags);
|
||||
}
|
||||
}, [ticketData, ticketError]);
|
||||
const updateTicket = async () => {
|
||||
const input = {
|
||||
ownerId: `gid://zammad/User/${selectedOwner}`,
|
||||
priorityId: `gid://zammad/Ticket::Priority/${selectedPriority}`,
|
||||
stateId: `gid://zammad/Ticket::State/${selectedState}`,
|
||||
groupId: `gid://zammad/Group/${selectedGroup}`,
|
||||
// tags: selectedTags,
|
||||
};
|
||||
const updateTicket = async (input: any) => {
|
||||
console.log({ input });
|
||||
const res = await fetcher({
|
||||
document: updateTicketMutation,
|
||||
variables: {
|
||||
|
|
@ -76,6 +71,17 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
});
|
||||
console.log({ res });
|
||||
};
|
||||
const updateTags = async (tags: string[]) => {
|
||||
console.log({ tags });
|
||||
const res = await fetcher({
|
||||
document: updateTagsMutation,
|
||||
variables: {
|
||||
objectId: `gid://zammad/Ticket/${id}`,
|
||||
tags,
|
||||
},
|
||||
});
|
||||
console.log({ res });
|
||||
};
|
||||
const shouldRender = ticketData && !ticketError;
|
||||
|
||||
return (
|
||||
|
|
@ -88,8 +94,11 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
defaultValue={selectedGroup}
|
||||
value={selectedGroup}
|
||||
onChange={(e: any) => {
|
||||
setSelectedGroup(e.target.value);
|
||||
updateTicket();
|
||||
const newGroup = e.target.value;
|
||||
setSelectedGroup(newGroup);
|
||||
updateTicket({
|
||||
groupId: `gid://zammad/Group/${newGroup}`,
|
||||
});
|
||||
}}
|
||||
size="small"
|
||||
sx={{
|
||||
|
|
@ -109,8 +118,9 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
<Select
|
||||
value={selectedOwner}
|
||||
onChange={(e: any) => {
|
||||
setSelectedOwner(e.target.value);
|
||||
updateTicket();
|
||||
const newOwner = e.target.value;
|
||||
setSelectedOwner(newOwner);
|
||||
updateTicket({ ownerId: `gid://zammad/User/${newOwner}` });
|
||||
}}
|
||||
size="small"
|
||||
sx={{
|
||||
|
|
@ -130,8 +140,11 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
<Select
|
||||
value={selectedState}
|
||||
onChange={(e: any) => {
|
||||
setSelectedState(e.target.value);
|
||||
updateTicket();
|
||||
const newState = e.target.value;
|
||||
setSelectedState(newState);
|
||||
updateTicket({
|
||||
stateId: `gid://zammad/Ticket::State/${newState}`,
|
||||
});
|
||||
}}
|
||||
size="small"
|
||||
sx={{
|
||||
|
|
@ -151,8 +164,11 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
<Select
|
||||
value={selectedPriority}
|
||||
onChange={(e: any) => {
|
||||
setSelectedPriority(e.target.value);
|
||||
updateTicket();
|
||||
const newPriority = e.target.value;
|
||||
setSelectedPriority(newPriority);
|
||||
updateTicket({
|
||||
priorityId: `gid://zammad/Ticket::Priority/${newPriority}`,
|
||||
});
|
||||
}}
|
||||
size="small"
|
||||
sx={{
|
||||
|
|
@ -175,7 +191,7 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
value={selectedTags}
|
||||
onChange={(tags: any) => {
|
||||
setSelectedTags(tags);
|
||||
updateTicket();
|
||||
updateTags(tags);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue