Update deps, ticket edit updates
This commit is contained in:
parent
aa453954ed
commit
2d892779bf
19 changed files with 1753 additions and 7776 deletions
|
|
@ -42,31 +42,31 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
useEffect(() => {
|
||||
const fetchAgents = async () => {
|
||||
const result = await getAgentsAction();
|
||||
console.log({ result });
|
||||
console.log({ agents: result });
|
||||
setAgents(result);
|
||||
};
|
||||
|
||||
const fetchGroups = async () => {
|
||||
const result = await getGroupsAction();
|
||||
console.log({ result });
|
||||
console.log({ groups: result });
|
||||
setGroups(result);
|
||||
};
|
||||
|
||||
const fetchTicketStates = async () => {
|
||||
const result = await getTicketStatesAction();
|
||||
console.log({ result });
|
||||
console.log({ ticketStates: result });
|
||||
setTicketStates(result);
|
||||
};
|
||||
|
||||
const fetchTicketPriorities = async () => {
|
||||
const result = await getTicketPrioritiesAction();
|
||||
console.log({ result });
|
||||
console.log({ ticketPriorities: result });
|
||||
setTicketPriorities(result);
|
||||
};
|
||||
|
||||
const fetchTicketTags = async () => {
|
||||
const result = await getTicketTagsAction();
|
||||
console.log({ result });
|
||||
console.log({ tags: result });
|
||||
setTags(result);
|
||||
};
|
||||
|
||||
|
|
@ -127,10 +127,10 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
errors: [],
|
||||
values: {
|
||||
customer: "",
|
||||
group: ticket.group.id?.split("/").pop(),
|
||||
owner: ticket.owner.id?.split("/").pop(),
|
||||
priority: ticket.priority.id?.split("/").pop(),
|
||||
state: ticket.state.id?.split("/").pop(),
|
||||
group: ticket?.group?.id?.split("/").pop(),
|
||||
owner: ticket?.owner?.id?.split("/").pop(),
|
||||
priority: ticket?.priority?.id?.split("/").pop(),
|
||||
state: ticket?.state?.id?.split("/").pop(),
|
||||
tags: [],
|
||||
title: "",
|
||||
article: {
|
||||
|
|
@ -157,21 +157,7 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
name="group"
|
||||
label="Group"
|
||||
formState={formState}
|
||||
getOptions={() =>
|
||||
groups?.map((group: any) => ({
|
||||
value: group.id,
|
||||
label: group.name,
|
||||
})) ?? []
|
||||
}
|
||||
/*
|
||||
onChange={(e: any) => {
|
||||
const newGroup = e.target.value;
|
||||
setSelectedGroup(newGroup);
|
||||
updateTicket({
|
||||
groupId: `gid://zammad/Group/${newGroup}`,
|
||||
});
|
||||
}}
|
||||
*/
|
||||
getOptions={() => groups}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
|
|
@ -180,19 +166,7 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
name="owner"
|
||||
label="Owner"
|
||||
formState={formState}
|
||||
getOptions={() =>
|
||||
agents?.map((user: any) => ({
|
||||
value: user.id,
|
||||
label: `${user.firstname} ${user.lastname}`,
|
||||
})) ?? []
|
||||
}
|
||||
/*
|
||||
onChange={(e: any) => {
|
||||
const newOwner = e.target.value;
|
||||
setSelectedOwner(newOwner);
|
||||
updateTicket({ ownerId: `gid://zammad/User/${newOwner}` });
|
||||
}}
|
||||
*/
|
||||
getOptions={() => agents}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
|
|
@ -249,12 +223,7 @@ export const TicketEdit: FC<TicketEditProps> = ({ id }) => {
|
|||
name="priority"
|
||||
label="Priority"
|
||||
formState={formState}
|
||||
getOptions={() =>
|
||||
ticketPriorities?.map((priority: any) => ({
|
||||
value: priority.id,
|
||||
label: priority.name,
|
||||
})) ?? []
|
||||
}
|
||||
getOptions={() => ticketPriorities}
|
||||
/*
|
||||
onChange={(e: any) => {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use server";
|
||||
|
||||
import { executeGraphQL } from "app/_lib/zammad";
|
||||
import { executeGraphQL, executeREST } from "app/_lib/zammad";
|
||||
import { getTicketOverviewCountsQuery } from "app/_graphql/getTicketOverviewCountsQuery";
|
||||
import { getTicketsByOverviewQuery } from "app/_graphql/getTicketsByOverviewQuery";
|
||||
|
||||
|
|
@ -22,17 +22,12 @@ export const getOverviewTicketsAction = async (name: string) => {
|
|||
let error = null;
|
||||
|
||||
if (name === "Recent") {
|
||||
const response = await fetch(
|
||||
`${process.env.ZAMMAD_URL}/api/v1/recent_view`,
|
||||
);
|
||||
const recent = await response.json();
|
||||
console.log({ recent });
|
||||
const recent = await executeREST({ path: "/api/v1/recent_view" });
|
||||
|
||||
for (const rec of recent) {
|
||||
const res = await fetch(
|
||||
`${process.env.ZAMMAD_URL}/api/v1/tickets/${rec.o_id}`,
|
||||
);
|
||||
const tkt = await res.json();
|
||||
const tkt = await executeREST({
|
||||
path: `/api/v1/tickets/${rec.o_id}`,
|
||||
});
|
||||
tickets.push({
|
||||
...tkt,
|
||||
internalId: tkt.id,
|
||||
|
|
|
|||
|
|
@ -170,7 +170,13 @@ export const getTicketTagsAction = async () => {
|
|||
path: "/api/v1/tags",
|
||||
});
|
||||
|
||||
return states;
|
||||
const formattedStates =
|
||||
states?.map((state: any) => ({
|
||||
value: state.id,
|
||||
label: state.name,
|
||||
})) ?? [];
|
||||
|
||||
return formattedStates;
|
||||
};
|
||||
|
||||
export const getTicketPrioritiesAction = async () => {
|
||||
|
|
@ -178,5 +184,11 @@ export const getTicketPrioritiesAction = async () => {
|
|||
path: "/api/v1/ticket_priorities",
|
||||
});
|
||||
|
||||
return priorities;
|
||||
const formattedPriorities =
|
||||
priorities?.map((priority: any) => ({
|
||||
value: priority.id,
|
||||
label: priority.name,
|
||||
})) ?? [];
|
||||
|
||||
return formattedPriorities;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export const getAgentsAction = async () => {
|
|||
const agents = users?.filter((user: any) => user.role_ids.includes(2)) ?? [];
|
||||
const formattedAgents = agents
|
||||
.map((agent: any) => ({
|
||||
label: agent.login,
|
||||
label: `${agent.firstname} ${agent.lastname}`,
|
||||
value: `gid://zammad/User/${agent.id}`,
|
||||
}))
|
||||
.sort((a: any, b: any) => a.label.localeCompare(b.label));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue