Fix email replies, update dependencies

This commit is contained in:
Darren Clarke 2023-11-22 11:11:28 +01:00
parent 8d86db882d
commit 7688730e4f
21 changed files with 539 additions and 567 deletions

View file

@ -21,7 +21,7 @@
"@fontsource/poppins": "^5.0.8", "@fontsource/poppins": "^5.0.8",
"@fontsource/roboto": "^5.0.8", "@fontsource/roboto": "^5.0.8",
"@mui/icons-material": "^5", "@mui/icons-material": "^5",
"@mui/lab": "^5.0.0-alpha.152", "@mui/lab": "^5.0.0-alpha.153",
"@mui/material": "^5", "@mui/material": "^5",
"@mui/x-data-grid-pro": "^6.18.1", "@mui/x-data-grid-pro": "^6.18.1",
"@mui/x-date-pickers-pro": "^6.18.1", "@mui/x-date-pickers-pro": "^6.18.1",
@ -31,8 +31,8 @@
"http-proxy-middleware": "^2.0.6", "http-proxy-middleware": "^2.0.6",
"leafcutter-common": "*", "leafcutter-common": "*",
"material-ui-popup-state": "^5.0.10", "material-ui-popup-state": "^5.0.10",
"next": "14.0.2", "next": "14.0.3",
"next-auth": "^4.24.4", "next-auth": "^4.24.5",
"next-http-proxy-middleware": "^1.2.6", "next-http-proxy-middleware": "^1.2.6",
"nodemailer": "^6.9.7", "nodemailer": "^6.9.7",
"react": "18.2.0", "react": "18.2.0",
@ -40,7 +40,7 @@
"react-cookie-consent": "^9.0.0", "react-cookie-consent": "^9.0.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-iframe": "^1.8.5", "react-iframe": "^1.8.5",
"react-markdown": "^9.0.0", "react-markdown": "^9.0.1",
"react-polyglot": "^0.7.2", "react-polyglot": "^0.7.2",
"sharp": "^0.32.6", "sharp": "^0.32.6",
"swr": "^2.2.4", "swr": "^2.2.4",
@ -49,18 +49,18 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.23.3", "@babel/core": "^7.23.3",
"@types/node": "^20.9.0", "@types/node": "^20.9.4",
"@types/react": "18.2.37", "@types/react": "18.2.38",
"@types/uuid": "^9.0.7", "@types/uuid": "^9.0.7",
"babel-loader": "^9.1.3", "babel-loader": "^9.1.3",
"eslint": "^8.53.0", "eslint": "^8.54.0",
"eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb": "^19.0.4",
"eslint-config-next": "^14.0.2", "eslint-config-next": "^14.0.3",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0", "eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.8.0", "eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.0.1", "eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2", "eslint-plugin-react": "^7.33.2",
"typescript": "5.2.2" "typescript": "5.3.2"
} }
} }

View file

@ -1,6 +1,6 @@
"use client"; "use client";
import { FC, useState } from "react"; import { FC, useEffect, useState } from "react";
import useSWR from "swr"; import useSWR from "swr";
import { getTicketQuery } from "app/_graphql/getTicketQuery"; import { getTicketQuery } from "app/_graphql/getTicketQuery";
import { getTicketArticlesQuery } from "app/_graphql/getTicketArticlesQuery"; import { getTicketArticlesQuery } from "app/_graphql/getTicketArticlesQuery";
@ -28,6 +28,8 @@ interface TicketDetailProps {
} }
export const TicketDetail: FC<TicketDetailProps> = ({ id }) => { export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
const [dialogOpen, setDialogOpen] = useState(false);
const [articleKind, setArticleKind] = useState("note");
const { data: ticketData, error: ticketError }: any = useSWR( const { data: ticketData, error: ticketError }: any = useSWR(
{ {
document: getTicketQuery, document: getTicketQuery,
@ -49,26 +51,15 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
body: JSON.stringify({ object: "Ticket", o_id: id }), body: JSON.stringify({ object: "Ticket", o_id: id }),
}); });
const closeDialog = () => setDialogOpen(false);
console.log({ recentViewData, recentViewError }); console.log({ recentViewData, recentViewError });
const ticket = ticketData?.ticket; const ticket = ticketData?.ticket;
const ticketArticles = ticketArticlesData?.ticketArticles; const ticketArticles = ticketArticlesData?.ticketArticles;
const externalArticles = ticketArticles?.edges.filter( const firstArticle = ticketArticles?.edges[0]?.node;
({ node: article }: any) => !article.internal, const firstArticleKind = firstArticle?.type?.name ?? "phone";
); const firstEmailSender = firstArticle?.from?.parsed?.[0]?.emailAddress ?? "";
const mostRecentExternalArticle = externalArticles?.length const recipient = firstEmailSender;
? 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(mostRecentEmailRecipient);
const closeDialog = () => setDialogOpen(false);
const shouldRender = const shouldRender =
ticketData && !ticketError && ticketArticlesData && !ticketArticlesError; ticketData && !ticketError && ticketArticlesData && !ticketArticlesError;
@ -113,7 +104,7 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
: "incoming-message" : "incoming-message"
} }
model={{ model={{
message: article.body.replace(/<div>*<br>*<div>/g, ""), message: article.bodyWithUrls,
sentTime: article.updated_at, sentTime: article.updated_at,
sender: article.from, sender: article.from,
direction: direction:
@ -159,7 +150,7 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
mt: 2, mt: 2,
}} }}
onClick={() => { onClick={() => {
setArticleKind(mostRecentExternalArticleKind); setArticleKind(firstArticleKind);
setDialogOpen(true); setDialogOpen(true);
}} }}
> >

View file

@ -6,7 +6,7 @@ query getTicketArticles($ticketId: ID!) {
edges { edges {
node { node {
id id
body bodyWithUrls
internal internal
type { type {
name name
@ -14,6 +14,11 @@ query getTicketArticles($ticketId: ID!) {
sender { sender {
name name
} }
from {
parsed {
emailAddress
}
}
} }
} }
} }

View file

@ -93,7 +93,6 @@ const handler = NextAuth({
callbacks: { callbacks: {
signIn: async ({ user, account, profile }) => { signIn: async ({ user, account, profile }) => {
console.log("SIGN IN");
const roles = await getUserRoles(user.email) ?? []; const roles = await getUserRoles(user.email) ?? [];
return roles.includes("admin") || roles.includes("agent") || process.env.SETUP_MODE === "true"; return roles.includes("admin") || roles.includes("agent") || process.env.SETUP_MODE === "true";
}, },

View file

@ -19,7 +19,7 @@
"@fontsource/poppins": "^5.0.8", "@fontsource/poppins": "^5.0.8",
"@fontsource/roboto": "^5.0.8", "@fontsource/roboto": "^5.0.8",
"@mui/icons-material": "^5", "@mui/icons-material": "^5",
"@mui/lab": "^5.0.0-alpha.152", "@mui/lab": "^5.0.0-alpha.153",
"@mui/material": "^5", "@mui/material": "^5",
"@mui/x-data-grid-pro": "^6.18.1", "@mui/x-data-grid-pro": "^6.18.1",
"@mui/x-date-pickers-pro": "^6.18.1", "@mui/x-date-pickers-pro": "^6.18.1",
@ -29,15 +29,15 @@
"leafcutter-common": "*", "leafcutter-common": "*",
"material-ui-popup-state": "^5.0.10", "material-ui-popup-state": "^5.0.10",
"mui-chips-input": "^2.1.3", "mui-chips-input": "^2.1.3",
"next": "14.0.2", "next": "14.0.3",
"next-auth": "^4.24.4", "next-auth": "^4.24.5",
"ra-data-graphql": "^4.14.3", "ra-data-graphql": "^4.16.0",
"ra-i18n-polyglot": "^4.15.2", "ra-i18n-polyglot": "^4.16.0",
"ra-input-rich-text": "^4.15.3", "ra-input-rich-text": "^4.16.0",
"ra-language-english": "^4.15.2", "ra-language-english": "^4.16.0",
"ra-postgraphile": "^6.1.2", "ra-postgraphile": "^6.1.2",
"react": "18.2.0", "react": "18.2.0",
"react-admin": "^4.15.3", "react-admin": "^4.16.0",
"react-cookie": "^6.1.1", "react-cookie": "^6.1.1",
"react-digit-input": "^2.1.0", "react-digit-input": "^2.1.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
@ -52,18 +52,18 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.23.3", "@babel/core": "^7.23.3",
"@types/node": "^20.9.0", "@types/node": "^20.9.4",
"@types/react": "18.2.37", "@types/react": "18.2.38",
"@types/uuid": "^9.0.7", "@types/uuid": "^9.0.7",
"babel-loader": "^9.1.3", "babel-loader": "^9.1.3",
"eslint": "^8.53.0", "eslint": "^8.54.0",
"eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb": "^19.0.4",
"eslint-config-next": "^14.0.2", "eslint-config-next": "^14.0.3",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0", "eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.8.0", "eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.0.1", "eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2", "eslint-plugin-react": "^7.33.2",
"typescript": "5.2.2" "typescript": "5.3.2"
} }
} }

View file

@ -59,7 +59,7 @@
"tsc-watch": "^6.0.4", "tsc-watch": "^6.0.4",
"tsconfig-link": "*", "tsconfig-link": "*",
"typedoc": "^0.25.3", "typedoc": "^0.25.3",
"typescript": "^5.2.2" "typescript": "^5.3.2"
}, },
"nodemonConfig": { "nodemonConfig": {
"ignore": [ "ignore": [

View file

@ -23,14 +23,14 @@
"graphql": "15.8.0" "graphql": "15.8.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.8", "@types/jest": "^29.5.10",
"pino-pretty": "^10.2.3", "pino-pretty": "^10.2.3",
"nodemon": "^3.0.1", "nodemon": "^3.0.1",
"tsconfig-link": "*", "tsconfig-link": "*",
"eslint-config-link": "*", "eslint-config-link": "*",
"jest-config-link": "*", "jest-config-link": "*",
"babel-preset-link": "*", "babel-preset-link": "*",
"typescript": "^5.2.2" "typescript": "^5.3.2"
}, },
"scripts": { "scripts": {
"migrate": "NODE_ENV=development node --unhandled-rejections=strict build/main/index.js db -- migrate", "migrate": "NODE_ENV=development node --unhandled-rejections=strict build/main/index.js db -- migrate",

View file

@ -22,17 +22,17 @@
"@babel/preset-env": "7.23.3", "@babel/preset-env": "7.23.3",
"@babel/preset-typescript": "7.23.3", "@babel/preset-typescript": "7.23.3",
"@types/fluent-ffmpeg": "^2.1.24", "@types/fluent-ffmpeg": "^2.1.24",
"@types/jest": "^29.5.8", "@types/jest": "^29.5.10",
"eslint": "^8.53.0", "eslint": "^8.54.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-circus": "^29.7.0", "jest-circus": "^29.7.0",
"jest-junit": "^16.0.0", "jest-junit": "^16.0.0",
"nodemon": "^3.0.1", "nodemon": "^3.0.1",
"pino-pretty": "^10.2.3", "pino-pretty": "^10.2.3",
"prettier": "^3.0.3", "prettier": "^3.1.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typedoc": "^0.25.3", "typedoc": "^0.25.3",
"typescript": "^5.2.2" "typescript": "^5.3.2"
}, },
"nodemonConfig": { "nodemonConfig": {
"ignore": [ "ignore": [

938
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -54,11 +54,12 @@
"typeorm": { "typeorm": {
"pg": "^8.11.0" "pg": "^8.11.0"
}, },
"graphql": "15.8.0" "graphql": "15.8.0",
"typescript": "^5.2.0"
}, },
"devDependencies": { "devDependencies": {
"dotenv-cli": "latest", "dotenv-cli": "latest",
"prettier": "^3.0.3" "prettier": "^3.1.0"
}, },
"engines": { "engines": {
"npm": ">=9.6.7", "npm": ">=9.6.7",

View file

@ -15,6 +15,6 @@
}, },
"peerDependencies": {}, "peerDependencies": {},
"devDependencies": { "devDependencies": {
"eslint": "^8.53.0" "eslint": "^8.54.0"
} }
} }

View file

@ -9,9 +9,9 @@
"fmt": "prettier \"profile/**/*.js\" --write" "fmt": "prettier \"profile/**/*.js\" --write"
}, },
"dependencies": { "dependencies": {
"@rushstack/eslint-patch": "^1.5.1", "@rushstack/eslint-patch": "^1.6.0",
"@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.10.0", "@typescript-eslint/parser": "^6.12.0",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",
"eslint-config-xo-space": "^0.34.0", "eslint-config-xo-space": "^0.34.0",
"eslint-plugin-cypress": "^2.15.1", "eslint-plugin-cypress": "^2.15.1",
@ -28,8 +28,8 @@
"typescript": "^4.9.5" "typescript": "^4.9.5"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^8.53.0", "eslint": "^8.54.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"typescript": "^5.2.2" "typescript": "^5.3.2"
} }
} }

