diff --git a/.github/workflows/generateCheck.sh b/.github/workflows/generateCheck.sh new file mode 100755 index 00000000..0f98e9cb --- /dev/null +++ b/.github/workflows/generateCheck.sh @@ -0,0 +1,14 @@ +if [ $status == 0 ]; then + echo "## Formatting Check passed 🥳" >>$GITHUB_STEP_SUMMARY + echo "All files are formatted correctly" >>$GITHUB_STEP_SUMMARY + exit 0 +else + echo "## Formatting Check Failed 😅" >>$GITHUB_STEP_SUMMARY + echo "Please run prettier using \`npx prettier . --write\` in order to format your code" >>$GITHUB_STEP_SUMMARY + echo "### Files with bad formatting:" >>$GITHUB_STEP_SUMMARY + for file in $files; do + echo "- $file" >>$GITHUB_STEP_SUMMARY + echo "::error file=$file::$file not formatted correctly" + done + exit 1 +fi diff --git a/.github/workflows/prettierCheck.yml b/.github/workflows/prettierCheck.yml new file mode 100644 index 00000000..e642ea75 --- /dev/null +++ b/.github/workflows/prettierCheck.yml @@ -0,0 +1,24 @@ +name: Formatting Check +run-name: Running formatting check +on: [push] +jobs: + check-formatting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: 'npm' + - name: Run npm install + run: | + mv package.json package.json.bak + npm i --no-save prettier prettier-plugin-tailwindcss + mv package.json.bak package.json + - name: Run prettier + run: | + files=`npx prettier . -l` || st=$? && st=$? + echo status=`echo $st`>>"$GITHUB_ENV" + echo files=`echo $files`>> "$GITHUB_ENV" + - name: generate errors/summary + run: .github/workflows/generateCheck.sh diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..01f86141 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +src/server/db/migrations/* diff --git a/next.config.mjs b/next.config.mjs index c611029a..97434853 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -7,15 +7,27 @@ await import('./src/env.mjs'); /** @type {import("next").NextConfig} */ const config = { images: { - domains: [ - 'lh3.googleusercontent.com', - 'cdn.discordapp.com', - 'jupiter.nlmc.workers.dev', + remotePatterns: [ + { + protocol: 'https', + hostname: 'lh3.googleusercontent.com', + pathname: '**', + port: '', + }, + { + protocol: 'https', + hostname: 'cdn.discordapp.com', + pathname: '**', + port: '', + }, + { + protocol: 'https', + hostname: 'jupiter.nlmc.workers.dev', + pathname: '**', + port: '', + }, ], }, - experimental: { - serverActions: true, - }, }; export default config; diff --git a/package-lock.json b/package-lock.json index 487c2f52..ce23a4bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,18 +16,17 @@ "@radix-ui/react-popover": "^1.0.7", "@radix-ui/react-radio-group": "^1.1.3", "@tanstack/match-sorter-utils": "^8.8.4", - "@tanstack/react-query": "^4.32.6", + "@tanstack/react-query": "^5.29.2", "@tanstack/react-table": "^8.11.0", "@tanstack/react-virtual": "^3.0.1", - "@trpc/client": "^10.37.1", - "@trpc/next": "^10.37.1", - "@trpc/react-query": "^10.37.1", - "@trpc/server": "^10.37.1", + "@trpc/client": "^11.0.0-rc.340", + "@trpc/react-query": "^11.0.0-rc.340", + "@trpc/server": "^11.0.0-rc.340", "date-fns": "^2.30.0", "dotenv": "^16.0.3", "drizzle-orm": "^0.28.5", "drizzle-zod": "^0.5.1", - "next": "^13.5.4", + "next": "^14.2.2", "next-auth": "^4.23.0", "postgres": "^3.3.5", "react": "18.2.0", @@ -64,7 +63,7 @@ "jest": "^29.7.0", "lint-staged": "^12.4.0", "postcss": "^8.4.27", - "prettier": "^3.0.0", + "prettier": "^3.2.5", "prettier-plugin-tailwindcss": "^0.5.1", "tailwindcss": "^3.3.3", "ts-jest": "^29.1.1", @@ -1109,22 +1108,6 @@ "get-tsconfig": "^4.7.0" } }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.18.20", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz", - "integrity": "sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -1735,9 +1718,9 @@ } }, "node_modules/@next/env": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/env/-/env-13.5.6.tgz", - "integrity": "sha512-Yac/bV5sBGkkEXmAX5FWPS9Mmo2rthrOPRQQNfycJPkjUAUclomCPH7QFVCDQ4Mp2k2K1SSM6m0zrxYrOwtFQw==" + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.3.tgz", + "integrity": "sha512-W7fd7IbkfmeeY2gXrzJYDx8D2lWKbVoTIj1o1ScPHNzvp30s1AuoEFSdr39bC5sjxJaxTtq3OTCZboNp0lNWHA==" }, "node_modules/@next/eslint-plugin-next": { "version": "13.5.5", @@ -1790,130 +1773,10 @@ "node": "*" } }, - "node_modules/@next/swc-darwin-arm64": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.5.6.tgz", - "integrity": "sha512-5nvXMzKtZfvcu4BhtV0KH1oGv4XEW+B+jOfmBdpFI3C7FrB/MfujRpWYSBBO64+qbW8pkZiSyQv9eiwnn5VIQA==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-darwin-x64": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.6.tgz", - "integrity": "sha512-6cgBfxg98oOCSr4BckWjLLgiVwlL3vlLj8hXg2b+nDgm4bC/qVXXLfpLB9FHdoDu4057hzywbxKvmYGmi7yUzA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.6.tgz", - "integrity": "sha512-txagBbj1e1w47YQjcKgSU4rRVQ7uF29YpnlHV5xuVUsgCUf2FmyfJ3CPjZUvpIeXCJAoMCFAoGnbtX86BK7+sg==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.6.tgz", - "integrity": "sha512-cGd+H8amifT86ZldVJtAKDxUqeFyLWW+v2NlBULnLAdWsiuuN8TuhVBt8ZNpCqcAuoruoSWynvMWixTFcroq+Q==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.6.tgz", - "integrity": "sha512-Mc2b4xiIWKXIhBy2NBTwOxGD3nHLmq4keFk+d4/WL5fMsB8XdJRdtUlL87SqVCTSaf1BRuQQf1HvXZcy+rq3Nw==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.6.tgz", - "integrity": "sha512-CFHvP9Qz98NruJiUnCe61O6GveKKHpJLloXbDSWRhqhkJdZD2zU5hG+gtVJR//tyW897izuHpM6Gtf6+sNgJPQ==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.6.tgz", - "integrity": "sha512-aFv1ejfkbS7PUa1qVPwzDHjQWQtknzAZWGTKYIAaS4NMtBlk3VyA6AYn593pqNanlicewqyl2jUhQAaFV/qXsg==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-ia32-msvc": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.6.tgz", - "integrity": "sha512-XqqpHgEIlBHvzwG8sp/JXMFkLAfGLqkbVsyN+/Ih1mR8INb6YCc2x/Mbwi6hsAgUnqQztz8cvEbHJUbSl7RHDg==", - "cpu": [ - "ia32" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.6.tgz", - "integrity": "sha512-Cqfe1YmOS7k+5mGu92nl5ULkzpKuxJrP3+4AEuPmrpFZ3BHxTY3TnHmU1On3bFmFFs6FbTcdF58CCUProGpIGQ==", + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.3.tgz", + "integrity": "sha512-Q1/zm43RWynxrO7lW4ehciQVj+5ePBhOK+/K2P7pLFX3JaJ/IZVC69SHidrmZSOkqz7ECIOhhy7XhAFG4JYyHA==", "cpu": [ "x64" ], @@ -2677,11 +2540,17 @@ "@sinonjs/commons": "^3.0.0" } }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==" + }, "node_modules/@swc/helpers": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.2.tgz", - "integrity": "sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.5.tgz", + "integrity": "sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==", "dependencies": { + "@swc/counter": "^0.1.3", "tslib": "^2.4.0" } }, @@ -2716,38 +2585,27 @@ } }, "node_modules/@tanstack/query-core": { - "version": "4.36.1", - "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-4.36.1.tgz", - "integrity": "sha512-DJSilV5+ytBP1FbFcEJovv4rnnm/CokuVvrBEtW/Va9DvuJ3HksbXUJEpI0aV1KtuL4ZoO9AVE6PyNLzF7tLeA==", + "version": "5.35.1", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.35.1.tgz", + "integrity": "sha512-0Dnpybqb8+ps6WgqBnqFEC+1F/xLvUosRAq+wiGisTgolOZzqZfkE2995dEXmhuzINiTM7/a6xSGznU0NIvBkw==", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" } }, "node_modules/@tanstack/react-query": { - "version": "4.36.1", - "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-4.36.1.tgz", - "integrity": "sha512-y7ySVHFyyQblPl3J3eQBWpXZkliroki3ARnBKsdJchlgt7yJLRDUcf4B8soufgiYt3pEQIkBWBx1N9/ZPIeUWw==", + "version": "5.35.1", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.35.1.tgz", + "integrity": "sha512-i2T7m2ffQdNqlX3pO+uMsnQ0H4a59Ens2GxtlMsRiOvdSB4SfYmHb27MnvFV8rGmtWRaa4gPli0/rpDoSS5LbQ==", "dependencies": { - "@tanstack/query-core": "4.36.1", - "use-sync-external-store": "^1.2.0" + "@tanstack/query-core": "5.35.1" }, "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" }, "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react-native": "*" - }, - "peerDependenciesMeta": { - "react-dom": { - "optional": true - }, - "react-native": { - "optional": true - } + "react": "^18.0.0" } }, "node_modules/@tanstack/react-table": { @@ -2807,55 +2665,35 @@ } }, "node_modules/@trpc/client": { - "version": "10.40.0", - "resolved": "https://registry.npmjs.org/@trpc/client/-/client-10.40.0.tgz", - "integrity": "sha512-bT6BcdWjj0KzGQiimE6rB2tIaRYX0Ear4Gthb5szN/c01wrP0yC1Fbz2uCcm/QTVAwu4Lve5M+YjPoEaTHG6lg==", - "funding": [ - "https://trpc.io/sponsor" - ], - "peerDependencies": { - "@trpc/server": "10.40.0" - } - }, - "node_modules/@trpc/next": { - "version": "10.40.0", - "resolved": "https://registry.npmjs.org/@trpc/next/-/next-10.40.0.tgz", - "integrity": "sha512-GMOiN+2DIfUXxS2DuTuTT3FOzkuB5p6+1QglY5M9ywKFWBVTGkBnbLkTgoPGuglq+dPfcZbcSajRN22AUv5Qtg==", + "version": "11.0.0-rc.366", + "resolved": "https://registry.npmjs.org/@trpc/client/-/client-11.0.0-rc.366.tgz", + "integrity": "sha512-bIbcF/UhCifU5i9hbbaMlmOS2NgnRq5W0pJH2SJhrp6jyIIaCF+uNAIZtkfO0GriBb0agBmGIXqvGLFEexiTKA==", "funding": [ "https://trpc.io/sponsor" ], - "dependencies": { - "react-ssr-prepass": "^1.5.0" - }, "peerDependencies": { - "@tanstack/react-query": "^4.18.0", - "@trpc/client": "10.40.0", - "@trpc/react-query": "10.40.0", - "@trpc/server": "10.40.0", - "next": "*", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" + "@trpc/server": "11.0.0-rc.366+237dbb3f9" } }, "node_modules/@trpc/react-query": { - "version": "10.40.0", - "resolved": "https://registry.npmjs.org/@trpc/react-query/-/react-query-10.40.0.tgz", - "integrity": "sha512-DpJrV3lmYNo9xtPtcg49lfh9CUFap3ZivjhlSmfe4QPf7H6xBjAE+ml4OdJ0RmKvSTFvbLSOiNdB1k5O8zIdzQ==", + "version": "11.0.0-rc.366", + "resolved": "https://registry.npmjs.org/@trpc/react-query/-/react-query-11.0.0-rc.366.tgz", + "integrity": "sha512-LCdJFymEdaKBBNRQPVAcEw9qNu3m+n9hH3qIPKDanLWYlo4h+8lQnj8JIhYpClD2G3gkvD0ZSZ+F54QvwrI3nA==", "funding": [ "https://trpc.io/sponsor" ], "peerDependencies": { - "@tanstack/react-query": "^4.18.0", - "@trpc/client": "10.40.0", - "@trpc/server": "10.40.0", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" + "@tanstack/react-query": "^5.25.0", + "@trpc/client": "11.0.0-rc.366+237dbb3f9", + "@trpc/server": "11.0.0-rc.366+237dbb3f9", + "react": ">=18.2.0", + "react-dom": ">=18.2.0" } }, "node_modules/@trpc/server": { - "version": "10.40.0", - "resolved": "https://registry.npmjs.org/@trpc/server/-/server-10.40.0.tgz", - "integrity": "sha512-49SUOMWzSZtu5+OdrADmJD+u+sjSE0qj1cWgYk2FY4jLkPJunLuNRuhzM7aOeBhiUjyfhg2YTfur8FN1WBmvEw==", + "version": "11.0.0-rc.366", + "resolved": "https://registry.npmjs.org/@trpc/server/-/server-11.0.0-rc.366.tgz", + "integrity": "sha512-Pr7SdpIVrOGtIGt9vs7i3v0hqzlpXbi8/8RV7XfrXVJ5hlzKYOz5VE0AjckhHXuhrUlpTGTDm0/2nz0ywLcQ2g==", "funding": [ "https://trpc.io/sponsor" ] @@ -4024,9 +3862,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001549", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001549.tgz", - "integrity": "sha512-qRp48dPYSCYaP+KurZLhDYdVE+yEyht/3NlmcJgVQ2VMGt6JL36ndQ/7rgspdZsJuxDPFIo/OzBT2+GmIJ53BA==", + "version": "1.0.30001616", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001616.tgz", + "integrity": "sha512-RHVYKov7IcdNjVHJFNY/78RdG4oGVjbayxv8u5IO74Wv7Hlq4PnJE6mo/OjFijjVFNy5ijnCt6H3IIo4t+wfEw==", "funding": [ { "type": "opencollective", @@ -6314,20 +6152,6 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -6561,11 +6385,6 @@ "node": ">=10.13.0" } }, - "node_modules/glob-to-regexp": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", - "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" - }, "node_modules/glob/node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -9024,37 +8843,38 @@ "dev": true }, "node_modules/next": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/next/-/next-13.5.6.tgz", - "integrity": "sha512-Y2wTcTbO4WwEsVb4A8VSnOsG1I9ok+h74q0ZdxkwM3EODqrs4pasq7O0iUxbcS9VtWMicG7f3+HAj0r1+NtKSw==", + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/next/-/next-14.2.3.tgz", + "integrity": "sha512-dowFkFTR8v79NPJO4QsBUtxv0g9BrS/phluVpMAt2ku7H+cbcBJlopXjkWlwxrk/xGqMemr7JkGPGemPrLLX7A==", "dependencies": { - "@next/env": "13.5.6", - "@swc/helpers": "0.5.2", + "@next/env": "14.2.3", + "@swc/helpers": "0.5.5", "busboy": "1.6.0", - "caniuse-lite": "^1.0.30001406", + "caniuse-lite": "^1.0.30001579", + "graceful-fs": "^4.2.11", "postcss": "8.4.31", - "styled-jsx": "5.1.1", - "watchpack": "2.4.0" + "styled-jsx": "5.1.1" }, "bin": { "next": "dist/bin/next" }, "engines": { - "node": ">=16.14.0" + "node": ">=18.17.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "13.5.6", - "@next/swc-darwin-x64": "13.5.6", - "@next/swc-linux-arm64-gnu": "13.5.6", - "@next/swc-linux-arm64-musl": "13.5.6", - "@next/swc-linux-x64-gnu": "13.5.6", - "@next/swc-linux-x64-musl": "13.5.6", - "@next/swc-win32-arm64-msvc": "13.5.6", - "@next/swc-win32-ia32-msvc": "13.5.6", - "@next/swc-win32-x64-msvc": "13.5.6" + "@next/swc-darwin-arm64": "14.2.3", + "@next/swc-darwin-x64": "14.2.3", + "@next/swc-linux-arm64-gnu": "14.2.3", + "@next/swc-linux-arm64-musl": "14.2.3", + "@next/swc-linux-x64-gnu": "14.2.3", + "@next/swc-linux-x64-musl": "14.2.3", + "@next/swc-win32-arm64-msvc": "14.2.3", + "@next/swc-win32-ia32-msvc": "14.2.3", + "@next/swc-win32-x64-msvc": "14.2.3" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", + "@playwright/test": "^1.41.2", "react": "^18.2.0", "react-dom": "^18.2.0", "sass": "^1.3.0" @@ -9063,6 +8883,9 @@ "@opentelemetry/api": { "optional": true }, + "@playwright/test": { + "optional": true + }, "sass": { "optional": true } @@ -9850,9 +9673,9 @@ } }, "node_modules/prettier": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", - "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" @@ -10158,14 +9981,6 @@ } } }, - "node_modules/react-ssr-prepass": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/react-ssr-prepass/-/react-ssr-prepass-1.5.0.tgz", - "integrity": "sha512-yFNHrlVEReVYKsLI5lF05tZoHveA5pGzjFbFJY/3pOqqjGOmMmqx83N4hIjN2n6E1AOa+eQEUxs3CgRnPmT0RQ==", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, "node_modules/react-style-singleton": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.1.tgz", @@ -11825,14 +11640,6 @@ } } }, - "node_modules/use-sync-external-store": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", - "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -11886,18 +11693,6 @@ "makeerror": "1.0.12" } }, - "node_modules/watchpack": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", - "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", - "dependencies": { - "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.1.2" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", @@ -12137,6 +11932,126 @@ "funding": { "url": "https://github.com/sponsors/colinhacks" } + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.3.tgz", + "integrity": "sha512-3pEYo/RaGqPP0YzwnlmPN2puaF2WMLM3apt5jLW2fFdXD9+pqcoTzRk+iZsf8ta7+quAe4Q6Ms0nR0SFGFdS1A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.3.tgz", + "integrity": "sha512-6adp7waE6P1TYFSXpY366xwsOnEXM+y1kgRpjSRVI2CBDOcbRjsJ67Z6EgKIqWIue52d2q/Mx8g9MszARj8IEA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.3.tgz", + "integrity": "sha512-cuzCE/1G0ZSnTAHJPUT1rPgQx1w5tzSX7POXSLaS7w2nIUJUD+e25QoXD/hMfxbsT9rslEXugWypJMILBj/QsA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.3.tgz", + "integrity": "sha512-0D4/oMM2Y9Ta3nGuCcQN8jjJjmDPYpHX9OJzqk42NZGJocU2MqhBq5tWkJrUQOQY9N+In9xOdymzapM09GeiZw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.3.tgz", + "integrity": "sha512-ENPiNnBNDInBLyUU5ii8PMQh+4XLr4pG51tOp6aJ9xqFQ2iRI6IH0Ds2yJkAzNV1CfyagcyzPfROMViS2wOZ9w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.3.tgz", + "integrity": "sha512-BTAbq0LnCbF5MtoM7I/9UeUu/8ZBY0i8SFjUMCbPDOLv+un67e2JgyN4pmgfXBwy/I+RHu8q+k+MCkDN6P9ViQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.3.tgz", + "integrity": "sha512-AEHIw/dhAMLNFJFJIJIyOFDzrzI5bAjI9J26gbO5xhAKHYTZ9Or04BesFPXiAYXDNdrwTP2dQceYA4dL1geu8A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.3.tgz", + "integrity": "sha512-vga40n1q6aYb0CLrM+eEmisfKCR45ixQYXuBXxOOmmoV8sYST9k7E3US32FsY+CkkF7NtzdcebiFT4CHuMSyZw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } } diff --git a/package.json b/package.json index 8935df9a..3deca13e 100644 --- a/package.json +++ b/package.json @@ -21,18 +21,17 @@ "@radix-ui/react-popover": "^1.0.7", "@radix-ui/react-radio-group": "^1.1.3", "@tanstack/match-sorter-utils": "^8.8.4", - "@tanstack/react-query": "^4.32.6", + "@tanstack/react-query": "^5.29.2", "@tanstack/react-table": "^8.11.0", "@tanstack/react-virtual": "^3.0.1", - "@trpc/client": "^10.37.1", - "@trpc/next": "^10.37.1", - "@trpc/react-query": "^10.37.1", - "@trpc/server": "^10.37.1", + "@trpc/client": "^11.0.0-rc.340", + "@trpc/react-query": "^11.0.0-rc.340", + "@trpc/server": "^11.0.0-rc.340", "date-fns": "^2.30.0", "dotenv": "^16.0.3", "drizzle-orm": "^0.28.5", "drizzle-zod": "^0.5.1", - "next": "^13.5.4", + "next": "^14.2.2", "next-auth": "^4.23.0", "postgres": "^3.3.5", "react": "18.2.0", @@ -69,7 +68,7 @@ "jest": "^29.7.0", "lint-staged": "^12.4.0", "postcss": "^8.4.27", - "prettier": "^3.0.0", + "prettier": "^3.2.5", "prettier-plugin-tailwindcss": "^0.5.1", "tailwindcss": "^3.3.3", "ts-jest": "^29.1.1", diff --git a/src/app/admin/carousel/page.tsx b/src/app/admin/carousel/page.tsx index 6e93a887..e9f0dd6f 100644 --- a/src/app/admin/carousel/page.tsx +++ b/src/app/admin/carousel/page.tsx @@ -3,8 +3,8 @@ import { api } from '@src/trpc/server'; import Link from 'next/link'; export default async function Page() { - const carouselItems = await api.club.getCarousel.query(); - const upcoming = await api.admin.upcomingCarousels.query(); + const carouselItems = await api.club.getCarousel(); + const upcoming = await api.admin.upcomingCarousels(); return (

