From dc71266bccfdc7dc140c7ede449526a2d25790d1 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 27 Jun 2023 17:16:08 +0300 Subject: [PATCH] fix(ProjectListItemConnected): add query state to goals counter --- package-lock.json | 50 ++-- package.json | 4 +- .../ProjectCreateForm/ProjectCreateForm.tsx | 11 +- .../ProjectListItemCollapsable.tsx | 6 +- src/components/ProjectListItemConnected.tsx | 16 +- src/components/ProjectPage/ProjectPage.tsx | 8 +- .../ProjectSettingsPage.tsx | 2 +- src/components/ProjectsPage/ProjectsPage.tsx | 9 +- src/hooks/useProjectResource.ts | 2 +- src/pages/explore/projects.tsx | 11 +- src/pages/projects/[id]/index.tsx | 5 +- src/pages/projects/[id]/settings.tsx | 2 +- src/pages/projects/index.tsx | 12 +- trpc/queries/project.ts | 84 ++++-- trpc/router/project.ts | 266 ++++++++++-------- 15 files changed, 294 insertions(+), 194 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc4a6cb6c..09816ba46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "@aws-sdk/client-s3": "3.347.1", "@hookform/resolvers": "3.1.1", "@next-auth/prisma-adapter": "1.0.6", - "@prisma/client": "4.14.1", "@sentry/nextjs": "7.50.0", "@tanstack/react-query": "4.29.5", "@tanstack/react-query-devtools": "4.29.5", @@ -57,6 +56,7 @@ "@commitlint/config-conventional": "17.6.1", "@faker-js/faker": "7.6.0", "@next/bundle-analyzer": "13.2.1", + "@prisma/client": "4.16.1", "@svgr/webpack": "7.0.0", "@types/cors": "2.8.13", "@types/jest": "29.5.1", @@ -90,7 +90,7 @@ "jest": "29.5.0", "lint-staged": "13.1.2", "prettier": "2.8.8", - "prisma": "4.15.0", + "prisma": "4.16.1", "ts-jest": "29.1.0", "ts-node": "10.9.1", "typescript": "5.1.3", @@ -5055,11 +5055,12 @@ } }, "node_modules/@prisma/client": { - "version": "4.14.1", + "version": "4.16.1", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-4.16.1.tgz", + "integrity": "sha512-CoDHu7Bt+NuDo40ijoeHP79EHtECsPBTy3yte5Yo3op8TqXt/kV0OT5OrsWewKvQGKFMHhYQ+ePed3zzjYdGAw==", "hasInstallScript": true, - "license": "Apache-2.0", "dependencies": { - "@prisma/engines-version": "4.14.0-67.d9a4c5988f480fa576d43970d5a23641aa77bc9c" + "@prisma/engines-version": "4.16.0-66.b20ead4d3ab9e78ac112966e242ded703f4a052c" }, "engines": { "node": ">=14.17" @@ -5074,14 +5075,16 @@ } }, "node_modules/@prisma/engines": { - "version": "4.15.0", + "version": "4.16.1", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-4.16.1.tgz", + "integrity": "sha512-gpZG0kGGxfemgvK/LghHdBIz+crHkZjzszja94xp4oytpsXrgt/Ice82MvPsWMleVIniKuARrowtsIsim0PFJQ==", "devOptional": true, - "hasInstallScript": true, - "license": "Apache-2.0" + "hasInstallScript": true }, "node_modules/@prisma/engines-version": { - "version": "4.14.0-67.d9a4c5988f480fa576d43970d5a23641aa77bc9c", - "license": "Apache-2.0" + "version": "4.16.0-66.b20ead4d3ab9e78ac112966e242ded703f4a052c", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-4.16.0-66.b20ead4d3ab9e78ac112966e242ded703f4a052c.tgz", + "integrity": "sha512-tMWAF/qF00fbUH1HB4Yjmz6bjh7fzkb7Y3NRoUfMlHu6V+O45MGvqwYxqwBjn1BIUXkl3r04W351D4qdJjrgvA==" }, "node_modules/@rollup/plugin-commonjs": { "version": "24.0.0", @@ -15728,12 +15731,13 @@ } }, "node_modules/prisma": { - "version": "4.15.0", + "version": "4.16.1", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-4.16.1.tgz", + "integrity": "sha512-C2Xm7yxHxjFjjscBEW4tmoraPHH/Vyu/A0XABdbaFtoiOZARsxvOM7rwc2iZ0qVxbh0bGBGBWZUSXO/52/nHBQ==", "devOptional": true, "hasInstallScript": true, - "license": "Apache-2.0", "dependencies": { - "@prisma/engines": "4.15.0" + "@prisma/engines": "4.16.1" }, "bin": { "prisma": "build/index.js", @@ -21991,17 +21995,23 @@ "version": "2.11.6" }, "@prisma/client": { - "version": "4.14.1", + "version": "4.16.1", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-4.16.1.tgz", + "integrity": "sha512-CoDHu7Bt+NuDo40ijoeHP79EHtECsPBTy3yte5Yo3op8TqXt/kV0OT5OrsWewKvQGKFMHhYQ+ePed3zzjYdGAw==", "requires": { - "@prisma/engines-version": "4.14.0-67.d9a4c5988f480fa576d43970d5a23641aa77bc9c" + "@prisma/engines-version": "4.16.0-66.b20ead4d3ab9e78ac112966e242ded703f4a052c" } }, "@prisma/engines": { - "version": "4.15.0", + "version": "4.16.1", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-4.16.1.tgz", + "integrity": "sha512-gpZG0kGGxfemgvK/LghHdBIz+crHkZjzszja94xp4oytpsXrgt/Ice82MvPsWMleVIniKuARrowtsIsim0PFJQ==", "devOptional": true }, "@prisma/engines-version": { - "version": "4.14.0-67.d9a4c5988f480fa576d43970d5a23641aa77bc9c" + "version": "4.16.0-66.b20ead4d3ab9e78ac112966e242ded703f4a052c", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-4.16.0-66.b20ead4d3ab9e78ac112966e242ded703f4a052c.tgz", + "integrity": "sha512-tMWAF/qF00fbUH1HB4Yjmz6bjh7fzkb7Y3NRoUfMlHu6V+O45MGvqwYxqwBjn1BIUXkl3r04W351D4qdJjrgvA==" }, "@rollup/plugin-commonjs": { "version": "24.0.0", @@ -28590,10 +28600,12 @@ } }, "prisma": { - "version": "4.15.0", + "version": "4.16.1", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-4.16.1.tgz", + "integrity": "sha512-C2Xm7yxHxjFjjscBEW4tmoraPHH/Vyu/A0XABdbaFtoiOZARsxvOM7rwc2iZ0qVxbh0bGBGBWZUSXO/52/nHBQ==", "devOptional": true, "requires": { - "@prisma/engines": "4.15.0" + "@prisma/engines": "4.16.1" } }, "process-nextick-args": { diff --git a/package.json b/package.json index efe1fccee..aa8916120 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "@aws-sdk/client-s3": "3.347.1", "@hookform/resolvers": "3.1.1", "@next-auth/prisma-adapter": "1.0.6", - "@prisma/client": "4.14.1", "@sentry/nextjs": "7.50.0", "@tanstack/react-query": "4.29.5", "@tanstack/react-query-devtools": "4.29.5", @@ -72,6 +71,7 @@ "@commitlint/config-conventional": "17.6.1", "@faker-js/faker": "7.6.0", "@next/bundle-analyzer": "13.2.1", + "@prisma/client": "4.16.1", "@svgr/webpack": "7.0.0", "@types/cors": "2.8.13", "@types/jest": "29.5.1", @@ -105,7 +105,7 @@ "jest": "29.5.0", "lint-staged": "13.1.2", "prettier": "2.8.8", - "prisma": "4.15.0", + "prisma": "4.16.1", "ts-jest": "29.1.0", "ts-node": "10.9.1", "typescript": "5.1.3", diff --git a/src/components/ProjectCreateForm/ProjectCreateForm.tsx b/src/components/ProjectCreateForm/ProjectCreateForm.tsx index 461f9935e..418f022eb 100644 --- a/src/components/ProjectCreateForm/ProjectCreateForm.tsx +++ b/src/components/ProjectCreateForm/ProjectCreateForm.tsx @@ -101,9 +101,14 @@ const ProjectCreateForm: React.FC = () => { const isKeyEnoughLength = Boolean(keyWatcher?.length >= 3); const flowRecomendations = trpc.flow.recommedations.useQuery(); - const existingProject = trpc.project.getById.useQuery(keyWatcher, { - enabled: isKeyEnoughLength, - }); + const existingProject = trpc.project.getById.useQuery( + { + id: keyWatcher, + }, + { + enabled: isKeyEnoughLength, + }, + ); const isKeyUnique = Boolean(!existingProject?.data); diff --git a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.tsx b/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.tsx index 0ceff5abe..f8d10c855 100644 --- a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.tsx +++ b/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.tsx @@ -23,7 +23,6 @@ interface ProjectListItemCollapsableProps { collapsedGoals: boolean; onClick?: () => void; onGoalsClick?: () => void; - goalsCounter?: number; loading?: boolean; deep?: number; } @@ -37,7 +36,6 @@ export const ProjectListItemCollapsable: React.FC { const contentHidden = collapsed || loading; @@ -70,12 +68,12 @@ export const ProjectListItemCollapsable: React.FC - {goalsCounter ? ( + {project._count.goals ? (