From 3e306ee0dc9e14f1515aac23ac5d8e18ff32ad6c Mon Sep 17 00:00:00 2001 From: Hansel Lee Date: Tue, 23 Apr 2024 17:06:39 -0700 Subject: [PATCH 01/18] Add TS compile check for PRs --- .github/workflows/check_ts.yml | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/check_ts.yml diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml new file mode 100644 index 0000000..9916d66 --- /dev/null +++ b/.github/workflows/check_ts.yml @@ -0,0 +1,35 @@ +name: 'check-ts' +on: + pull_request: +jobs: + ts: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Get diff lines + id: diff + uses: Equip-Collaboration/diff-line-numbers@v1.0.0 + with: + include: '["\\.ts$"]' + - name: Detecting files changed + id: files + uses: umani/changed-files@v4.0.0 + with: + repo-token: ${{ github.token }} + pattern: '^.*\.ts$' + - name: List files changed + run: | + echo 'Files modified: ${{steps.files.outputs.files_updated}}' + echo 'Files added: ${{steps.files.outputs.files_created}}' + echo 'Files removed: ${{steps.files.outputs.files_deleted}}' + - uses: Arhia/action-check-typescript@v1.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + use-check: true + check-fail-mode: added + files-changed: ${{steps.files.outputs.files_updated}} + files-added: ${{steps.files.outputs.files_created}} + files-deleted: ${{steps.files.outputs.files_deleted}} + line-numbers: ${{steps.diff.outputs.lineNumbers}} + output-behaviour: both + comment-behaviour: new \ No newline at end of file From c1ed3a3fbc22a7a817c4ea33f4ed6a93693e5fa4 Mon Sep 17 00:00:00 2001 From: Hansel Lee Date: Tue, 30 Apr 2024 15:41:24 -0700 Subject: [PATCH 02/18] Set up TS compile check --- .github/workflows/check_ts.yml | 23 +++++++++++++++++------ client/tsconfig.json | 2 -- package-lock.json | 15 +++++++++++++++ package.json | 3 +++ 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index 9916d66..e57014f 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -1,35 +1,46 @@ name: 'check-ts' +# run this check on PRs on: pull_request: jobs: ts: runs-on: ubuntu-latest steps: + # checkout the code - uses: actions/checkout@v3 + + # get the lines modified in this PR - name: Get diff lines id: diff uses: Equip-Collaboration/diff-line-numbers@v1.0.0 with: - include: '["\\.ts$"]' + include: '["\\.tsx?$"]' + + # get the files modified in this PR - name: Detecting files changed id: files uses: umani/changed-files@v4.0.0 with: repo-token: ${{ github.token }} - pattern: '^.*\.ts$' + pattern: '^.*\.tsx?$' + + # echo the changed files - name: List files changed run: | echo 'Files modified: ${{steps.files.outputs.files_updated}}' echo 'Files added: ${{steps.files.outputs.files_created}}' echo 'Files removed: ${{steps.files.outputs.files_deleted}}' + + # run the action - uses: Arhia/action-check-typescript@v1.0.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - use-check: true - check-fail-mode: added + use-check: true # if the action fails, the PR wil fail + check-fail-mode: added # only check for added errors files-changed: ${{steps.files.outputs.files_updated}} files-added: ${{steps.files.outputs.files_created}} files-deleted: ${{steps.files.outputs.files_deleted}} line-numbers: ${{steps.diff.outputs.lineNumbers}} - output-behaviour: both - comment-behaviour: new \ No newline at end of file + output-behaviour: both # use github annotations and comments on the PR + comment-behaviour: new # every run of this action will create a new comment + ts-config-path: './client/tsconfig.json' # use the tsconfig.json in the client directory \ No newline at end of file diff --git a/client/tsconfig.json b/client/tsconfig.json index a7fc6fb..f50b75c 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -6,7 +6,6 @@ "module": "ESNext", "skipLibCheck": true, - /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "resolveJsonModule": true, @@ -14,7 +13,6 @@ "noEmit": true, "jsx": "react-jsx", - /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, diff --git a/package-lock.json b/package-lock.json index 4c6167b..04fd1c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,9 @@ "name": "societas", "version": "1.0.0", "license": "ISC", + "dependencies": { + "typescript": "^5.4.5" + }, "devDependencies": { "prettier": "3.2.5" } @@ -26,6 +29,18 @@ "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" } + }, + "node_modules/typescript": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } } } } diff --git a/package.json b/package.json index 6081b64..8b411e4 100644 --- a/package.json +++ b/package.json @@ -10,5 +10,8 @@ "license": "ISC", "devDependencies": { "prettier": "3.2.5" + }, + "dependencies": { + "typescript": "^5.4.5" } } From fd9df2301e09fa8fb3a1181dd0514c1214ef98f6 Mon Sep 17 00:00:00 2001 From: Arjun Naik Date: Tue, 30 Apr 2024 18:44:29 -0700 Subject: [PATCH 03/18] added a cd to check_ts.yml --- .github/workflows/check_ts.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index e57014f..f06ebef 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -9,6 +9,9 @@ jobs: # checkout the code - uses: actions/checkout@v3 + - name: Install + run: cd ./client + # get the lines modified in this PR - name: Get diff lines id: diff @@ -43,4 +46,4 @@ jobs: line-numbers: ${{steps.diff.outputs.lineNumbers}} output-behaviour: both # use github annotations and comments on the PR comment-behaviour: new # every run of this action will create a new comment - ts-config-path: './client/tsconfig.json' # use the tsconfig.json in the client directory \ No newline at end of file + ts-config-path: './client/tsconfig.json' # use the tsconfig.json in the client directory From cb2f398f76faa6bb28388e694551d17637008931 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Wed, 1 May 2024 15:14:05 -0700 Subject: [PATCH 04/18] build errors --- client/src/components/Spinner.tsx | 42 ---------------------------- client/src/pages/CreateProj.tsx | 30 +------------------- client/src/pages/Home.tsx | 2 +- client/src/pages/Project.tsx | 3 +- client/src/pages/Search.tsx | 7 +---- server/src/routers/postsRouter.ts | 2 -- server/src/routers/projectsRouter.ts | 30 ++++++++++++++++++-- 7 files changed, 32 insertions(+), 84 deletions(-) diff --git a/client/src/components/Spinner.tsx b/client/src/components/Spinner.tsx index b02fa12..fc68b4d 100644 --- a/client/src/components/Spinner.tsx +++ b/client/src/components/Spinner.tsx @@ -1,6 +1,3 @@ -// import styled from "styled-components" -// import PropTypes from "prop-types" - //Buffering animation - the circle that spins when things are loading export default function Spinner({ size }: { size?: number}) { return ( @@ -27,42 +24,3 @@ export default function Spinner({ size }: { size?: number}) { ); } - -// const StyledSpinner = styled.div` -// width: ${({ size }) => size}; -// height: ${({ size }) => size}; -// display: flex; -// /* position: relative; */ -// transform: scale(0.5); -// transform-origin: center; -// pointer-events: ${({ loading }) => (loading ? "none" : "all")}; - -// & div { -// box-sizing: border-box; -// display: block; -// position: absolute; -// width: ${({ size }) => size}; -// height: ${({ size }) => size}; -// border: 8px solid ${({ color }) => color}; -// border-radius: 50%; -// animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite; -// border-color: ${({ color }) => color} transparent transparent transparent; -// } -// & div:nth-child(1) { -// animation-delay: -0.45s; -// } -// & div:nth-child(2) { -// animation-delay: -0.3s; -// } -// & div:nth-child(3) { -// animation-delay: -0.15s; -// } -// @keyframes lds-ring { -// 0% { -// transform: rotate(0deg); -// } -// 100% { -// transform: rotate(360deg); -// } -// } -// ` diff --git a/client/src/pages/CreateProj.tsx b/client/src/pages/CreateProj.tsx index 514bfff..f2903aa 100644 --- a/client/src/pages/CreateProj.tsx +++ b/client/src/pages/CreateProj.tsx @@ -122,12 +122,10 @@ function AddTagsView({ addedTags: string[]; setAddedTags: React.Dispatch>; }) { - const [errors, setErrors] = useState([]); function handleAddTag(tag: string) { const val: string = tag.trim(); if (addedTags.indexOf(val) !== -1) { - setErrors((prev) => [...prev, 'you have already added this tag']); return; } if (val === '') return; @@ -392,7 +390,7 @@ function SubmitBtnView({ loading ? 'opacity-100' : 'opacity-0' }`} > - + @@ -416,32 +414,6 @@ const SubmitWrapper = styled.div` } `; -const FilesWrapper = styled.div` - display: flex; - flex-direction: column; - gap: 1rem; - height: fit-content; - min-height: 21rem; - - label { - all: unset; - font-family: inherit; - white-space: nowrap; - border: 2px dashed #27a0f2; - border-radius: 0.5rem; - padding: 1rem 2rem; - display: flex; - justify-content: center; - align-items: center; - gap: 1rem; - - span { - font-size: 0.9rem; - color: ${({ theme }) => theme.colors.subText}; - } - } -`; - const Image = styled.div` position: relative; width: fit-content; diff --git a/client/src/pages/Home.tsx b/client/src/pages/Home.tsx index f2676f2..b03a8ca 100644 --- a/client/src/pages/Home.tsx +++ b/client/src/pages/Home.tsx @@ -50,7 +50,7 @@ function Projects() { margin: 'auto', }} > - + ); diff --git a/client/src/pages/Project.tsx b/client/src/pages/Project.tsx index 52fb98c..05e27ab 100644 --- a/client/src/pages/Project.tsx +++ b/client/src/pages/Project.tsx @@ -1,5 +1,4 @@ import { - FetcherWithComponents, useNavigate, useParams, } from 'react-router-dom'; @@ -137,7 +136,7 @@ export default function Project() { margin: 'auto', }} > - + ); diff --git a/client/src/pages/Search.tsx b/client/src/pages/Search.tsx index 66cf5ad..687c01b 100644 --- a/client/src/pages/Search.tsx +++ b/client/src/pages/Search.tsx @@ -1,7 +1,6 @@ -import { ChangeEvent, useEffect, useRef, useState } from 'react'; +import { ChangeEvent, useState } from 'react'; import { trpc } from '../utils/trpc'; import ProjectsView from '../components/ProjectsView'; -import { util } from 'zod'; import TagsAutocomplete from '../components/TagsAutocomplete'; type FilterState = { @@ -18,10 +17,6 @@ export default function Search() { }); const { data: projData } = trpc.projects.getByTags.useQuery(filterState.tags); - const { data: autcompleteOptions } = - trpc.tags.getAutocompleteOptions.useQuery(filterState.input); - - const [errorState, setErrorState] = useState(false); const breakpointColumnsObj = { default: 4, diff --git a/server/src/routers/postsRouter.ts b/server/src/routers/postsRouter.ts index f509b93..93d6208 100644 --- a/server/src/routers/postsRouter.ts +++ b/server/src/routers/postsRouter.ts @@ -1,7 +1,5 @@ import { z } from "zod"; import { authedProcedure, publicProcedure, router } from "../trpc"; -import { TRPCError } from "@trpc/server"; -import { projectsRouter } from "./projectsRouter"; export const postsRouter = router({ getAll: publicProcedure.query(async ({ ctx }) => { diff --git a/server/src/routers/projectsRouter.ts b/server/src/routers/projectsRouter.ts index f9d52ce..9fde700 100644 --- a/server/src/routers/projectsRouter.ts +++ b/server/src/routers/projectsRouter.ts @@ -1,6 +1,7 @@ import { z } from 'zod'; import { authedProcedure, publicProcedure, router } from '../trpc'; import { TRPCError } from '@trpc/server'; +import clerkClient from '@clerk/clerk-sdk-node'; export const projectsRouter = router({ getAll: publicProcedure.query(async ({ ctx }) => { @@ -47,6 +48,32 @@ export const projectsRouter = router({ return data; }), + getUserList: authedProcedure + .input( + z.object({ + projectId: z.string(), + userId: z.string(), + }), + ) + .query(async ({ ctx, input }) => { + const projectMemberships = await ctx.db.memberships.findMany({ + where: { + projectId: input.projectId, + }, + }); + + const userList = projectMemberships.map( + (membership) => membership.userId, + ); + + const users = await clerkClient.users.getUserList({ userId: userList }); + users.map((user) => ({ + imageUrl: user.imageUrl, + email: user.emailAddresses, + name: `${user.firstName} ${user.lastName}`, + })); + return users; + }), getByUserId: authedProcedure .input(z.string()) @@ -95,7 +122,7 @@ export const projectsRouter = router({ await ctx.db.post.create({ data: input }); }), - create: authedProcedure + create: authedProcedure .input( z.object({ name: z.string(), @@ -183,4 +210,3 @@ export const projectsRouter = router({ }) }); - From 1c7629dcce6b9dcb9a98445d614cba47d59aad0f Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Tue, 30 Apr 2024 19:22:17 -0700 Subject: [PATCH 05/18] test new process --- .github/workflows/check_ts.yml | 71 +++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index f06ebef..223c70c 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -11,39 +11,48 @@ jobs: - name: Install run: cd ./client + run: npm ci + run: cd .. + run: cd ./client + run: npx prisma generate + run: npm ci + run: cd .. + run: cd ./client + run: npm run build # get the lines modified in this PR - - name: Get diff lines - id: diff - uses: Equip-Collaboration/diff-line-numbers@v1.0.0 - with: - include: '["\\.tsx?$"]' + # - name: Get diff lines + + # id: diff + # uses: Equip-Collaboration/diff-line-numbers@v1.0.0 + # with: + # include: '["\\.tsx?$"]' - # get the files modified in this PR - - name: Detecting files changed - id: files - uses: umani/changed-files@v4.0.0 - with: - repo-token: ${{ github.token }} - pattern: '^.*\.tsx?$' + # # get the files modified in this PR + # - name: Detecting files changed + # id: files + # uses: umani/changed-files@v4.0.0 + # with: + # repo-token: ${{ github.token }} + # pattern: '^.*\.tsx?$' - # echo the changed files - - name: List files changed - run: | - echo 'Files modified: ${{steps.files.outputs.files_updated}}' - echo 'Files added: ${{steps.files.outputs.files_created}}' - echo 'Files removed: ${{steps.files.outputs.files_deleted}}' + # # echo the changed files + # - name: List files changed + # run: | + # echo 'Files modified: ${{steps.files.outputs.files_updated}}' + # echo 'Files added: ${{steps.files.outputs.files_created}}' + # echo 'Files removed: ${{steps.files.outputs.files_deleted}}' - # run the action - - uses: Arhia/action-check-typescript@v1.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - use-check: true # if the action fails, the PR wil fail - check-fail-mode: added # only check for added errors - files-changed: ${{steps.files.outputs.files_updated}} - files-added: ${{steps.files.outputs.files_created}} - files-deleted: ${{steps.files.outputs.files_deleted}} - line-numbers: ${{steps.diff.outputs.lineNumbers}} - output-behaviour: both # use github annotations and comments on the PR - comment-behaviour: new # every run of this action will create a new comment - ts-config-path: './client/tsconfig.json' # use the tsconfig.json in the client directory + # # run the action + # - uses: Arhia/action-check-typescript@v1.0.0 + # with: + # repo-token: ${{ secrets.GITHUB_TOKEN }} + # use-check: true # if the action fails, the PR wil fail + # check-fail-mode: added # only check for added errors + # files-changed: ${{steps.files.outputs.files_updated}} + # files-added: ${{steps.files.outputs.files_created}} + # files-deleted: ${{steps.files.outputs.files_deleted}} + # line-numbers: ${{steps.diff.outputs.lineNumbers}} + # output-behaviour: both # use github annotations and comments on the PR + # comment-behaviour: new # every run of this action will create a new comment + # ts-config-path: './client/tsconfig.json' # use the tsconfig.json in the client directory From a791801e455fdb6d7e9ce55641f10d47b562d9a8 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Tue, 30 Apr 2024 19:24:58 -0700 Subject: [PATCH 06/18] fix new process --- .github/workflows/check_ts.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index 223c70c..297ef4f 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -7,18 +7,18 @@ jobs: runs-on: ubuntu-latest steps: # checkout the code - - uses: actions/checkout@v3 - + uses: actions/checkout@v3 - name: Install - run: cd ./client - run: npm ci - run: cd .. - run: cd ./client - run: npx prisma generate - run: npm ci - run: cd .. - run: cd ./client - run: npm run build + uses: actions/setup-node@v3 + - run: cd ./client + - run: npm ci + - run: cd .. + - run: cd ./client + - run: npx prisma generate + - run: npm ci + - run: cd .. + - run: cd ./client + - run: npm run build # get the lines modified in this PR # - name: Get diff lines From 52cdb3aed9908804dc1853e230baa29cd8e6e73c Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Tue, 30 Apr 2024 19:26:30 -0700 Subject: [PATCH 07/18] another fix --- .github/workflows/check_ts.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index 297ef4f..f0dcd21 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -6,7 +6,6 @@ jobs: ts: runs-on: ubuntu-latest steps: - # checkout the code uses: actions/checkout@v3 - name: Install uses: actions/setup-node@v3 From d6b845858736d043f7e184754c9c2c02f87251d7 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Tue, 30 Apr 2024 19:27:30 -0700 Subject: [PATCH 08/18] add dash --- .github/workflows/check_ts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index f0dcd21..fea8e15 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -6,7 +6,7 @@ jobs: ts: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - name: Install uses: actions/setup-node@v3 - run: cd ./client From 5ca3325635a90e7b54e6e96e1afd01d3c47d2bdc Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Tue, 30 Apr 2024 19:34:14 -0700 Subject: [PATCH 09/18] indent --- .github/workflows/check_ts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index fea8e15..7dd87ba 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -8,7 +8,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Install - uses: actions/setup-node@v3 + uses: actions/setup-node@v3 - run: cd ./client - run: npm ci - run: cd .. From 5dca3373ed4fcf83205c9b1ef4fe9e0ff1d0513a Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Tue, 30 Apr 2024 23:33:49 -0700 Subject: [PATCH 10/18] edit cds --- .github/workflows/check_ts.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index 7dd87ba..2321c1d 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -9,14 +9,14 @@ jobs: - uses: actions/checkout@v3 - name: Install uses: actions/setup-node@v3 - - run: cd ./client + - run: cd client - run: npm ci - run: cd .. - - run: cd ./client + - run: cd server - run: npx prisma generate - run: npm ci - run: cd .. - - run: cd ./client + - run: cd client - run: npm run build # get the lines modified in this PR From d19c892601f3f4384a5844f5a5b7a0cbfef41610 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Tue, 30 Apr 2024 23:48:58 -0700 Subject: [PATCH 11/18] user working-directory --- .github/workflows/check_ts.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index 2321c1d..459a83a 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -6,19 +6,18 @@ jobs: ts: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Install - uses: actions/setup-node@v3 - - run: cd client - - run: npm ci - - run: cd .. - - run: cd server - - run: npx prisma generate - - run: npm ci - - run: cd .. - - run: cd client - - run: npm run build - + - uses: actions/checkout@v4 + - name: Install Node + uses: actions/setup-node@v4 + - name: Install client depencies + working-directory: client + run: npm ci + - name: Install server depencies + working-directory: server + run: npx prisma generate + run: npm ci + - name: Run build + working-directory: client # get the lines modified in this PR # - name: Get diff lines From f7b9c123eb3847d19d5b2788b68e99fc9e9ae8f9 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Tue, 30 Apr 2024 23:49:43 -0700 Subject: [PATCH 12/18] actually run command --- .github/workflows/check_ts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index 459a83a..c6bb08c 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -18,6 +18,7 @@ jobs: run: npm ci - name: Run build working-directory: client + run: npm run build # get the lines modified in this PR # - name: Get diff lines From ad68a178ea5911f89f3f603c4ea412e3064dbd39 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Tue, 30 Apr 2024 23:53:24 -0700 Subject: [PATCH 13/18] fix invalid workflow --- .github/workflows/check_ts.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index c6bb08c..3992cc0 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -14,8 +14,9 @@ jobs: run: npm ci - name: Install server depencies working-directory: server - run: npx prisma generate - run: npm ci + run: | + npx prisma generate + npm ci - name: Run build working-directory: client run: npm run build From 2f6059fd6bb1bde60511e818a5f67c48d418dc2c Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Wed, 1 May 2024 00:00:17 -0700 Subject: [PATCH 14/18] run lint in pipeline --- .github/workflows/check_ts.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_ts.yml b/.github/workflows/check_ts.yml index 3992cc0..2576faf 100644 --- a/.github/workflows/check_ts.yml +++ b/.github/workflows/check_ts.yml @@ -1,7 +1,8 @@ name: 'check-ts' # run this check on PRs on: - pull_request: + pull_request: + branches: [main] jobs: ts: runs-on: ubuntu-latest @@ -19,7 +20,9 @@ jobs: npm ci - name: Run build working-directory: client - run: npm run build + run: | + npm run lint + npm run build # get the lines modified in this PR # - name: Get diff lines From feb0b1892fcffcba72b68a65debfcf11ab0e52bc Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Wed, 1 May 2024 14:40:54 -0700 Subject: [PATCH 15/18] fix useEffect warnings --- client/src/pages/Profile.tsx | 2 +- client/src/pages/Project.tsx | 12 +----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/client/src/pages/Profile.tsx b/client/src/pages/Profile.tsx index de8ee19..40be9dc 100644 --- a/client/src/pages/Profile.tsx +++ b/client/src/pages/Profile.tsx @@ -117,7 +117,7 @@ export function EditProfile() { useEffect(() => { if (!user) return; setImage(user.imageUrl); - }, [isLoaded]); + }, [isLoaded, user]); if (!isSignedIn) return
must be logged in
; diff --git a/client/src/pages/Project.tsx b/client/src/pages/Project.tsx index 05e27ab..bbfc361 100644 --- a/client/src/pages/Project.tsx +++ b/client/src/pages/Project.tsx @@ -75,14 +75,6 @@ export default function Project() { } } - const requestData = trpc.memberships.getAllPendingRequests.useQuery( - projectId ?? '', - ); - - if (requestData.data != undefined) { - console.log(requestData.data); - } - const leaveProjectMutation = trpc.memberships.leaveProject.useMutation({ onSuccess() { console.log('Left Project'); @@ -539,12 +531,10 @@ export function ProjectPostsLayout() { useEffect(() => { if (postId === undefined && data) { - console.log('here'); - if (data.length === 0) return; navigate(`/${projectId}/posts/${data[0].id}`); } - }, []); + }, [data, navigate, postId, projectId]); if (isLoading) return
loading posts
; From 243c2db006d615db2cccbf5fcb220ee2dce973a5 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Wed, 1 May 2024 17:52:59 -0700 Subject: [PATCH 16/18] fix edit project errors --- client/src/components/ProjectsView.tsx | 6 +- client/src/components/Spinner.tsx | 2 +- client/src/components/TagsAutocomplete.tsx | 16 +++-- client/src/main.tsx | 6 +- client/src/pages/CreateProj.tsx | 25 ++++--- client/src/pages/EditProject.tsx | 73 ++++++++++--------- client/src/pages/Project.tsx | 72 +++++++++---------- server/src/index.ts | 2 +- server/src/routers/postsRouter.ts | 70 ++++++++++--------- server/src/routers/projectsRouter.ts | 81 +++++++++++----------- 10 files changed, 189 insertions(+), 164 deletions(-) diff --git a/client/src/components/ProjectsView.tsx b/client/src/components/ProjectsView.tsx index 0d2cbd3..525ed02 100644 --- a/client/src/components/ProjectsView.tsx +++ b/client/src/components/ProjectsView.tsx @@ -59,7 +59,11 @@ export default function ProjectsView(props: { )} {proj.meetType} - {proj.tags.map(tag =>

{tag}

)} + {proj.tags.map((tag) => ( + +

{tag}

+
+ ))} ))} diff --git a/client/src/components/Spinner.tsx b/client/src/components/Spinner.tsx index fc68b4d..b9641de 100644 --- a/client/src/components/Spinner.tsx +++ b/client/src/components/Spinner.tsx @@ -1,5 +1,5 @@ //Buffering animation - the circle that spins when things are loading -export default function Spinner({ size }: { size?: number}) { +export default function Spinner({ size }: { size?: number }) { return (
(''); const [showOpts, setShowOpts] = useState(false); const inputRef = useRef(null); - const { data: autocompleteOptions } = trpc.tags.getAutocompleteOptions.useQuery(input); + const { data: autocompleteOptions } = + trpc.tags.getAutocompleteOptions.useQuery(input); const handleSelect = (tag: string) => { params.onSelect(tag); setInput(''); }; - return (
- {showOpts && (
- {autocompleteOptions && autocompleteOptions?.length > 0 ? + {autocompleteOptions && autocompleteOptions?.length > 0 ? ( autocompleteOptions?.map((tag) => (
{ @@ -42,14 +41,17 @@ export default function TagsAutocomplete(params: AutcompleteParams) { }} onMouseUp={() => { handleSelect(tag.name); - inputRef.current?.blur() - setInput('') + inputRef.current?.blur(); + setInput(''); }} className="flex hover:bg-zinc-200 rounded-md px-2 py-1 hover:cursor-pointer transition-colors" >

{tag.name}

- )) :
Sorry no Matches
} + )) + ) : ( +
Sorry no Matches
+ )}
)}
diff --git a/client/src/main.tsx b/client/src/main.tsx index f555ff1..c4080d2 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -93,12 +93,12 @@ const router = createBrowserRouter([ }, { path: 'members', - element: + element: , }, { path: 'edit', - element: - } + element: , + }, ], }, { diff --git a/client/src/pages/CreateProj.tsx b/client/src/pages/CreateProj.tsx index f2903aa..cb00e18 100644 --- a/client/src/pages/CreateProj.tsx +++ b/client/src/pages/CreateProj.tsx @@ -19,11 +19,6 @@ export type FormState = { image: Blob | null | string; }; -type TagsState = { - input: string; - tags: string[]; -}; - export default function CreateProj() { //elements to fill when creating a project. const [formState, setFormState] = useState({ @@ -87,7 +82,8 @@ export default function CreateProj() { function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (!user) return; - if (!formState.image) return; + if (!formState.image || typeof formState.image === 'string') return; + uploadImageMutation.mutate(formState.image); } //gets files view and inputs view from formstate. @@ -122,7 +118,6 @@ function AddTagsView({ addedTags: string[]; setAddedTags: React.Dispatch>; }) { - function handleAddTag(tag: string) { const val: string = tag.trim(); if (addedTags.indexOf(val) !== -1) { @@ -154,7 +149,9 @@ function AddTagsView({ })} ) : ( -
No tags selected, search one!
+
+ No tags selected, search one! +
)} @@ -309,7 +306,9 @@ export function FilesView({

Select a picture

- + setFormState((prev) => ({ ...prev, image: null }))} /> @@ -390,7 +393,7 @@ function SubmitBtnView({ loading ? 'opacity-100' : 'opacity-0' }`} > - +
diff --git a/client/src/pages/EditProject.tsx b/client/src/pages/EditProject.tsx index 66889be..f12b8f9 100644 --- a/client/src/pages/EditProject.tsx +++ b/client/src/pages/EditProject.tsx @@ -1,10 +1,9 @@ -import { useUser } from "@clerk/clerk-react"; -import { RouterOutputs, trpc } from "../utils/trpc" -import { useState } from "react"; -import { Form, useNavigate, useParams } from "react-router-dom"; -import { FilesView, InputsView } from "./CreateProj"; -import toast from "react-hot-toast"; - +import { useUser } from '@clerk/clerk-react'; +import { trpc } from '../utils/trpc'; +import { useState } from 'react'; +import { Form, useNavigate, useParams } from 'react-router-dom'; +import { FilesView, InputsView } from './CreateProj'; +import toast from 'react-hot-toast'; type FormState = { title: string; @@ -15,19 +14,35 @@ type FormState = { image: Blob | null | string; }; -type ProjectData = RouterOutputs["projects"]["getById"] -type EditProjectProps = { - oldData: ProjectData -} -export function EditProject(){ - const {user} = useUser(); +export function EditProject() { + const { user } = useUser(); const params = useParams(); const utils = trpc.useUtils(); const navigate = useNavigate(); - const { data: oldData} = trpc.projects.getById.useQuery(params.projectId ?? "") - - if(!oldData) return
Error
+ const { data: oldData } = trpc.projects.getById.useQuery( + params.projectId ?? '', + ); + + const [formState, setFormState] = useState(() => + oldData + ? { + title: oldData.name, + description: oldData.description, + location: oldData.meetLocation, + maxMems: '0', + image: oldData.imageUrl, + startDate: oldData.startDate, + } + : { + title: '', + description: '', + location: '', + maxMems: '', + image: '', + startDate: '', + }, + ); // const getImageAsBlob = async (url : string) : Promise => { // // try{ @@ -41,15 +56,6 @@ export function EditProject(){ // return null // } - const [formState, setFormState] = useState({ - title: oldData.name, - description: oldData.description, - location: oldData.meetLocation, - maxMems: "0", - image: oldData.imageUrl, - startDate: oldData.startDate, - }); - function isFormValid() { Object.values(formState).forEach((val) => { if (val === '' || val === null) return false; @@ -57,7 +63,9 @@ export function EditProject(){ return true; } - const [addedTags, setAddedTags] = useState(oldData.tags); + const [addedTags, setAddedTags] = useState( + oldData ? oldData.tags : [], + ); const tagMutation = trpc.tags.addTags.useMutation({ onSuccess() { @@ -76,20 +84,22 @@ export function EditProject(){ // getImageAsBlob(oldData.imageUrl).then((img) => { // setFormState((prev) => ({...prev, image: null})) // }) - + + if (!oldData) return
Error
; + function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (!user) return; if (!formState.image) return; - if(!params.projectId) return; + if (!params.projectId) return; // uploadImageMutation.mutate(formState.image); projMutation.mutate({ projectId: params.projectId, name: formState.title, description: formState.description, meetLocation: formState.location, - meetType: oldData?.meetType ?? "", - imageUrl: oldData?.imageUrl ?? "", + meetType: oldData?.meetType ?? '', + imageUrl: oldData?.imageUrl ?? '', tags: addedTags, }); } @@ -117,5 +127,4 @@ export function EditProject(){ ); - -} \ No newline at end of file +} diff --git a/client/src/pages/Project.tsx b/client/src/pages/Project.tsx index bbfc361..7f7b2fc 100644 --- a/client/src/pages/Project.tsx +++ b/client/src/pages/Project.tsx @@ -1,7 +1,4 @@ -import { - useNavigate, - useParams, -} from 'react-router-dom'; +import { useNavigate, useParams } from 'react-router-dom'; import Spinner from '../components/Spinner'; import dayjjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; @@ -128,7 +125,7 @@ export default function Project() { margin: 'auto', }} > - + ); @@ -592,50 +589,55 @@ export function ProjectPost() { ); } -export function MemberList(){ +export function MemberList() { const params = useParams(); - const {data, isLoading} = trpc.projects.getMembers.useQuery(params.projectId ?? ""); + const { data } = trpc.projects.getMembers.useQuery(params.projectId ?? ''); const utils = trpc.useUtils(); // if (isLoading) return
loading...
const kickUserMutation = trpc.projects.kickUser.useMutation({ - onSuccess(){ - console.log("User Removed") + onSuccess() { + console.log('User Removed'); utils.projects.getMembers.invalidate(); - } + }, }); - - if(!data) return
Error Fetching Members
- if(!data.memberships || data.memberships.length == 0) return
No Members
; + if (!data) return
Error Fetching Members
; + if (!data.memberships || data.memberships.length == 0) + return
No Members
; const handleKickUser = (e: React.MouseEvent) => { e.preventDefault(); - const userId = e.currentTarget.getAttribute("value"); - - if(userId == null) return; + const userId = e.currentTarget.getAttribute('value'); + + if (userId == null) return; kickUserMutation.mutate({ userId: userId, - projectId: params.projectId ?? "" - }) - } + projectId: params.projectId ?? '', + }); + }; - return
- {data.memberships.map((member) => ( -
- {member.userId} - -
- + return ( +
+ {data.memberships.map((member) => ( +
+ {member.userId} + +
+ +
-
- ))} -
+ ))} +
+ ); } diff --git a/server/src/index.ts b/server/src/index.ts index 8f08f42..622fc50 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -4,7 +4,7 @@ import cors from 'cors'; import { projectsRouter } from './routers/projectsRouter'; import { membershipsRouter } from './routers/membershipsRouter'; import { tagsRouter } from './routers/tagsRouter'; -import { postsRouter } from "./routers/postsRouter"; +import { postsRouter } from './routers/postsRouter'; const appRouter = router({ projects: projectsRouter, diff --git a/server/src/routers/postsRouter.ts b/server/src/routers/postsRouter.ts index 93d6208..327ee00 100644 --- a/server/src/routers/postsRouter.ts +++ b/server/src/routers/postsRouter.ts @@ -1,43 +1,45 @@ -import { z } from "zod"; -import { authedProcedure, publicProcedure, router } from "../trpc"; +import { z } from 'zod'; +import { authedProcedure, publicProcedure, router } from '../trpc'; export const postsRouter = router({ - getAll: publicProcedure.query(async ({ ctx }) => { - const posts = await ctx.db.post.findMany({ - take: 5 - }); - return posts; - }), + getAll: publicProcedure.query(async ({ ctx }) => { + const posts = await ctx.db.post.findMany({ + take: 5, + }); + return posts; + }), - getByProjectId: publicProcedure.input(z.string()).query(async ({ ctx, input }) => { - const posts = await ctx.db.post.findMany({ - where: { - projectId: input, - }, - }); + getByProjectId: publicProcedure + .input(z.string()) + .query(async ({ ctx, input }) => { + const posts = await ctx.db.post.findMany({ + where: { + projectId: input, + }, + }); - return posts; + return posts; }), - getById: publicProcedure.input(z.string()).query(async ({ ctx, input }) => { - const posts = await ctx.db.post.findFirst({ - where: { - id: input, - }, - }); + getById: publicProcedure.input(z.string()).query(async ({ ctx, input }) => { + const posts = await ctx.db.post.findFirst({ + where: { + id: input, + }, + }); - return posts; - }), + return posts; + }), - createPost: authedProcedure - .input( - z.object({ - projectId: z.string(), - title: z.string(), - content: z.string(), - }), - ) - .mutation(async ({ ctx, input }) => { - await ctx.db.post.create({ data: input }); + createPost: authedProcedure + .input( + z.object({ + projectId: z.string(), + title: z.string(), + content: z.string(), + }), + ) + .mutation(async ({ ctx, input }) => { + await ctx.db.post.create({ data: input }); }), -}) +}); diff --git a/server/src/routers/projectsRouter.ts b/server/src/routers/projectsRouter.ts index 9fde700..0276ba7 100644 --- a/server/src/routers/projectsRouter.ts +++ b/server/src/routers/projectsRouter.ts @@ -28,26 +28,28 @@ export const projectsRouter = router({ return data; }), - getMembers: publicProcedure.input(z.string()).query(async ({ ctx, input }) => { - const data = await ctx.db.project.findFirst({ - where: { - id: input, - }, - select: { - memberships: { - where: { - status: "ACCEPTED" + getMembers: publicProcedure + .input(z.string()) + .query(async ({ ctx, input }) => { + const data = await ctx.db.project.findFirst({ + where: { + id: input, + }, + select: { + memberships: { + where: { + status: 'ACCEPTED', + }, + select: { + id: true, + userId: true, + }, }, - select: { - id: true, - userId: true, - } - } - } - }) - - return data; - }), + }, + }); + + return data; + }), getUserList: authedProcedure .input( z.object({ @@ -182,31 +184,32 @@ export const projectsRouter = router({ return undefined; } }), - - edit : authedProcedure - .input(z.object({ - projectId: z.string(), - name: z.string(), - description: z.string(), - meetType: z.string(), - meetLocation: z.string(), - imageUrl: z.string(), - tags: z.array(z.string()), - })) + + edit: authedProcedure + .input( + z.object({ + projectId: z.string(), + name: z.string(), + description: z.string(), + meetType: z.string(), + meetLocation: z.string(), + imageUrl: z.string(), + tags: z.array(z.string()), + }), + ) .mutation(async ({ ctx, input }) => { await ctx.db.project.update({ - where:{ - id: input.projectId - }, + where: { + id: input.projectId, + }, data: { - name: input.name, + name: input.name, description: input.description, meetType: input.meetType, meetLocation: input.meetLocation, imageUrl: input.imageUrl, - tags: input.tags, - } - }) - }) - + tags: input.tags, + }, + }); + }), }); From 03c4a3f083003c2663f1049810d46f7533ac6f51 Mon Sep 17 00:00:00 2001 From: Santiago Garcia Date: Thu, 22 Aug 2024 13:04:28 -0700 Subject: [PATCH 17/18] add tailwind merge and add styling for main activity --- client/package-lock.json | 19 ++++++++++++ client/package.json | 2 ++ client/src/App.tsx | 7 +++-- client/src/components/ActivityWrapper.tsx | 11 +++++++ client/src/components/Nav.tsx | 10 +++---- client/src/components/ProjectsView.tsx | 4 +-- client/src/index.css | 2 +- client/src/pages/Home.tsx | 6 ---- client/src/pages/Project.tsx | 36 +++++++++++++++-------- client/src/pages/Requests.tsx | 5 +--- client/src/utils/utils.ts | 6 ++++ server/src/routers/projectsRouter.ts | 13 ++++++-- 12 files changed, 84 insertions(+), 37 deletions(-) create mode 100644 client/src/components/ActivityWrapper.tsx create mode 100644 client/src/utils/utils.ts diff --git a/client/package-lock.json b/client/package-lock.json index 2c3a6c5..5ed1547 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -14,6 +14,7 @@ "@trpc/client": "^10.44.1", "@trpc/react-query": "^10.44.1", "@trpc/server": "^10.44.1", + "clsx": "^2.1.1", "dayjs": "^1.11.9", "firebase": "^10.1.0", "react": "^18.2.0", @@ -24,6 +25,7 @@ "react-masonry-css": "^1.0.16", "react-router-dom": "^6.14.2", "styled-components": "^6.1.0", + "tailwind-merge": "^2.5.2", "uuid": "^9.0.1", "zod": "^3.22.4" }, @@ -5406,6 +5408,14 @@ "node": ">=6" } }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "engines": { + "node": ">=6" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -11777,6 +11787,15 @@ "react": "^16.11.0 || ^17.0.0 || ^18.0.0" } }, + "node_modules/tailwind-merge": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.5.2.tgz", + "integrity": "sha512-kjEBm+pvD+6eAwzJL2Bi+02/9LFLal1Gs61+QB7HvTfQQ0aXwC5LGT8PEt1gS0CWKktKe6ysPTAy3cBC5MeiIg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/dcastil" + } + }, "node_modules/tailwindcss": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.3.tgz", diff --git a/client/package.json b/client/package.json index 5cf6922..9e3f09d 100644 --- a/client/package.json +++ b/client/package.json @@ -17,6 +17,7 @@ "@trpc/client": "^10.44.1", "@trpc/react-query": "^10.44.1", "@trpc/server": "^10.44.1", + "clsx": "^2.1.1", "dayjs": "^1.11.9", "firebase": "^10.1.0", "react": "^18.2.0", @@ -27,6 +28,7 @@ "react-masonry-css": "^1.0.16", "react-router-dom": "^6.14.2", "styled-components": "^6.1.0", + "tailwind-merge": "^2.5.2", "uuid": "^9.0.1", "zod": "^3.22.4" }, diff --git a/client/src/App.tsx b/client/src/App.tsx index 67d23aa..fc9356f 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -10,6 +10,7 @@ import { useState } from 'react'; import { trpc } from './utils/trpc'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { httpBatchLink } from '@trpc/client'; +import ActivityWrapper from './components/ActivityWrapper'; export default function App({ queryClient }: { queryClient: QueryClient }) { const { getToken, userId } = useAuth(); @@ -40,10 +41,10 @@ export default function App({ queryClient }: { queryClient: QueryClient }) {
diff --git a/client/src/components/ActivityWrapper.tsx b/client/src/components/ActivityWrapper.tsx new file mode 100644 index 0000000..3f0b071 --- /dev/null +++ b/client/src/components/ActivityWrapper.tsx @@ -0,0 +1,11 @@ +import cn from '../utils/utils'; + +export default function ActivityWrapper({ + children, + className, +}: { + children: React.ReactNode; + className?: string; +}) { + return
{children}
; +} diff --git a/client/src/components/Nav.tsx b/client/src/components/Nav.tsx index f24bf1b..f197d31 100644 --- a/client/src/components/Nav.tsx +++ b/client/src/components/Nav.tsx @@ -9,8 +9,8 @@ export default function Nav() { //returns header of logo and profile button or "sign in/sign up" if user is not registered. return ( -
-