diff --git a/src/app/admin/orgs/page.tsx b/src/app/admin/orgs/page.tsx index 5fa2cd71..d2fc79b8 100644 --- a/src/app/admin/orgs/page.tsx +++ b/src/app/admin/orgs/page.tsx @@ -2,7 +2,7 @@ import OrgTable from '@src/components/admin/OrgTable'; import { api } from '@src/trpc/server'; export default async function Page() { - const clubs = await api.admin.allOrgs.query(); + const clubs = await api.admin.allOrgs(); return (
diff --git a/src/app/api/trpc/[trpc]/route.ts b/src/app/api/trpc/[trpc]/route.ts index 532a5438..e9bf0c13 100644 --- a/src/app/api/trpc/[trpc]/route.ts +++ b/src/app/api/trpc/[trpc]/route.ts @@ -10,7 +10,7 @@ const handler = (req: NextRequest) => endpoint: '/api/trpc', req, router: appRouter, - createContext: () => createTRPCContext({ req }), + createContext: () => createTRPCContext({ headers: req.headers }), onError: env.NODE_ENV === 'development' ? ({ path, error }) => { diff --git a/src/app/liked/likedEvents.tsx b/src/app/community/communityEvents.tsx similarity index 75% rename from src/app/liked/likedEvents.tsx rename to src/app/community/communityEvents.tsx index a9af30d7..a831495f 100644 --- a/src/app/liked/likedEvents.tsx +++ b/src/app/community/communityEvents.tsx @@ -4,14 +4,14 @@ import EventCard from '@src/components/events/EventCard'; import { api } from '@src/trpc/server'; import Link from 'next/link'; -const LikedEvents = async () => { - const events = await api.userMetadata.getEvents.query(); +const CommunityEvents = async () => { + const events = await api.userMetadata.getEvents(); if (events.length == 0) { return (
-
you haven't liked any events yet 😢
+
You haven't added any community events yet 😭
- you can check out new events{' '} + You can check out new events{' '} {
); }; -export default LikedEvents; +export default CommunityEvents; diff --git a/src/app/liked/page.tsx b/src/app/community/page.tsx similarity index 64% rename from src/app/liked/page.tsx rename to src/app/community/page.tsx index c297726d..c3fb56cf 100644 --- a/src/app/liked/page.tsx +++ b/src/app/community/page.tsx @@ -3,21 +3,21 @@ import { getServerAuthSession } from '@src/server/auth'; import { type Metadata } from 'next'; import Image from 'next/image'; import React from 'react'; -import LikedEvents from './likedEvents'; +import CommunityEvents from './communityEvents'; export const metadata: Metadata = { - title: 'Liked - Jupiter', - description: 'Liked Page', + title: 'My Community - Jupiter', + description: 'Community Page', alternates: { - canonical: 'https://jupiter.utdnebula.com/liked', + canonical: 'https://jupiter.utdnebula.com/community', }, openGraph: { - url: 'https://jupiter.utdnebula.com/liked', - description: 'Liked - Jupiter', + url: 'https://jupiter.utdnebula.com/community', + description: 'My Community - Jupiter', }, }; -const Liked = async () => { +const Community = async () => { const session = await getServerAuthSession(); if (!session) { @@ -29,7 +29,7 @@ const Liked = async () => {

- Please Sign in to Use the liked Page. + Please Sign in to Use the Community Page.

@@ -39,11 +39,11 @@ const Liked = async () => {
-

Liked Events

- +

Community Events

+
); }; -export default Liked; +export default Community; diff --git a/src/app/directory/[id]/page.tsx b/src/app/directory/[id]/page.tsx index 98b7d393..51de93ad 100644 --- a/src/app/directory/[id]/page.tsx +++ b/src/app/directory/[id]/page.tsx @@ -1,17 +1,15 @@ -import ClubDocuments from '@src/components/ClubDocuments'; import Header from '@src/components/BaseHeader'; import OrgHeader from '@src/components/OrgHeader'; import OrgInfoSegment from '@src/components/OrgInfoSegment'; import OrgUpcomingEvents from '@src/components/OrgUpcomingEvents'; import { api } from '@src/trpc/server'; -import { PlusIcon } from '@src/icons/Icons'; import { db } from '@src/server/db'; import { eq } from 'drizzle-orm'; import { type Metadata } from 'next'; import NotFound from '@src/components/NotFound'; const OrganizationPage = async ({ params }: { params: { id: string } }) => { - const club = await api.club.getDirectoryInfo.query({ id: params.id }); + const club = await api.club.getDirectoryInfo({ id: params.id }); if (!club) return ; return ( @@ -21,14 +19,6 @@ const OrganizationPage = async ({ params }: { params: { id: string } }) => { - -
-
Promo text
- -
); diff --git a/src/app/directory/create/createForm.tsx b/src/app/directory/create/createForm.tsx index f5d26a44..b9342196 100644 --- a/src/app/directory/create/createForm.tsx +++ b/src/app/directory/create/createForm.tsx @@ -34,7 +34,7 @@ const CreateClubForm = ({ user }: { user: { id: string; name: string } }) => { onSuccess: (id) => router.push(`/directory/${id}`), }); const submitForm = handleSubmit((data) => { - if (!createClub.isLoading) createClub.mutate(data); + if (!createClub.isPending) createClub.mutate(data); }); return (
diff --git a/src/app/directory/create/page.tsx b/src/app/directory/create/page.tsx index dae95411..da5b2791 100644 --- a/src/app/directory/create/page.tsx +++ b/src/app/directory/create/page.tsx @@ -2,10 +2,11 @@ import Header from '@src/components/BaseHeader'; import CreateClubForm from './createForm'; import { getServerAuthSession } from '@src/server/auth'; import { redirect } from 'next/navigation'; +import { signInRoute } from '@src/utils/redirect'; export default async function Page() { const session = await getServerAuthSession(); - if (!session) redirect('/auth'); + if (!session) redirect(signInRoute('directory/create')); return (
diff --git a/src/app/event/[id]/page.tsx b/src/app/event/[id]/page.tsx index cdaf902c..405c6452 100644 --- a/src/app/event/[id]/page.tsx +++ b/src/app/event/[id]/page.tsx @@ -23,12 +23,16 @@ export default async function EventsPage({ params }: Params) { const { club, ...event } = res; - const isRegistered = (session && await db.query.userMetadataToEvents.findFirst({ - where: (userMetadataToEvents) => and( - eq(userMetadataToEvents.eventId, event.id), - eq(userMetadataToEvents.userId, session.user.id) - ) - }) !== undefined) || false; + const isRegistered = + (session && + (await db.query.userMetadataToEvents.findFirst({ + where: (userMetadataToEvents) => + and( + eq(userMetadataToEvents.eventId, event.id), + eq(userMetadataToEvents.userId, session.user.id), + ), + })) !== undefined) || + false; const clubDescription = ['Club', 'Location', 'Multi-Day']; const clubDetails = [club.name, event.location, 'No']; @@ -52,7 +56,10 @@ export default async function EventsPage({ params }: Params) {
{session && ( - + )}
diff --git a/src/app/events/eventView.tsx b/src/app/events/eventView.tsx index 86d97c5a..dfaed368 100644 --- a/src/app/events/eventView.tsx +++ b/src/app/events/eventView.tsx @@ -14,13 +14,13 @@ const EventView = ({ events, params }: Props) => { return (
-
+

Events

{
-

List view

+

List view

{
-

Grid view

+

Grid view

-
+
{events.map((event) => { diff --git a/src/app/events/page.tsx b/src/app/events/page.tsx index c852f94f..bb5935e2 100644 --- a/src/app/events/page.tsx +++ b/src/app/events/page.tsx @@ -66,7 +66,7 @@ const Events = async ({ searchParams }: { searchParams: searchPams }) => { order: searchParams.order ?? 'soon', types: searchParams.types ?? [], }; - const { events } = await api.event.findByFilters.query({ + const { events } = await api.event.findByFilters({ startTime: getStartTime(filters), club: filters.clubs, order: filters.order, diff --git a/src/app/feedback/Form.tsx b/src/app/feedback/Form.tsx index 071e230b..65f075c6 100644 --- a/src/app/feedback/Form.tsx +++ b/src/app/feedback/Form.tsx @@ -1,4 +1,4 @@ -"use client"; +'use client'; /* eslint-disable @typescript-eslint/no-misused-promises */ import Image from 'next/image'; @@ -8,111 +8,121 @@ import { api } from '@src/trpc/react'; import { type z } from 'zod'; import { zodResolver } from '@hookform/resolvers/zod'; import { type FormEventHandler } from 'react'; -import FormPopUp from "@src/app/feedback/FormPopUp"; +import FormPopUp from '@src/app/feedback/FormPopUp'; import { useState } from 'react'; -import nebulaPic from "public/android-chrome-192x192.png" - -const Form = () => { - - const [isPopupOpen, setIsPopupOpen] = useState(false); - const [showForm, setShowForm] = useState(true); - - const handlePopup = () => { - setIsPopupOpen(!isPopupOpen); - } - const handleShowForm = () => { - setShowForm(!showForm); - } - - const handleRangeChange: FormEventHandler = (event) => { - const inputValue = event.currentTarget.value; - document.getElementById('num')!.textContent = inputValue; - } - - const { register, handleSubmit} = useForm>({ - resolver: zodResolver(feedbackFormSchema) - }); - - const createForm = api.form.sendForm.useMutation() - - const submitForm = handleSubmit(( data ) => { - if (!createForm.isLoading) createForm.mutate(data); - handlePopup(); - handleShowForm(); - }) - - return ( -
- - -
- Nebula -
-

Feedback

- -

- On a scale of 1-10, how would you rate your experience with Jupiter? -

- - 5 - - -

- -

- What do you like about Jupiter? -

- -

- -

- What do you dislike about Jupiter? -

- - - -

- What features would you like to see in Jupiter? -

- - -

- - -
- The form has been submitted successfully! -
-
- ) - } - - -export default Form; \ No newline at end of file +import nebulaPic from 'public/android-chrome-192x192.png'; + +const Form = () => { + const [isPopupOpen, setIsPopupOpen] = useState(false); + const [showForm, setShowForm] = useState(true); + + const handlePopup = () => { + setIsPopupOpen(!isPopupOpen); + }; + const handleShowForm = () => { + setShowForm(!showForm); + }; + + const handleRangeChange: FormEventHandler = (event) => { + const inputValue = event.currentTarget.value; + document.getElementById('num')!.textContent = inputValue; + }; + + const { register, handleSubmit } = useForm< + z.infer + >({ + resolver: zodResolver(feedbackFormSchema), + }); + + const createForm = api.form.sendForm.useMutation(); + + const submitForm = handleSubmit((data) => { + if (!createForm.isPending) createForm.mutate(data); + handlePopup(); + handleShowForm(); + }); + + return ( +
+ +
+
+ Nebula +
+

Feedback

+ +

+ On a scale of 1-10, how would you rate your experience with Jupiter? +

+ + + 5 + + +

+ +

+ What do you like about Jupiter? +

+ +

+ +

+ What do you dislike about Jupiter? +

+ + + +

+ What features would you like to see in Jupiter? +

+ + +

+ +
+
+ The form has been submitted successfully! +
+
+ ); +}; + +export default Form; diff --git a/src/app/feedback/FormPopUp.tsx b/src/app/feedback/FormPopUp.tsx index 44040b46..6b882ac8 100644 --- a/src/app/feedback/FormPopUp.tsx +++ b/src/app/feedback/FormPopUp.tsx @@ -43,4 +43,3 @@ const FormPopUp: React.FC = ({ onClose, isOpen }) => { }; export default FormPopUp; - diff --git a/src/app/feedback/page.tsx b/src/app/feedback/page.tsx index 62a9e111..38feaa5d 100644 --- a/src/app/feedback/page.tsx +++ b/src/app/feedback/page.tsx @@ -1,8 +1,7 @@ import React from 'react'; import Header from '@src/components/BaseHeader'; import { type Metadata } from 'next'; -import Form from '@src/app/feedback/Form'; - +import Form from '@src/app/feedback/Form'; export const metadata: Metadata = { title: 'Feedback - Jupiter', @@ -16,15 +15,13 @@ export const metadata: Metadata = { }, }; - const Feedback = () => { - return (
-
-
+
+
diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 62ddf2ca..0d2c40ec 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -9,7 +9,7 @@ import { type Metadata } from 'next'; const inter = Inter({ subsets: ['latin'], - variable: '--font-sans', + variable: '--font-inter', }); export const metadata: Metadata = { @@ -18,7 +18,6 @@ export const metadata: Metadata = { manifest: 'site.webmanifest', description: 'A student organization portal to connect organizations on campus with interested students at UTD.', - themeColor: '#573DFF', openGraph: { title: 'Jupiter', description: @@ -31,6 +30,9 @@ export const metadata: Metadata = { site: 'jupiter.utdnebula.com', }, }; +export const viewport = { + themeColor: '#573DFF', +}; export default function RootLayout({ children, diff --git a/src/app/manage/[clubId]/(dashboard)/@events/page.tsx b/src/app/manage/[clubId]/(dashboard)/@events/page.tsx index dd92a90c..2635ea7d 100644 --- a/src/app/manage/[clubId]/(dashboard)/@events/page.tsx +++ b/src/app/manage/[clubId]/(dashboard)/@events/page.tsx @@ -5,7 +5,7 @@ import { format, isSameDay } from 'date-fns'; import { MoreIcon } from '@src/icons/Icons'; const Events = async ({ params }: { params: { clubId: string } }) => { - const events = await api.event.byClubId.query({ clubId: params.clubId }); + const events = await api.event.byClubId({ clubId: params.clubId }); return (

Events

diff --git a/src/app/manage/[clubId]/(dashboard)/layout.tsx b/src/app/manage/[clubId]/(dashboard)/layout.tsx index 082e7464..6879ec2b 100644 --- a/src/app/manage/[clubId]/(dashboard)/layout.tsx +++ b/src/app/manage/[clubId]/(dashboard)/layout.tsx @@ -2,6 +2,7 @@ import Header from '@src/components/BaseHeader'; import BackButton from '@src/components/BlueBackButton'; import { getServerAuthSession } from '@src/server/auth'; import { api } from '@src/trpc/server'; +import { signInRoute } from '@src/utils/redirect'; import { notFound, redirect } from 'next/navigation'; import { type ReactNode } from 'react'; @@ -15,12 +16,12 @@ const Layout = async ({ events: ReactNode; }) => { const session = await getServerAuthSession(); - if (!session) redirect('/auth'); - const canAccess = await api.club.isOfficer.query({ id: params.clubId }); + if (!session) redirect(signInRoute(`manage/${params.clubId}`)); + const canAccess = await api.club.isOfficer({ id: params.clubId }); if (!canAccess) { return
You can't access this 😢
; } - const club = await api.club.byId.query({ id: params.clubId }); + const club = await api.club.byId({ id: params.clubId }); if (!club) { notFound(); } diff --git a/src/app/manage/[clubId]/(dashboard)/page.tsx b/src/app/manage/[clubId]/(dashboard)/page.tsx index cb83584d..d2de5b39 100644 --- a/src/app/manage/[clubId]/(dashboard)/page.tsx +++ b/src/app/manage/[clubId]/(dashboard)/page.tsx @@ -19,6 +19,12 @@ const Page = ({ params }: { params: { clubId: string } }) => { + + Create Event +
); diff --git a/src/app/manage/[clubId]/create/CreateEventForm.tsx b/src/app/manage/[clubId]/create/CreateEventForm.tsx new file mode 100644 index 00000000..70168b22 --- /dev/null +++ b/src/app/manage/[clubId]/create/CreateEventForm.tsx @@ -0,0 +1,130 @@ +'use client' + +import { useEffect, useState } from "react"; +import { type SelectClub } from "@src/server/db/models"; +import { createEventSchema } from "@src/utils/formSchemas"; +import { useForm } from "react-hook-form"; +import { api } from "@src/trpc/react"; +import { type z } from "zod"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useRouter } from "next/navigation"; +import { UploadIcon } from "@src/icons/Icons"; +import EventCardPreview from "./EventCardPreview"; +import TimeSelect from "./TimeSelect"; +import { type RouterOutputs } from "@src/trpc/shared"; + +const CreateEventForm = ({ clubId, officerClubs }: { clubId: string, officerClubs: SelectClub[]}) => { + const { + register, + handleSubmit, + watch, + setValue, + getValues, + } = useForm>({ + resolver: zodResolver(createEventSchema), + defaultValues: { + clubId: clubId, + }, + mode: "onSubmit", + }); + const router = useRouter(); + const [watchDescription, watchStartTime] = watch(['description', 'startTime']); + const [eventPreview, setEventPreview] = useState({ + name: "", + clubId, + description: "", + location: "", + liked: false, + id: "", + startTime: new Date(Date.now()), + endTime: new Date(Date.now()), + club: officerClubs.filter((v) => v.id == clubId)[0]!, + }); + useEffect(() => { + const subscription = watch((data, info) => { + const { name, clubId, description, location, startTime, endTime } = data; + const club = officerClubs.find((val) => val.id == data.clubId); + if (club) { + setEventPreview({ + name: name || "", + clubId: clubId || "", + description: description || "", + location: location || "", + liked: false, + id: "", + startTime: startTime?.toString() === "" || startTime == undefined ? new Date(Date.now()) : new Date(startTime), + endTime: endTime?.toString() === "" || endTime?.toString() == "Invalid Date" || !endTime ? new Date(Date.now()) : new Date(endTime), + club, + }); + } + if (info.name == "clubId") { + router.replace(`/manage/${data.clubId}/create`); + } + }); + return () => subscription.unsubscribe(); + }, [router, watch, officerClubs]); + + const createMutation = api.event.create.useMutation({ + onSuccess: () => { location.reload(); } + }) + + const onSubmit = handleSubmit((data: z.infer) => { + if (!createMutation.isPending) { + createMutation.mutate(data); + } + }); + + return ( void onSubmit(e)} className="w-full flex flex-row flex-wrap justify-start gap-10 overflow-x-clip text-[#4D5E80] pb-4"> +
+
+ Create Club Event for +
+ +
+
+
+

Event Picture

+

Drag or choose file to upload

+
+ +

JPEG, PNG, or SVG

+
+
+
+

Event Details

+
+ + +
+
+ + +
+
+
+ +

{watchDescription && watchDescription.length} of 1000 Characters used

+
+