View file

@ -9,7 +9,7 @@
"private": false, "private": false,
"devDependencies": { "devDependencies": {
"@hapi/basic": "^7.0.2", "@hapi/basic": "^7.0.2",
"@types/jest": "^29.5.8", "@types/jest": "^29.5.10",
"babel-preset-link": "*", "babel-preset-link": "*",
"eslint-config-link": "*", "eslint-config-link": "*",
"jest-config-link": "*", "jest-config-link": "*",
@ -20,7 +20,7 @@
"@hapi/hapi": "^21.3.2", "@hapi/hapi": "^21.3.2",
"@hapi/hoek": "^11.0.2", "@hapi/hoek": "^11.0.2",
"joi": "^17.11.0", "joi": "^17.11.0",
"next-auth": "4.24.4" "next-auth": "4.24.5"
}, },
"scripts": { "scripts": {
"build": "tsc -p tsconfig.json", "build": "tsc -p tsconfig.json",

View file

@ -8,7 +8,7 @@
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"private": false, "private": false,
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.8", "@types/jest": "^29.5.10",
"tsc-watch": "^6.0.4" "tsc-watch": "^6.0.4"
}, },
"dependencies": { "dependencies": {

View file

@ -9,7 +9,7 @@
"node": ">=14" "node": ">=14"
}, },
"dependencies": { "dependencies": {
"@types/jest": "^29.5.8", "@types/jest": "^29.5.10",
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-junit": "^16.0.0" "jest-junit": "^16.0.0"
}, },

View file

@ -13,7 +13,7 @@
"@fontsource/poppins": "^5.0.8", "@fontsource/poppins": "^5.0.8",
"@fontsource/roboto": "^5.0.8", "@fontsource/roboto": "^5.0.8",
"@mui/icons-material": "^5", "@mui/icons-material": "^5",
"@mui/lab": "^5.0.0-alpha.152", "@mui/lab": "^5.0.0-alpha.153",
"@mui/material": "^5", "@mui/material": "^5",
"@mui/x-data-grid-pro": "^6.18.1", "@mui/x-data-grid-pro": "^6.18.1",
"@mui/x-date-pickers-pro": "^6.18.1", "@mui/x-date-pickers-pro": "^6.18.1",
@ -21,8 +21,8 @@
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
"http-proxy-middleware": "^2.0.6", "http-proxy-middleware": "^2.0.6",
"material-ui-popup-state": "^5.0.10", "material-ui-popup-state": "^5.0.10",
"next": "14.0.2", "next": "14.0.3",
"next-auth": "^4.24.4", "next-auth": "^4.24.5",
"next-http-proxy-middleware": "^1.2.6", "next-http-proxy-middleware": "^1.2.6",
"nodemailer": "^6.9.7", "nodemailer": "^6.9.7",
"react": "18.2.0", "react": "18.2.0",
@ -30,7 +30,7 @@
"react-cookie-consent": "^9.0.0", "react-cookie-consent": "^9.0.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-iframe": "^1.8.5", "react-iframe": "^1.8.5",
"react-markdown": "^9.0.0", "react-markdown": "^9.0.1",
"react-polyglot": "^0.7.2", "react-polyglot": "^0.7.2",
"sharp": "^0.32.6", "sharp": "^0.32.6",
"swr": "^2.2.4", "swr": "^2.2.4",
@ -39,19 +39,19 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.23.3", "@babel/core": "^7.23.3",
"@types/node": "^20.9.0", "@types/node": "^20.9.4",
"@types/react": "18.2.37", "@types/react": "18.2.38",
"@types/uuid": "^9.0.7", "@types/uuid": "^9.0.7",
"babel-loader": "^9.1.3", "babel-loader": "^9.1.3",
"eslint": "^8.53.0", "eslint": "^8.54.0",
"eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb": "^19.0.4",
"eslint-config-next": "^14.0.2", "eslint-config-next": "^14.0.3",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0", "eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.8.0", "eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.0.1", "eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2", "eslint-plugin-react": "^7.33.2",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"typescript": "5.2.2" "typescript": "5.3.2"
} }
} }

File diff suppressed because one or more lines are too long

View file

@ -18,14 +18,14 @@
}, },
"devDependencies": { "devDependencies": {
"@types/figlet": "^1.5.8", "@types/figlet": "^1.5.8",
"@types/lodash": "^4.14.201", "@types/lodash": "^4.14.202",
"@types/node": "*", "@types/node": "*",
"@types/uuid": "^9.0.7", "@types/uuid": "^9.0.7",
"camelcase-keys": "^9.1.2", "camelcase-keys": "^9.1.2",
"pg-monitor": "^2.0.0", "pg-monitor": "^2.0.0",
"tsc-watch": "^6.0.4", "tsc-watch": "^6.0.4",
"typedoc": "^0.25.3", "typedoc": "^0.25.3",
"typescript": "^5.2.2" "typescript": "^5.3.2"
}, },
"dependencies": { "dependencies": {
"@digiresilience/hapi-nextauth": "*", "@digiresilience/hapi-nextauth": "*",
@ -54,9 +54,9 @@
"http-terminator": "^3.2.0", "http-terminator": "^3.2.0",
"joi": "^17.11.0", "joi": "^17.11.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"next-auth": "^4.24.4", "next-auth": "^4.24.5",
"pg-promise": "^11.5.4", "pg-promise": "^11.5.4",
"pino": "^8.16.1", "pino": "^8.16.2",
"pino-pretty": "^10.2.3", "pino-pretty": "^10.2.3",
"prom-client": "^15.x.x", "prom-client": "^15.x.x",
"uuid": "^9.0.1" "uuid": "^9.0.1"

View file

@ -13,13 +13,13 @@
"@babel/core": "7.23.3", "@babel/core": "7.23.3",
"@babel/preset-env": "7.23.3", "@babel/preset-env": "7.23.3",
"@babel/preset-typescript": "7.23.3", "@babel/preset-typescript": "7.23.3",
"eslint": "^8.53.0", "eslint": "^8.54.0",
"pino-pretty": "^10.2.3", "pino-pretty": "^10.2.3",
"prettier": "^3.0.3", "prettier": "^3.1.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-watch": "^6.0.4", "tsc-watch": "^6.0.4",
"typedoc": "^0.25.3", "typedoc": "^0.25.3",
"typescript": "^5.2.2" "typescript": "^5.3.2"
}, },
"files": [ "files": [
"build", "build",

View file

@ -20,16 +20,16 @@
"@babel/core": "7.23.3", "@babel/core": "7.23.3",
"@babel/preset-env": "7.23.3", "@babel/preset-env": "7.23.3",
"@babel/preset-typescript": "7.23.3", "@babel/preset-typescript": "7.23.3",
"@types/jest": "^29.5.8", "@types/jest": "^29.5.10",
"eslint": "^8.53.0", "eslint": "^8.54.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-junit": "^16.0.0", "jest-junit": "^16.0.0",
"pino-pretty": "^10.2.3", "pino-pretty": "^10.2.3",
"prettier": "^3.0.3", "prettier": "^3.1.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"tsc-watch": "^6.0.4", "tsc-watch": "^6.0.4",
"typedoc": "^0.25.3", "typedoc": "^0.25.3",
"typescript": "^5.2.2" "typescript": "^5.3.2"
}, },
"scripts": { "scripts": {
"build": "tsc -p tsconfig.json", "build": "tsc -p tsconfig.json",

View file

@ -23,7 +23,7 @@
"node": ">=14" "node": ">=14"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.8", "@types/jest": "^29.5.10",
"babel-preset-link": "*", "babel-preset-link": "*",
"eslint-config-link": "*", "eslint-config-link": "*",
"jest-config-link": "*", "jest-config-link": "*",