From 032137e004871c840e7be0e5dabc517b08f6604c Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Tue, 23 May 2023 20:44:31 +0100 Subject: [PATCH] Fix support messaging --- .gitignore | 4 + codegen-support.yml | 14 -- package.json | 13 +- src/App.tsx | 4 +- src/components/MessagingSidebar/index.tsx | 18 +-- src/graphql/chat.api.support.ts | 22 +-- src/graphql/types.support.ts | 110 +++++++------- src/index.tsx | 26 ++-- src/pages/Support/index.tsx | 71 ++++----- yarn.lock | 170 ++++++++++++++++------ 10 files changed, 259 insertions(+), 193 deletions(-) delete mode 100644 codegen-support.yml diff --git a/.gitignore b/.gitignore index eb14a76..4bbcda1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,10 @@ /.pnp .pnp.js +# development +codegen-main.yml +codegen-support.ts + # testing /coverage diff --git a/codegen-support.yml b/codegen-support.yml deleted file mode 100644 index 6343571..0000000 --- a/codegen-support.yml +++ /dev/null @@ -1,14 +0,0 @@ -overwrite: true -schema: 'https://astrobuild-support-service.herokuapp.com' -documents: 'src/graphql/*.api.support.ts' -config: - withHOC: false - scalars: - Date: Date - enumsAsTypes: true - withHooks: true -generates: - src/graphql/types.support.ts: - plugins: - - 'typescript' - - 'typescript-operations' diff --git a/package.json b/package.json index fef1f67..fa7f242 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@types/styled-components": "^5.1.26", "formik": "^2.2.9", "graphql": "^16.6.0", + "graphql-ws": "^5.13.1", "jwt-decode": "^3.1.2", "localforage": "^1.10.0", "match-sorter": "^6.3.1", @@ -27,7 +28,6 @@ "reactflow": "^11.7.0", "sort-by": "^1.2.0", "styled-components": "^5.3.10", - "subscriptions-transport-ws": "^0.9.19", "typescript": "^5.0.2", "vite-plugin-svgr": "^2.4.0", "web-vitals": "^3.3.0", @@ -36,10 +36,10 @@ "scripts": { "start": "vite", "build": "vite build", - "generate-main": "graphql-codegen --config codegen-main.yml", - "generate-support": "graphql-codegen --config codegen-support.yml", + "generate:main": "graphql-codegen --config codegen-main.yml", "lint": "yarn run eslint src --ext .ts,.tsx", - "fix": "yarn lint --fix" + "fix": "yarn lint --fix", + "generate:support": "graphql-codegen --config codegen-support.ts" }, "browserslist": { "production": [ @@ -54,8 +54,9 @@ ] }, "devDependencies": { - "@graphql-codegen/cli": "^3.2.2", - "@graphql-codegen/introspection": "^3.0.1", + "@graphql-codegen/cli": "3.3.1", + "@graphql-codegen/client-preset": "3.0.1", + "@graphql-codegen/introspection": "3.0.1", "@graphql-codegen/typescript": "^3.0.2", "@graphql-codegen/typescript-operations": "^3.0.2", "@typescript-eslint/eslint-plugin": "^5.56.0", diff --git a/src/App.tsx b/src/App.tsx index 0960dc2..67d42dd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -136,7 +136,7 @@ const App = () => { } /> @@ -144,7 +144,7 @@ const App = () => { } /> diff --git a/src/components/MessagingSidebar/index.tsx b/src/components/MessagingSidebar/index.tsx index 6b650ad..961ab19 100644 --- a/src/components/MessagingSidebar/index.tsx +++ b/src/components/MessagingSidebar/index.tsx @@ -7,7 +7,7 @@ import { Wrapper } from './styles'; import { GetProjectThreadsQuery, GetProjectThreadsQueryVariables, - ThreadObject, + Support, } from '../../graphql/types.support'; import { GET_PROJECT_THREADS } from '../../graphql/chat.api.support'; import { Add, Empty } from '../../assets'; @@ -21,7 +21,7 @@ const MessagingSidebar = ({ onClose }: MessagingSidebarProps) => { const role = useReactiveVar(roleVar); const location = useLocation(); const navigate = useNavigate(); - const [projectThreads, setProjectThreads] = useState>(); + const [projectThreads, setProjectThreads] = useState>(); useEffect(() => { (async () => { @@ -32,15 +32,13 @@ const MessagingSidebar = ({ onClose }: MessagingSidebarProps) => { >({ query: GET_PROJECT_THREADS, variables: { - projectId: location.pathname.split('/')[2]!, + projectId: location.pathname.split('/')[2] as string, }, fetchPolicy: 'network-only', }); - setProjectThreads(threads?.data?.getProjectThreads!); + setProjectThreads(threads?.data?.threads!); } })(); - - // eslint-disable-next-line }, [location.pathname]); return ( @@ -55,7 +53,7 @@ const MessagingSidebar = ({ onClose }: MessagingSidebarProps) => { > - Messaging Support + Support