Ticket edit updates
This commit is contained in:
parent
2568547384
commit
87724bb7b8
9 changed files with 297 additions and 352 deletions
|
|
@ -76,35 +76,59 @@ export const createTicketArticleAction = async (
|
|||
};
|
||||
|
||||
export const updateTicketAction = async (
|
||||
currentState: any,
|
||||
formData: FormData,
|
||||
ticketID: string,
|
||||
ticketInfo: Record<string, any>,
|
||||
) => {
|
||||
/*
|
||||
console.log({ ticketID, ticketInfo });
|
||||
try {
|
||||
const { id, project } = currentState.values;
|
||||
const updatedTicket = {
|
||||
title: formData.get("title"),
|
||||
};
|
||||
await executeMutation({
|
||||
project,
|
||||
mutation: UpdateAssetMutation,
|
||||
const input = {};
|
||||
if (ticketInfo.state) {
|
||||
input["stateId"] = ticketInfo.state;
|
||||
}
|
||||
if (ticketInfo.pendingTime) {
|
||||
input["pendingTime"] = ticketInfo.pendingTime;
|
||||
}
|
||||
if (ticketInfo.priority) {
|
||||
input["priorityId"] = ticketInfo.priority;
|
||||
}
|
||||
if (ticketInfo.group) {
|
||||
input["groupId"] = ticketInfo.group;
|
||||
}
|
||||
if (ticketInfo.owner) {
|
||||
input["ownerId"] = ticketInfo.owner;
|
||||
}
|
||||
|
||||
const result = await executeGraphQL({
|
||||
query: updateTicketMutation,
|
||||
variables: {
|
||||
id,
|
||||
input: updatedAsset,
|
||||
ticketId: `gid://zammad/Ticket/${ticketID}`,
|
||||
input,
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath(`/${project}/assets/${id}`);
|
||||
if (ticketInfo.tags?.length > 0) {
|
||||
const tagsResult = await executeGraphQL({
|
||||
query: updateTagsMutation,
|
||||
variables: {
|
||||
objectId: `gid://zammad/Ticket/${ticketID}`,
|
||||
tags: ticketInfo.tags,
|
||||
},
|
||||
});
|
||||
console.log({ tagsResult });
|
||||
}
|
||||
|
||||
console.log({ result });
|
||||
return {
|
||||
...currentState,
|
||||
values: { ...currentState.values, ...updatedAsset, id, project },
|
||||
result,
|
||||
success: true,
|
||||
};
|
||||
} catch (e: any) {
|
||||
return { success: false, message: e?.message ?? "Unknown error" };
|
||||
console.log({ e });
|
||||
return {
|
||||
success: false,
|
||||
message: e?.message ?? "Unknown error",
|
||||
};
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
export const getTicketAction = async (id: string) => {
|
||||
|
|
@ -112,7 +136,7 @@ export const getTicketAction = async (id: string) => {
|
|||
query: getTicketQuery,
|
||||
variables: { ticketId: `gid://zammad/Ticket/${id}` },
|
||||
});
|
||||
|
||||
console.log({ td: ticketData.ticket });
|
||||
return ticketData?.ticket;
|
||||
};
|
||||
|
||||
|
|
@ -125,38 +149,6 @@ export const getTicketArticlesAction = async (id: string) => {
|
|||
return ticketData?.ticketArticles;
|
||||
};
|
||||
|
||||
export const updateTicketTagsAction = async (
|
||||
currentState: any,
|
||||
formData: FormData,
|
||||
) => {
|
||||
/*
|
||||
try {
|
||||
const { id, project } = currentState.values;
|
||||
const updatedTicket = {
|
||||
title: formData.get("title"),
|
||||
};
|
||||
await executeMutation({
|
||||
project,
|
||||
mutation: UpdateAssetMutation,
|
||||
variables: {
|
||||
id,
|
||||
input: updatedAsset,
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath(`/${project}/assets/${id}`);
|
||||
|
||||
return {
|
||||
...currentState,
|
||||
values: { ...currentState.values, ...updatedAsset, id, project },
|
||||
success: true,
|
||||
};
|
||||
} catch (e: any) {
|
||||
return { success: false, message: e?.message ?? "Unknown error" };
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
export const getTicketStatesAction = async () => {
|
||||
const states = await executeREST({
|
||||
path: "/api/v1/ticket_states",
|
||||
|
|
@ -164,15 +156,15 @@ export const getTicketStatesAction = async () => {
|
|||
|
||||
const formattedStates =
|
||||
states?.map((state: any) => ({
|
||||
value: state.id,
|
||||
value: `gid://zammad/Ticket::State/${state.id}`,
|
||||
label: state.name,
|
||||
})) ?? [];
|
||||
|
||||
return formattedStates;
|
||||
};
|
||||
|
||||
export const getTicketTagsAction = async () => {
|
||||
const tags = await executeREST({
|
||||
export const getTagsAction = async () => {
|
||||
const { tags } = await executeREST({
|
||||
path: "/api/v1/tags",
|
||||
});
|
||||
|
||||
|
|
@ -186,7 +178,7 @@ export const getTicketPrioritiesAction = async () => {
|
|||
|
||||
const formattedPriorities =
|
||||
priorities?.map((priority: any) => ({
|
||||
value: priority.id,
|
||||
value: `gid://zammad/Ticket::Priority/${priority.id}`,
|
||||
label: priority.name,
|
||||
})) ?? [];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue