Select overviews by name instead of index

This commit is contained in:
Darren Clarke 2023-10-23 13:27:42 +02:00
parent f13530f043
commit 7df947f35a
28 changed files with 1581 additions and 2809 deletions

View file

@ -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" });

View file

@ -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",

View file

@ -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";

View file

@ -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;

View file

@ -1,6 +1,6 @@
"use client";
import { DisplayError } from "../../../_components/DisplayError";
import { DisplayError } from "app/_components/DisplayError";
type PageProps = {
error: Error;

View file

@ -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();

View file

@ -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;

View file

@ -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>
)

View file

@ -1,6 +1,6 @@
"use client";
import { DisplayError } from "../../../_components/DisplayError";
import { DisplayError } from "app/_components/DisplayError";
type PageProps = {
error: Error;

View file

@ -15,29 +15,29 @@
"@emotion/react": "^11.11.1",
"@emotion/server": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@fontsource/playfair-display": "^5.0.15",
"@fontsource/playfair-display": "^5.0.17",
"@fontsource/poppins": "^5.0.8",
"@fontsource/roboto": "^5.0.8",
"@mui/icons-material": "^5",
"@mui/lab": "^5.0.0-alpha.148",
"@mui/lab": "^5.0.0-alpha.149",
"@mui/material": "^5",
"@mui/x-data-grid-pro": "^6.16.2",
"@mui/x-date-pickers-pro": "^6.16.2",
"@mui/x-data-grid-pro": "^6.16.3",
"@mui/x-date-pickers-pro": "^6.16.3",
"cryptr": "^6.3.0",
"date-fns": "^2.30.0",
"graphql-request": "^6.1.0",
"leafcutter-common": "*",
"material-ui-popup-state": "^5.0.9",
"mui-chips-input": "^2.1.3",
"next": "13.5.4",
"next-auth": "^4.23.2",
"next": "13.5.6",
"next-auth": "^4.24.3",
"ra-data-graphql": "^4.14.3",
"ra-i18n-polyglot": "^4.15.0",
"ra-input-rich-text": "^4.15.0",
"ra-language-english": "^4.15.0",
"ra-i18n-polyglot": "^4.15.1",
"ra-input-rich-text": "^4.15.1",
"ra-language-english": "^4.15.1",
"ra-postgraphile": "^6.1.2",
"react": "18.2.0",
"react-admin": "^4.15.0",
"react-admin": "^4.15.1",
"react-cookie": "^6.1.1",
"react-digit-input": "^2.1.0",
"react-dom": "18.2.0",
@ -47,20 +47,20 @@
"react-timer-hook": "^3.0.7",
"sharp": "^0.32.6",
"swr": "^2.2.4",
"tss-react": "^4.9.2",
"twilio-client": "^1.15.0"
"tss-react": "^4.9.3",
"twilio-client": "^1.15.1"
},
"devDependencies": {
"@babel/core": "^7.23.2",
"@types/node": "^20.8.6",
"@types/react": "18.2.28",
"@types/uuid": "^9.0.5",
"@types/node": "^20.8.7",
"@types/react": "18.2.31",
"@types/uuid": "^9.0.6",
"babel-loader": "^9.1.3",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-next": "^13.5.4",
"eslint-config-next": "^13.5.6",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2",