From 3720a5a2fccdeea672bfbf1852b0fc230b77e9c4 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 29 Sep 2023 19:18:44 -0700 Subject: [PATCH] Fix CSS. Updated pages. --- next-env.d.ts | 1 + next.config.js | 3 +++ package.json | 2 +- src/app/(app)/console/TestConsole.js | 1 + src/app/(app)/layout.module.css | 1 - src/app/layout.tsx | 14 +++++------ src/app/logout/Logout.js | 32 +++++++++++++++++++++++++ src/app/logout/page.tsx | 35 +++------------------------- src/app/share/[...id]/Share.js | 13 +++++++++++ src/app/share/[...id]/page.tsx | 16 ++++--------- src/styles/variables.css | 2 +- yarn.lock | 22 ++++------------- 12 files changed, 71 insertions(+), 71 deletions(-) create mode 100644 src/app/logout/Logout.js create mode 100644 src/app/share/[...id]/Share.js diff --git a/next-env.d.ts b/next-env.d.ts index 4f11a03d..fd36f949 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/next.config.js b/next.config.js index 2ef1c05e..cf7dce7f 100644 --- a/next.config.js +++ b/next.config.js @@ -78,6 +78,7 @@ const basePath = process.env.BASE_PATH; /** @type {import('next').NextConfig} */ const config = { + reactStrictMode: false, env: { basePath: basePath || '', cloudMode: !!process.env.CLOUD_MODE, @@ -85,6 +86,8 @@ const config = { configUrl: '/config', currentVersion: pkg.version, defaultLocale: process.env.DEFAULT_LOCALE, + disableLogin: process.env.DISABLE_LOGIN, + disableUI: process.env.DISABLE_UI, isProduction: process.env.NODE_ENV === 'production', }, basePath, diff --git a/package.json b/package.json index 5b005f66..bb769cbc 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "dependencies": { "@fontsource/inter": "^4.5.15", "@prisma/client": "5.3.1", + "@react-spring/web": "^9.7.3", "@tanstack/react-query": "^4.33.0", "@umami/prisma-client": "^0.3.0", "@umami/redis-client": "^0.15.0", @@ -102,7 +103,6 @@ "react-error-boundary": "^4.0.4", "react-intl": "^6.4.7", "react-simple-maps": "^2.3.0", - "react-spring": "^9.4.4", "react-use-measure": "^2.0.4", "react-window": "^1.8.6", "request-ip": "^3.3.0", diff --git a/src/app/(app)/console/TestConsole.js b/src/app/(app)/console/TestConsole.js index d8060651..ca7ffc4a 100644 --- a/src/app/(app)/console/TestConsole.js +++ b/src/app/(app)/console/TestConsole.js @@ -1,3 +1,4 @@ +'use client'; import WebsiteSelect from 'components/input/WebsiteSelect'; import Page from 'components/layout/Page'; import PageHeader from 'components/layout/PageHeader'; diff --git a/src/app/(app)/layout.module.css b/src/app/(app)/layout.module.css index bcce963f..0afd11f9 100644 --- a/src/app/(app)/layout.module.css +++ b/src/app/(app)/layout.module.css @@ -10,7 +10,6 @@ width: 100vw; grid-column: 1; grid-row: 1 / 2; - z-index: var(--z-index-popup); } .body { diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 5858239e..e2478a95 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -4,20 +4,20 @@ import '@fontsource/inter/400.css'; import '@fontsource/inter/700.css'; import '@fontsource/inter/800.css'; import 'react-basics/dist/styles.css'; -import 'styles/variables.css'; import 'styles/locale.css'; import 'styles/index.css'; +import 'styles/variables.css'; export default function RootLayout({ children }) { return ( - - - - - - + + + + + + diff --git a/src/app/logout/Logout.js b/src/app/logout/Logout.js new file mode 100644 index 00000000..e9da0373 --- /dev/null +++ b/src/app/logout/Logout.js @@ -0,0 +1,32 @@ +'use client'; +import { useEffect } from 'react'; +import { useRouter } from 'next/navigation'; +import useApi from 'components/hooks/useApi'; +import { setUser } from 'store/app'; +import { removeClientAuthToken } from 'lib/client'; + +export function Logout() { + const disabled = !!(process.env.disableLogin || process.env.cloudMode); + const router = useRouter(); + const { post } = useApi(); + + useEffect(() => { + async function logout() { + await post('/auth/logout'); + } + + if (!disabled) { + removeClientAuthToken(); + + logout(); + + router.push('/login'); + + return () => setUser(null); + } + }, [disabled, router, post]); + + return null; +} + +export default Logout; diff --git a/src/app/logout/page.tsx b/src/app/logout/page.tsx index 74ae006d..bce24736 100644 --- a/src/app/logout/page.tsx +++ b/src/app/logout/page.tsx @@ -1,34 +1,5 @@ -'use client'; -import { useEffect } from 'react'; -import { useRouter } from 'next/router'; -import useApi from 'components/hooks/useApi'; -import { setUser } from 'store/app'; -import { removeClientAuthToken } from 'lib/client'; +import Logout from './Logout'; -async function getDisabled() { - return !!(process.env.DISABLE_LOGIN || process.env.CLOUD_MODE); -} - -export default async function LogoutPage() { - const disabled = await getDisabled(); - const router = useRouter(); - const { post } = useApi(); - - useEffect(() => { - async function logout() { - await post('/auth/logout'); - } - - if (!disabled) { - removeClientAuthToken(); - - logout(); - - router.push('/login'); - - return () => setUser(null); - } - }, [disabled, router, post]); - - return null; +export default function () { + return ; } diff --git a/src/app/share/[...id]/Share.js b/src/app/share/[...id]/Share.js new file mode 100644 index 00000000..69d76178 --- /dev/null +++ b/src/app/share/[...id]/Share.js @@ -0,0 +1,13 @@ +'use client'; +import WebsiteDetails from 'app/(app)/websites/[id]/WebsiteDetails'; +import useShareToken from 'components/hooks/useShareToken'; + +export default function ({ shareId }) { + const shareToken = useShareToken(shareId); + + if (!shareToken) { + return null; + } + + return ; +} diff --git a/src/app/share/[...id]/page.tsx b/src/app/share/[...id]/page.tsx index 1c17255c..736abe7d 100644 --- a/src/app/share/[...id]/page.tsx +++ b/src/app/share/[...id]/page.tsx @@ -1,17 +1,9 @@ -import Page from 'components/layout/Page'; -import WebsiteDetails from 'app/(app)/websites/[id]/WebsiteDetails'; -import useShareToken from 'components/hooks/useShareToken'; +import Share from './Share'; -export default function SharePage({ params }) { - const shareToken = useShareToken(params.id); - - if (!shareToken) { +export default function ({ params: { id } }) { + if (!id) { return null; } - return ( - - - - ); + return ; } diff --git a/src/styles/variables.css b/src/styles/variables.css index 726195d2..686fac84 100644 --- a/src/styles/variables.css +++ b/src/styles/variables.css @@ -1,4 +1,4 @@ -:root { +html body { --primary400: var(--blue800); --primary500: var(--blue900); --primary600: var(--blue1000); diff --git a/yarn.lock b/yarn.lock index e6c2c6c1..0eef7e9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2024,7 +2024,7 @@ "@react-spring/shared" "~9.7.3" "@react-spring/types" "~9.7.3" -"@react-spring/konva@~9.7.1", "@react-spring/konva@~9.7.3": +"@react-spring/konva@~9.7.1": version "9.7.3" resolved "https://registry.yarnpkg.com/@react-spring/konva/-/konva-9.7.3.tgz#16bd29dd4860a99e960a72987c8bcfc828b22119" integrity sha512-R9sY6SiPGYqz1383P5qppg5z57YfChVknOC1UxxaGxpw+WiZa8fZ4zmZobslrw+os3/+HAXZv8O+EvU/nQpf7g== @@ -2034,7 +2034,7 @@ "@react-spring/shared" "~9.7.3" "@react-spring/types" "~9.7.3" -"@react-spring/native@~9.7.1", "@react-spring/native@~9.7.3": +"@react-spring/native@~9.7.1": version "9.7.3" resolved "https://registry.yarnpkg.com/@react-spring/native/-/native-9.7.3.tgz#ee38d7c23482cfb4916c9b3c021de2995a4f553a" integrity sha512-4mpxX3FuEBCUT6ae2fjhxcJW6bhr2FBwFf274eXB7n+U30Gdg8Wo2qYwcUnmiAA0S3dvP8vLTazx3+CYWFShnA== @@ -2051,7 +2051,7 @@ dependencies: "@react-spring/types" "~9.7.3" -"@react-spring/three@~9.7.1", "@react-spring/three@~9.7.3": +"@react-spring/three@~9.7.1": version "9.7.3" resolved "https://registry.yarnpkg.com/@react-spring/three/-/three-9.7.3.tgz#4358a0c4640efe2972c4f7d0f7cd4efe927471c1" integrity sha512-Q1p512CqUlmMK8UMBF/Rj79qndhOWq4XUTayxMP9S892jiXzWQuj+xC3Xvm59DP/D4JXusXpxxqfgoH+hmOktA== @@ -2066,7 +2066,7 @@ resolved "https://registry.yarnpkg.com/@react-spring/types/-/types-9.7.3.tgz#ea78fd447cbc2612c1f5d55852e3c331e8172a0b" integrity sha512-Kpx/fQ/ZFX31OtlqVEFfgaD1ACzul4NksrvIgYfIFq9JpDHFwQkMVZ10tbo0FU/grje4rcL4EIrjekl3kYwgWw== -"@react-spring/web@~9.7.1", "@react-spring/web@~9.7.3": +"@react-spring/web@^9.7.3", "@react-spring/web@~9.7.1": version "9.7.3" resolved "https://registry.yarnpkg.com/@react-spring/web/-/web-9.7.3.tgz#d9f4e17fec259f1d65495a19502ada4f5b57fa3d" integrity sha512-BXt6BpS9aJL/QdVqEIX9YoUy8CE6TJrU0mNCqSoxdXlIeNcEBWOfIyE6B14ENNsyQKS3wOWkiJfco0tCr/9tUg== @@ -2076,7 +2076,7 @@ "@react-spring/shared" "~9.7.3" "@react-spring/types" "~9.7.3" -"@react-spring/zdog@~9.7.1", "@react-spring/zdog@~9.7.3": +"@react-spring/zdog@~9.7.1": version "9.7.3" resolved "https://registry.yarnpkg.com/@react-spring/zdog/-/zdog-9.7.3.tgz#8ccc7316f6d3460ed244d9e3f60de9b4c4a848ac" integrity sha512-L+yK/1PvNi9n8cldiJ309k4LdxcPkeWE0W18l1zrP1IBIyd5NB5EPA8DMsGr9gtNnnIujtEzZk+4JIOjT8u/tw== @@ -7914,18 +7914,6 @@ react-simple-maps@^2.3.0: d3-zoom "^2.0.0" topojson-client "^3.1.0" -react-spring@^9.4.4: - version "9.7.3" - resolved "https://registry.yarnpkg.com/react-spring/-/react-spring-9.7.3.tgz#3211dea4c4d7c5b541260af5100261b87becb5d5" - integrity sha512-oTxDpFV5gzq7jQX6+bU0SVq+vX8VnuuT5c8Zwn6CpDErOPvCmV+DRkPiEBtaL3Ozgzwiy5yFx83N0h303j/r3A== - dependencies: - "@react-spring/core" "~9.7.3" - "@react-spring/konva" "~9.7.3" - "@react-spring/native" "~9.7.3" - "@react-spring/three" "~9.7.3" - "@react-spring/web" "~9.7.3" - "@react-spring/zdog" "~9.7.3" - react-spring@^9.5.5: version "9.7.1" resolved "https://registry.yarnpkg.com/react-spring/-/react-spring-9.7.1.tgz#8acfed700823490a4d9d4cf131c5fea12d1aaa93"