From 618b7d0b59395cb83897fd1543e713728fca7333 Mon Sep 17 00:00:00 2001 From: brunosllz Date: Thu, 19 Oct 2023 02:55:36 -0300 Subject: [PATCH] refactor: change next auth implementation and remove notification count api route --- package-lock.json | 280 ++++++++++++++++++++++- package.json | 1 + src/app/(app)/layout.tsx | 4 +- src/app/(app)/me/[slug]/page.tsx | 81 ++++--- src/app/(app)/me/project/new/page.tsx | 2 +- src/app/(app)/notifications/page.tsx | 23 +- src/app/api/auth/[...nextauth]/route.ts | 5 +- src/app/api/notifications/count/route.ts | 19 -- src/app/globals.css | 2 +- src/components/file-input.tsx | 26 ++- src/components/ui/dialog.tsx | 2 +- src/components/ui/select.tsx | 2 +- src/components/ui/toast.tsx | 4 +- src/env.ts | 1 + 14 files changed, 381 insertions(+), 71 deletions(-) delete mode 100644 src/app/api/notifications/count/route.ts diff --git a/package-lock.json b/package-lock.json index ec2a9a8..de8dfca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -64,6 +64,7 @@ "next-auth": "^4.23.1", "nookies": "^2.5.2", "react": "18.2.0", + "react-confetti-explosion": "^2.1.2", "react-day-picker": "^8.8.1", "react-dom": "18.2.0", "react-dropzone": "^14.2.3", @@ -1369,6 +1370,19 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@emotion/is-prop-valid": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.7.3.tgz", + "integrity": "sha512-uxJqm/sqwXw3YPA5GXX365OBcJGFtxUVkB6WyezqFHlNe9jqUWH5ur2O2M8dGBz61kn1g3ZBlzUunFQXQIClhA==", + "dependencies": { + "@emotion/memoize": "0.7.1" + } + }, + "node_modules/@emotion/memoize": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.1.tgz", + "integrity": "sha512-Qv4LTqO11jepd5Qmlp3M1YEjBumoTHcHFdgPTQ+sFlIL5myi/7xu/POwP7IRu6odBdmLXdtIs1D6TuW6kbwbbg==" + }, "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", @@ -5871,6 +5885,25 @@ "node": ">= 8" } }, + "node_modules/css-jss": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/css-jss/-/css-jss-10.10.0.tgz", + "integrity": "sha512-YyMIS/LsSKEGXEaVJdjonWe18p4vXLo8CMA4FrW/kcaEyqdIGKCFXao31gbJddXEdIxSXFFURWrenBJPlKTgAA==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "^10.10.0", + "jss-preset-default": "^10.10.0" + } + }, + "node_modules/css-vendor": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/css-vendor/-/css-vendor-2.0.8.tgz", + "integrity": "sha512-x9Aq0XTInxrkuFeHKbYC7zWY8ai7qJ04Kxd9MnvbC1uO5DagxoHQjm4JvG+vCdXOoFtCjbL2XSZfxmoYa9uQVQ==", + "dependencies": { + "@babel/runtime": "^7.8.3", + "is-in-browser": "^1.0.2" + } + }, "node_modules/cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", @@ -7761,6 +7794,14 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "dependencies": { + "react-is": "^16.7.0" + } + }, "node_modules/hosted-git-info": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", @@ -7833,6 +7874,11 @@ "url": "https://github.com/sponsors/typicode" } }, + "node_modules/hyphenate-style-name": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz", + "integrity": "sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==" + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", @@ -8158,6 +8204,11 @@ "node": ">=0.10.0" } }, + "node_modules/is-in-browser": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/is-in-browser/-/is-in-browser-1.1.3.tgz", + "integrity": "sha512-FeXIBgG/CPGd/WUxuEyvgGTEfwiG9Z4EKGxjNMRqviiIIfsmgrpnHLffEDdwUHqNva1VEW91o3xBT/m8Elgl9g==" + }, "node_modules/is-inside-container": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", @@ -8638,6 +8689,158 @@ "npm": ">=6" } }, + "node_modules/jss": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.10.0.tgz", + "integrity": "sha512-cqsOTS7jqPsPMjtKYDUpdFC0AbhYFLTcuGRqymgmdJIeQ8cH7+AgX7YSgQy79wXloZq2VvATYxUOUQEvS1V/Zw==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/jss" + } + }, + "node_modules/jss-plugin-camel-case": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-camel-case/-/jss-plugin-camel-case-10.10.0.tgz", + "integrity": "sha512-z+HETfj5IYgFxh1wJnUAU8jByI48ED+v0fuTuhKrPR+pRBYS2EDwbusU8aFOpCdYhtRc9zhN+PJ7iNE8pAWyPw==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "hyphenate-style-name": "^1.0.3", + "jss": "10.10.0" + } + }, + "node_modules/jss-plugin-compose": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-compose/-/jss-plugin-compose-10.10.0.tgz", + "integrity": "sha512-F5kgtWpI2XfZ3Z8eP78tZEYFdgTIbpA/TMuX3a8vwrNolYtN1N4qJR/Ob0LAsqIwCMLojtxN7c7Oo/+Vz6THow==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0", + "tiny-warning": "^1.0.2" + } + }, + "node_modules/jss-plugin-default-unit": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-default-unit/-/jss-plugin-default-unit-10.10.0.tgz", + "integrity": "sha512-SvpajxIECi4JDUbGLefvNckmI+c2VWmP43qnEy/0eiwzRUsafg5DVSIWSzZe4d2vFX1u9nRDP46WCFV/PXVBGQ==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0" + } + }, + "node_modules/jss-plugin-expand": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-expand/-/jss-plugin-expand-10.10.0.tgz", + "integrity": "sha512-ymT62W2OyDxBxr7A6JR87vVX9vTq2ep5jZLIdUSusfBIEENLdkkc0lL/Xaq8W9s3opUq7R0sZQpzRWELrfVYzA==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0" + } + }, + "node_modules/jss-plugin-extend": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-extend/-/jss-plugin-extend-10.10.0.tgz", + "integrity": "sha512-sKYrcMfr4xxigmIwqTjxNcHwXJIfvhvjTNxF+Tbc1NmNdyspGW47Ey6sGH8BcQ4FFQhLXctpWCQSpDwdNmXSwg==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0", + "tiny-warning": "^1.0.2" + } + }, + "node_modules/jss-plugin-global": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-global/-/jss-plugin-global-10.10.0.tgz", + "integrity": "sha512-icXEYbMufiNuWfuazLeN+BNJO16Ge88OcXU5ZDC2vLqElmMybA31Wi7lZ3lf+vgufRocvPj8443irhYRgWxP+A==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0" + } + }, + "node_modules/jss-plugin-nested": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-nested/-/jss-plugin-nested-10.10.0.tgz", + "integrity": "sha512-9R4JHxxGgiZhurDo3q7LdIiDEgtA1bTGzAbhSPyIOWb7ZubrjQe8acwhEQ6OEKydzpl8XHMtTnEwHXCARLYqYA==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0", + "tiny-warning": "^1.0.2" + } + }, + "node_modules/jss-plugin-props-sort": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-props-sort/-/jss-plugin-props-sort-10.10.0.tgz", + "integrity": "sha512-5VNJvQJbnq/vRfje6uZLe/FyaOpzP/IH1LP+0fr88QamVrGJa0hpRRyAa0ea4U/3LcorJfBFVyC4yN2QC73lJg==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0" + } + }, + "node_modules/jss-plugin-rule-value-function": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-rule-value-function/-/jss-plugin-rule-value-function-10.10.0.tgz", + "integrity": "sha512-uEFJFgaCtkXeIPgki8ICw3Y7VMkL9GEan6SqmT9tqpwM+/t+hxfMUdU4wQ0MtOiMNWhwnckBV0IebrKcZM9C0g==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0", + "tiny-warning": "^1.0.2" + } + }, + "node_modules/jss-plugin-rule-value-observable": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-rule-value-observable/-/jss-plugin-rule-value-observable-10.10.0.tgz", + "integrity": "sha512-ZLMaYrR3QE+vD7nl3oNXuj79VZl9Kp8/u6A1IbTPDcuOu8b56cFdWRZNZ0vNr8jHewooEeq2doy8Oxtymr2ZPA==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0", + "symbol-observable": "^1.2.0" + } + }, + "node_modules/jss-plugin-template": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-template/-/jss-plugin-template-10.10.0.tgz", + "integrity": "sha512-ocXZBIOJOA+jISPdsgkTs8wwpK6UbsvtZK5JI7VUggTD6LWKbtoxUzadd2TpfF+lEtlhUmMsCkTRNkITdPKa6w==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0", + "tiny-warning": "^1.0.2" + } + }, + "node_modules/jss-plugin-vendor-prefixer": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-plugin-vendor-prefixer/-/jss-plugin-vendor-prefixer-10.10.0.tgz", + "integrity": "sha512-UY/41WumgjW8r1qMCO8l1ARg7NHnfRVWRhZ2E2m0DMYsr2DD91qIXLyNhiX83hHswR7Wm4D+oDYNC1zWCJWtqg==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "css-vendor": "^2.0.8", + "jss": "10.10.0" + } + }, + "node_modules/jss-preset-default": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/jss-preset-default/-/jss-preset-default-10.10.0.tgz", + "integrity": "sha512-GL175Wt2FGhjE+f+Y3aWh+JioL06/QWFgZp53CbNNq6ZkVU0TDplD8Bxm9KnkotAYn3FlplNqoW5CjyLXcoJ7Q==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "jss": "10.10.0", + "jss-plugin-camel-case": "10.10.0", + "jss-plugin-compose": "10.10.0", + "jss-plugin-default-unit": "10.10.0", + "jss-plugin-expand": "10.10.0", + "jss-plugin-extend": "10.10.0", + "jss-plugin-global": "10.10.0", + "jss-plugin-nested": "10.10.0", + "jss-plugin-props-sort": "10.10.0", + "jss-plugin-rule-value-function": "10.10.0", + "jss-plugin-rule-value-observable": "10.10.0", + "jss-plugin-template": "10.10.0", + "jss-plugin-vendor-prefixer": "10.10.0" + } + }, "node_modules/jsx-ast-utils": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", @@ -8765,8 +8968,7 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "node_modules/lodash.camelcase": { "version": "4.3.0", @@ -10748,6 +10950,19 @@ "node": ">=0.10.0" } }, + "node_modules/react-confetti-explosion": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/react-confetti-explosion/-/react-confetti-explosion-2.1.2.tgz", + "integrity": "sha512-4UzDFBajAGXmF9TSJoRMO2QOBCIXc66idTxH8l7Mkul48HLGtk+tMzK9HYDYsy7Zmw5sEGchi2fbn4AJUuLrZw==", + "dependencies": { + "lodash": "^4.17.21", + "react-jss": "^10.9.2" + }, + "peerDependencies": { + "react": "^18.x", + "react-dom": "^18.x" + } + }, "node_modules/react-day-picker": { "version": "8.8.1", "resolved": "https://registry.npmjs.org/react-day-picker/-/react-day-picker-8.8.1.tgz", @@ -10761,6 +10976,11 @@ "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, + "node_modules/react-display-name": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/react-display-name/-/react-display-name-0.2.5.tgz", + "integrity": "sha512-I+vcaK9t4+kypiSgaiVWAipqHRXYmZIuAiS8vzFvXHHXVigg/sMKwlRgLy6LH2i3rmP+0Vzfl5lFsFRwF1r3pg==" + }, "node_modules/react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", @@ -10817,6 +11037,27 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/react-jss": { + "version": "10.10.0", + "resolved": "https://registry.npmjs.org/react-jss/-/react-jss-10.10.0.tgz", + "integrity": "sha512-WLiq84UYWqNBF6579/uprcIUnM1TSywYq6AIjKTTTG5ziJl9Uy+pwuvpN3apuyVwflMbD60PraeTKT7uWH9XEQ==", + "dependencies": { + "@babel/runtime": "^7.3.1", + "@emotion/is-prop-valid": "^0.7.3", + "css-jss": "10.10.0", + "hoist-non-react-statics": "^3.2.0", + "is-in-browser": "^1.1.3", + "jss": "10.10.0", + "jss-preset-default": "10.10.0", + "prop-types": "^15.6.0", + "shallow-equal": "^1.2.0", + "theming": "^3.3.0", + "tiny-warning": "^1.0.2" + }, + "peerDependencies": { + "react": ">=16.8.6" + } + }, "node_modules/react-markdown": { "version": "8.0.7", "resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-8.0.7.tgz", @@ -11422,6 +11663,11 @@ "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz", "integrity": "sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==" }, + "node_modules/shallow-equal": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/shallow-equal/-/shallow-equal-1.2.1.tgz", + "integrity": "sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA==" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -11808,6 +12054,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/symbol-observable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -11952,6 +12206,23 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, + "node_modules/theming": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/theming/-/theming-3.3.0.tgz", + "integrity": "sha512-u6l4qTJRDaWZsqa8JugaNt7Xd8PPl9+gonZaIe28vAhqgHMIG/DOyFPqiKN/gQLQYj05tHv+YQdNILL4zoiAVA==", + "dependencies": { + "hoist-non-react-statics": "^3.3.0", + "prop-types": "^15.5.8", + "react-display-name": "^0.2.4", + "tiny-warning": "^1.0.2" + }, + "engines": { + "node": ">=8" + }, + "peerDependencies": { + "react": ">=16.3" + } + }, "node_modules/thenify": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", @@ -11994,6 +12265,11 @@ "readable-stream": "3" } }, + "node_modules/tiny-warning": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz", + "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" + }, "node_modules/tippy.js": { "version": "6.3.7", "resolved": "https://registry.npmjs.org/tippy.js/-/tippy.js-6.3.7.tgz", diff --git a/package.json b/package.json index 623533c..8155023 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "next-auth": "^4.23.1", "nookies": "^2.5.2", "react": "18.2.0", + "react-confetti-explosion": "^2.1.2", "react-day-picker": "^8.8.1", "react-dom": "18.2.0", "react-dropzone": "^14.2.3", diff --git a/src/app/(app)/layout.tsx b/src/app/(app)/layout.tsx index 02cd847..7ce353f 100644 --- a/src/app/(app)/layout.tsx +++ b/src/app/(app)/layout.tsx @@ -4,10 +4,10 @@ import { ReactNode } from 'react' export default function AppLayout({ children }: { children: ReactNode }) { return ( -
+ <>
{children}
-
+ ) } diff --git a/src/app/(app)/me/[slug]/page.tsx b/src/app/(app)/me/[slug]/page.tsx index db290ad..9235e37 100644 --- a/src/app/(app)/me/[slug]/page.tsx +++ b/src/app/(app)/me/[slug]/page.tsx @@ -1,8 +1,15 @@ +import { redirect } from 'next/navigation' +import { prisma } from '@/libs/prisma' +import Link from 'next/link' + import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Card, CardContent, CardFooter, CardHeader } from '@/components/ui/card' import { Separator } from '@/components/ui/separator' +import { AvatarGroupAnimated } from './components/avatar-group-animated' +import { AvatarGroup } from '@/components/avatar-group' + import { Github, Linkedin, @@ -11,11 +18,29 @@ import { MoreHorizontal, Star, } from 'lucide-react' -import Link from 'next/link' -import { AvatarGroupAnimated } from './components/avatar-group-animated' -import { AvatarGroup } from '@/components/avatar-group' -export default function Me() { +interface MeProps { + params: { + slug: string + } +} +async function getUser({ slug }: { slug: string }) { + const user = await prisma.user.findUnique({ + where: { + slugProfile: slug, + }, + }) + + if (!user) { + return redirect('/') + } + + return { user } +} + +export default async function Me({ params }: MeProps) { + const { user } = await getUser({ slug: params.slug }) + return (
@@ -28,7 +53,7 @@ export default function Me() {
- +
@@ -66,27 +91,31 @@ export default function Me() {
- - - + {user.linkedinLink && ( + + )} + + {user.githubLink && ( + + )}
diff --git a/src/app/(app)/me/project/new/page.tsx b/src/app/(app)/me/project/new/page.tsx index 807a55c..a3bec66 100644 --- a/src/app/(app)/me/project/new/page.tsx +++ b/src/app/(app)/me/project/new/page.tsx @@ -13,7 +13,7 @@ export const metadata: Metadata = { export default function NewProject() { return ( -
+

New project

diff --git a/src/app/(app)/notifications/page.tsx b/src/app/(app)/notifications/page.tsx index 1b4f3d8..a5d6483 100644 --- a/src/app/(app)/notifications/page.tsx +++ b/src/app/(app)/notifications/page.tsx @@ -1,11 +1,28 @@ import { Separator } from '@/components/ui/separator' import { NotificationList } from './components/notification-list' -import { api } from '@/libs/axios' import { redirect } from 'next/navigation' +import { prisma } from '@/libs/prisma' +import { getServerSession } from 'next-auth' +import { authOptions } from '@/app/api/auth/[...nextauth]/route' + +async function verifyIfHasAvailableNotifications() { + const session = await getServerSession(authOptions) + + if (session) { + const countNotificationsFromUser = await prisma.notification.count({ + where: { + authorId: session.user.uId, + }, + }) + + return countNotificationsFromUser + } + + return 0 +} export default async function Notifications() { - const { data } = await api.get('/notifications/count') - const { count } = data + const count = await verifyIfHasAvailableNotifications() const hasNotifications = count > 0 diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts index 9721294..14c816a 100644 --- a/src/app/api/auth/[...nextauth]/route.ts +++ b/src/app/api/auth/[...nextauth]/route.ts @@ -7,7 +7,7 @@ import { Adapter } from 'next-auth/adapters' import { CustomPrismaAdapter } from '@/libs/next-auth/prisma-adapter' import { env } from '@/env' -export const handler: NextAuthOptions = NextAuth({ +export const authOptions: NextAuthOptions = { adapter: CustomPrismaAdapter(prisma) as Adapter, providers: [ GitHubProvider({ @@ -64,6 +64,7 @@ export const handler: NextAuthOptions = NextAuth({ signIn: '/auth/sign-in', error: '/auth/error', }, -}) +} +const handler = NextAuth(authOptions) export { handler as GET, handler as POST } diff --git a/src/app/api/notifications/count/route.ts b/src/app/api/notifications/count/route.ts deleted file mode 100644 index 9c6154a..0000000 --- a/src/app/api/notifications/count/route.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { prisma } from '@/libs/prisma' -import { getToken } from 'next-auth/jwt' -import { NextRequest, NextResponse } from 'next/server' - -export async function GET(request: NextRequest) { - const token = await getToken({ req: request }) - - try { - const countNotificationsFromUser = await prisma.notification.count({ - where: { - authorId: token?.sub, - }, - }) - - return NextResponse.json({ count: countNotificationsFromUser }) - } catch (err) { - console.log(err) - } -} diff --git a/src/app/globals.css b/src/app/globals.css index 3458059..63b4052 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -8,7 +8,7 @@ } body { - @apply bg-background text-foreground min-w-full; + @apply bg-background text-foreground min-w-full min-h-screen; } :root { diff --git a/src/components/file-input.tsx b/src/components/file-input.tsx index 28eb3b0..db1f736 100644 --- a/src/components/file-input.tsx +++ b/src/components/file-input.tsx @@ -3,9 +3,9 @@ import { HTMLAttributes, createContext, - useContext, + // useContext, useId, - ChangeEvent, + // ChangeEvent, InputHTMLAttributes, forwardRef, ReactNode, @@ -27,7 +27,7 @@ interface FileInputContextType { const FileInputContext = createContext({} as FileInputContextType) -const useFileInput = () => useContext(FileInputContext) +// const useFileInput = () => useContext(FileInputContext) function FileInputRoot({ id, ...props }: RootProps) { const customId = useId() @@ -44,12 +44,18 @@ function FileInputRoot({ id, ...props }: RootProps) { } interface FileInputControlProps extends InputHTMLAttributes { - uploadPrefix?: 'projects' | 'avatar' + // uploadPrefix?: 'projects' | 'avatar' onValueChange?: ChangeHandler } const FileInputControl = forwardRef( - ({ uploadPrefix = 'projects', ...props }, ref) => { + ( + { + // uploadPrefix = 'projects', + ...props + }, + ref, + ) => { /** * we using dropzone for control this input */ @@ -91,17 +97,15 @@ function FileInputImagePreview() { if (previewUrl === null) { return ( -
+
) } else { return ( - +
+ +
) } } diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index 3d8f92c..899f81d 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -47,7 +47,7 @@ const DialogContent = React.forwardRef< {...props} > {children} - + Close diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx index e921474..19205d5 100644 --- a/src/components/ui/select.tsx +++ b/src/components/ui/select.tsx @@ -80,7 +80,7 @@ const SelectItem = React.forwardRef< ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (value: any) => { if (env === process.env.NODE_ENV && !value) { return false