Select overviews by name instead of index
This commit is contained in:
parent
f13530f043
commit
7df947f35a
28 changed files with 1581 additions and 2809 deletions
|
|
@ -175,16 +175,23 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
|
|||
},
|
||||
{ refreshInterval: 10000 },
|
||||
);
|
||||
console.log({ overviewData });
|
||||
const findOverviewCountByID = (id: number) =>
|
||||
overviewData?.ticketOverviews?.edges?.find((overview: any) =>
|
||||
overview.node.id.endsWith(`/${id}`),
|
||||
const findOverviewByName = (name: string) =>
|
||||
overviewData?.ticketOverviews?.edges?.find(
|
||||
(overview: any) => overview.node.name === name,
|
||||
)?.node?.id;
|
||||
const findOverviewCountByID = (id: string) =>
|
||||
overviewData?.ticketOverviews?.edges?.find(
|
||||
(overview: any) => overview.node.id === id,
|
||||
)?.node?.ticketCount ?? 0;
|
||||
const recentCount = 0;
|
||||
const assignedCount = findOverviewCountByID(1);
|
||||
const openCount = findOverviewCountByID(5);
|
||||
const urgentCount = findOverviewCountByID(7);
|
||||
const unassignedCount = findOverviewCountByID(2);
|
||||
const assignedID = findOverviewByName("My Assigned Tickets");
|
||||
const assignedCount = findOverviewCountByID(assignedID);
|
||||
const openID = findOverviewByName("Open Tickets");
|
||||
const openCount = findOverviewCountByID(openID);
|
||||
const urgentID = findOverviewByName("Escalated Tickets");
|
||||
const urgentCount = findOverviewCountByID(urgentID);
|
||||
const unassignedID = findOverviewByName("Unassigned & Open Tickets");
|
||||
const unassignedCount = findOverviewCountByID(unassignedID);
|
||||
|
||||
const logout = () => {
|
||||
signOut({ callbackUrl: "/login" });
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Metadata } from "next";
|
||||
import { ZammadWrapper } from "../../../(main)/_components/ZammadWrapper";
|
||||
import { ZammadWrapper } from "app/(main)/_components/ZammadWrapper";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Zammad",
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
import { FC, useState } from "react";
|
||||
import { Grid, Box } from "@mui/material";
|
||||
import { GridColDef } from "@mui/x-data-grid-pro";
|
||||
import { StyledDataGrid } from "../../../_components/StyledDataGrid";
|
||||
import { Button } from "../../../../_components/Button";
|
||||
import { typography } from "../../../../_styles/theme";
|
||||
import { StyledDataGrid } from "app/(main)/_components/StyledDataGrid";
|
||||
import { Button } from "app/_components/Button";
|
||||
import { typography } from "app/_styles/theme";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { TicketCreateDialog } from "./TicketCreateDialog";
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { FC, useEffect, useState } from "react";
|
||||
import useSWR from "swr";
|
||||
import { TicketList } from "./TicketList";
|
||||
import { getTicketsByOverviewQuery } from "../../../../_graphql/getTicketsByOverviewQuery";
|
||||
import { getTicketsByOverviewQuery } from "app/_graphql/getTicketsByOverviewQuery";
|
||||
|
||||
type ZammadOverviewProps = {
|
||||
name: string;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import { DisplayError } from "../../../_components/DisplayError";
|
||||
import { DisplayError } from "app/_components/DisplayError";
|
||||
|
||||
type PageProps = {
|
||||
error: Error;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { FC, useLayoutEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { CircularProgress, Box, Grid } from "@mui/material";
|
||||
import { ZammadWrapper } from "../../../(main)/_components/ZammadWrapper";
|
||||
import { ZammadWrapper } from "app/(main)/_components/ZammadWrapper";
|
||||
|
||||
export const Setup: FC = () => {
|
||||
const router = useRouter();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
TextField,
|
||||
} from "@mui/material";
|
||||
import { useSWRConfig } from "swr";
|
||||
import { updateTicketMutation } from "../../../../../_graphql/updateTicketMutation";
|
||||
import { updateTicketMutation } from "app/_graphql/updateTicketMutation";
|
||||
|
||||
interface ArticleCreateDialogProps {
|
||||
ticketID: string;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
import { FC, useState } from "react";
|
||||
import useSWR from "swr";
|
||||
import { getTicketQuery } from "../../../../../_graphql/getTicketQuery";
|
||||
import { getTicketArticlesQuery } from "../../../../../_graphql/getTicketArticlesQuery";
|
||||
import { getTicketQuery } from "app/_graphql/getTicketQuery";
|
||||
import { getTicketArticlesQuery } from "app/_graphql/getTicketArticlesQuery";
|
||||
import {
|
||||
Grid,
|
||||
Box,
|
||||
|
|
@ -51,12 +51,14 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
|
|||
const mostRecentExternalArticle = externalArticles?.length
|
||||
? externalArticles[externalArticles.length - 1].node
|
||||
: null;
|
||||
console.log({ mostRecentExternalArticle });
|
||||
const mostRecentExternalArticleKind =
|
||||
mostRecentExternalArticle?.type?.name ?? "phone";
|
||||
const mostRecentEmailRecipient = mostRecentExternalArticle?.to?.name ?? "";
|
||||
console.log({ mostRecentExternalArticleKind, mostRecentEmailRecipient });
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const [articleKind, setArticleKind] = useState("phone");
|
||||
const [recipient, setRecipient] = useState("");
|
||||
const [recipient, setRecipient] = useState(mostRecentEmailRecipient);
|
||||
const closeDialog = () => setDialogOpen(false);
|
||||
|
||||
const shouldRender =
|
||||
|
|
@ -189,6 +191,7 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
|
|||
open={dialogOpen}
|
||||
closeDialog={closeDialog}
|
||||
kind={articleKind}
|
||||
recipient={recipient}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import { DisplayError } from "../../../_components/DisplayError";
|
||||
import { DisplayError } from "app/_components/DisplayError";
|
||||
|
||||
type PageProps = {
|
||||
error: Error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue