From 9b9c3c1d875969a828c562dd60b5389ad3dd8a9a Mon Sep 17 00:00:00 2001
From: Max Leiter
Date: Wed, 9 Nov 2022 18:38:05 -0800
Subject: [PATCH] start api transition, prisma additions
---
client/.env.local | 2 -
client/app/(auth)/head.tsx | 5 +
client/app/(auth)/signin/page.tsx | 5 +
client/app/(auth)/signup/page.tsx | 12 +
client/app/(posts)/new/from/[id]/page.tsx | 67 +++
client/app/(posts)/new/head.tsx | 5 +
client/app/(posts)/new/page.tsx | 10 +
client/app/layout.tsx | 7 +-
client/app/page-wrapper.tsx | 21 +
client/app/page.tsx | 17 +-
client/app/prisma.ts | 52 +++
client/app/root-layout-wrapper.tsx | 66 +++
.../admin/action-dropdown/index.tsx | 2 +-
client/components/admin/post-table.tsx | 2 +-
client/components/admin/user-table.tsx | 2 +-
client/components/app/index.tsx | 2 +-
client/components/auth/index.tsx | 39 +-
.../badges/created-ago-badge/index.tsx | 2 +-
.../badges/expiration-badge/index.tsx | 2 +-
.../badges/visibility-badge/index.tsx | 2 +-
.../badges/visibility-control/index.tsx | 2 +-
.../edit-document/formatting-icons/index.tsx | 2 +-
client/components/edit-document/index.tsx | 2 +-
client/components/error/index.tsx | 2 +-
client/components/file-dropdown/index.tsx | 2 +-
client/components/header/controls.tsx | 2 +-
client/components/header/index.tsx | 35 +-
client/components/home/index.tsx | 2 +-
client/components/link/index.tsx | 11 +-
.../components/new-post/description/index.tsx | 6 +-
.../new-post/drag-and-drop/index.tsx | 2 +-
client/components/new-post/index.tsx | 87 ++--
.../new-post/password-modal/index.tsx | 2 +-
client/components/new-post/title/index.tsx | 4 +-
client/components/note/note.module.css | 2 +-
client/components/page-seo/index.tsx | 7 +-
client/components/post-list/index.tsx | 2 +-
.../post-list/list-item-skeleton.tsx | 2 +-
client/components/post-list/list-item.tsx | 2 +-
client/components/post-page/index.tsx | 2 +-
.../post-page/password-modal-wrapper.tsx | 2 +-
client/components/preview/index.tsx | 17 +-
client/components/scroll-to-top/index.tsx | 2 +-
client/components/settings-group/index.tsx | 2 +-
.../components/settings/sections/password.tsx | 2 +-
.../components/settings/sections/profile.tsx | 2 +-
client/components/view-document/index.tsx | 2 +-
client/lib/api/generate-access-token.ts | 27 ++
client/lib/api/get-html-from-drift-file.ts | 39 ++
client/lib/api/jwt.ts | 64 +++
client/lib/api/parse-url-query.ts | 13 +
client/lib/config.ts | 89 ++++
client/lib/get-title-for-post-copy.ts | 4 +-
client/lib/hooks/use-user-data.ts | 4 +-
client/lib/render-markdown.tsx | 189 +++++++++
client/middleware.ts | 2 +-
client/package.json | 22 +-
client/pages/_document.tsx | 2 +-
client/pages/admin.tsx | 2 +-
client/pages/api/auth/backup.ts | 32 ++
client/pages/api/auth/requires-passcode.ts | 35 ++
client/pages/api/auth/signin.ts | 36 ++
client/pages/api/auth/signup.ts | 45 ++
client/pages/api/file/get-html.ts | 52 +++
client/pages/api/{ => file}/html/[id].ts | 0
client/pages/api/user/[slug].ts | 32 ++
client/pages/api/welcome.ts | 34 ++
client/pages/expired.tsx | 2 +-
client/pages/index.backup.tsx | 2 +-
client/pages/mine.tsx | 2 +-
.../pages/{new => new-backup}/from/[id].tsx | 2 +-
client/pages/{new => new-backup}/index.tsx | 2 +-
client/pages/settings.tsx | 2 +-
.../pages/{signin.tsx => signin.backup.tsx} | 2 +-
.../pages/{signup.tsx => signup.backup.tsx} | 2 +-
client/pnpm-lock.yaml | 389 +++++++++++++++++-
.../20221110002714_init/migration.sql | 73 ++++
.../migration.sql | 19 +
.../migration.sql | 28 ++
client/prisma/migrations/migration_lock.toml | 3 +
client/prisma/schema.prisma | 93 +++++
.../css => styles}/react-datepicker.css | 0
82 files changed, 1671 insertions(+), 202 deletions(-)
delete mode 100644 client/.env.local
create mode 100644 client/app/(auth)/head.tsx
create mode 100644 client/app/(auth)/signin/page.tsx
create mode 100644 client/app/(auth)/signup/page.tsx
create mode 100644 client/app/(posts)/new/from/[id]/page.tsx
create mode 100644 client/app/(posts)/new/head.tsx
create mode 100644 client/app/(posts)/new/page.tsx
create mode 100644 client/app/page-wrapper.tsx
create mode 100644 client/app/prisma.ts
create mode 100644 client/app/root-layout-wrapper.tsx
create mode 100644 client/lib/api/generate-access-token.ts
create mode 100644 client/lib/api/get-html-from-drift-file.ts
create mode 100644 client/lib/api/jwt.ts
create mode 100644 client/lib/api/parse-url-query.ts
create mode 100644 client/lib/config.ts
create mode 100644 client/lib/render-markdown.tsx
create mode 100644 client/pages/api/auth/backup.ts
create mode 100644 client/pages/api/auth/requires-passcode.ts
create mode 100644 client/pages/api/auth/signin.ts
create mode 100644 client/pages/api/auth/signup.ts
create mode 100644 client/pages/api/file/get-html.ts
rename client/pages/api/{ => file}/html/[id].ts (100%)
create mode 100644 client/pages/api/user/[slug].ts
create mode 100644 client/pages/api/welcome.ts
rename client/pages/{new => new-backup}/from/[id].tsx (97%)
rename client/pages/{new => new-backup}/index.tsx (93%)
rename client/pages/{signin.tsx => signin.backup.tsx} (88%)
rename client/pages/{signup.tsx => signup.backup.tsx} (88%)
create mode 100644 client/prisma/migrations/20221110002714_init/migration.sql
create mode 100644 client/prisma/migrations/20221110003646_auth_token_type_fixes/migration.sql
create mode 100644 client/prisma/migrations/20221110014822_file_optional_fixes/migration.sql
create mode 100644 client/prisma/migrations/migration_lock.toml
create mode 100644 client/prisma/schema.prisma
rename client/{public/css => styles}/react-datepicker.css (100%)
diff --git a/client/.env.local b/client/.env.local
deleted file mode 100644
index 1eac9b7c..00000000
--- a/client/.env.local
+++ /dev/null
@@ -1,2 +0,0 @@
-API_URL=http://localhost:3000
-SECRET_KEY=secret
diff --git a/client/app/(auth)/head.tsx b/client/app/(auth)/head.tsx
new file mode 100644
index 00000000..cea829b8
--- /dev/null
+++ b/client/app/(auth)/head.tsx
@@ -0,0 +1,5 @@
+import PageSeo from "@components/head"
+
+export default function AuthHead() {
+ return
+}
diff --git a/client/app/(auth)/signin/page.tsx b/client/app/(auth)/signin/page.tsx
new file mode 100644
index 00000000..1e9469f5
--- /dev/null
+++ b/client/app/(auth)/signin/page.tsx
@@ -0,0 +1,5 @@
+import Auth from "@components/auth"
+
+export default function SignInPage() {
+ return
+}
diff --git a/client/app/(auth)/signup/page.tsx b/client/app/(auth)/signup/page.tsx
new file mode 100644
index 00000000..af8f5e8c
--- /dev/null
+++ b/client/app/(auth)/signup/page.tsx
@@ -0,0 +1,12 @@
+import Auth from "@components/auth"
+import config from "@lib/config"
+import { getRequiresPasscode } from "pages/api/auth/requires-passcode"
+
+const getPasscode = async () => {
+ return await getRequiresPasscode()
+}
+
+export default async function SignUpPage() {
+ const requiresPasscode = await getPasscode()
+ return
+}
diff --git a/client/app/(posts)/new/from/[id]/page.tsx b/client/app/(posts)/new/from/[id]/page.tsx
new file mode 100644
index 00000000..b20974c8
--- /dev/null
+++ b/client/app/(posts)/new/from/[id]/page.tsx
@@ -0,0 +1,67 @@
+import styles from "@styles/Home.module.css"
+import NewPost from "@components/new-post"
+import PageSeo from "@components/page-seo"
+import { Page } from "@geist-ui/core/dist"
+import Head from "next/head"
+import { GetServerSideProps } from "next"
+import { Post } from "@lib/types"
+import cookie from "cookie"
+
+
+const NewFromExisting = async () => {
+ return (
+ //
+ // {/* TODO: solve this. */}
+ // {/* eslint-disable-next-line @next/next/no-css-tags */}
+ //
+ //
+
+ )
+}
+
+// export const getServerSideProps: GetServerSideProps = async ({
+// req,
+// params
+// }) => {
+// const id = params?.id
+// const redirect = {
+// redirect: {
+// destination: "/new",
+// permanent: false
+// }
+// }
+
+// if (!id) {
+// return redirect
+// }
+
+// const driftToken = cookie.parse(req.headers.cookie || "")[`drift-token`]
+
+// const post = await fetch(`${process.env.API_URL}/posts/${id}`, {
+// method: "GET",
+// headers: {
+// "Content-Type": "application/json",
+// Authorization: `Bearer ${driftToken}`,
+// "x-secret-key": process.env.SECRET_KEY || ""
+// }
+// })
+
+// if (!post.ok) {
+// return redirect
+// }
+
+// const data = await post.json()
+
+// if (!data) {
+// return redirect
+// }
+
+// return {
+// props: {
+// post: data,
+// parentId: id
+// }
+// }
+// }
+
+export default NewFromExisting
diff --git a/client/app/(posts)/new/head.tsx b/client/app/(posts)/new/head.tsx
new file mode 100644
index 00000000..8acc8e7d
--- /dev/null
+++ b/client/app/(posts)/new/head.tsx
@@ -0,0 +1,5 @@
+import PageSeo from "@components/page-seo"
+
+export default function NewPostHead() {
+ return
+}
diff --git a/client/app/(posts)/new/page.tsx b/client/app/(posts)/new/page.tsx
new file mode 100644
index 00000000..ed68e74f
--- /dev/null
+++ b/client/app/(posts)/new/page.tsx
@@ -0,0 +1,10 @@
+import NewPost from "@components/new-post"
+import '@styles/react-datepicker.css'
+
+const New = () => {
+ return (
+
+ )
+}
+
+export default New
diff --git a/client/app/layout.tsx b/client/app/layout.tsx
index 78994a13..8bc39b88 100644
--- a/client/app/layout.tsx
+++ b/client/app/layout.tsx
@@ -1,5 +1,6 @@
-import "styles/globals.css"
+import "@styles/globals.css"
import { ServerThemeProvider } from "next-themes"
+import { LayoutWrapper } from "./root-layout-wrapper"
interface RootLayoutProps {
children: React.ReactNode
@@ -8,9 +9,9 @@ interface RootLayoutProps {
export default function RootLayout({ children }: RootLayoutProps) {
return (
@@ -48,7 +49,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
Drift
- {children}
+ {children}
)
diff --git a/client/app/page-wrapper.tsx b/client/app/page-wrapper.tsx
new file mode 100644
index 00000000..86d2f22d
--- /dev/null
+++ b/client/app/page-wrapper.tsx
@@ -0,0 +1,21 @@
+"use client"
+
+import Header from "@components/header"
+import { Page } from "@geist-ui/core/dist"
+import styles from "@styles/Home.module.css"
+
+export default function PageWrapper({
+ children
+}: {
+ children: React.ReactNode
+}) {
+ return (
+
+
+
+
+
+ {children}
+
+ )
+}
diff --git a/client/app/page.tsx b/client/app/page.tsx
index e701f3f9..56c3c4d7 100644
--- a/client/app/page.tsx
+++ b/client/app/page.tsx
@@ -1,7 +1,12 @@
-export default function Page() {
- return (
- <>
- Hello, world!
- >
- )
+import { getWelcomeContent } from "pages/api/welcome"
+
+const getWelcomeData = async () => {
+ const welcomeContent = await getWelcomeContent()
+ return welcomeContent
+}
+
+export default async function Page() {
+ const welcomeData = await getWelcomeData()
+
+ return {JSON.stringify(welcomeData)}
}
diff --git a/client/app/prisma.ts b/client/app/prisma.ts
new file mode 100644
index 00000000..9ef83abe
--- /dev/null
+++ b/client/app/prisma.ts
@@ -0,0 +1,52 @@
+import { Post, PrismaClient, File } from "@prisma/client"
+
+const prisma = new PrismaClient()
+
+export default prisma
+
+export type {
+ User,
+ AuthTokens,
+ File,
+ Post,
+ PostToAuthors
+} from "@prisma/client"
+
+export type PostWithFiles = Post & {
+ files: File[]
+}
+
+export const getFilesForPost = async (postId: string) => {
+ const files = await prisma.file.findMany({
+ where: {
+ postId
+ }
+ })
+
+ return files
+}
+
+export const getPostWithFiles = async (
+ postId: string
+): Promise => {
+ const post = await prisma.post.findUnique({
+ where: {
+ id: postId
+ }
+ })
+
+ if (!post) {
+ return undefined
+ }
+
+ const files = await getFilesForPost(postId)
+
+ if (!files) {
+ return undefined
+ }
+
+ return {
+ ...post,
+ files
+ }
+}
diff --git a/client/app/root-layout-wrapper.tsx b/client/app/root-layout-wrapper.tsx
new file mode 100644
index 00000000..bd612503
--- /dev/null
+++ b/client/app/root-layout-wrapper.tsx
@@ -0,0 +1,66 @@
+"use client"
+
+import { CssBaseline, GeistProvider, Themes } from "@geist-ui/core/dist"
+import { ThemeProvider } from "next-themes"
+import { SkeletonTheme } from "react-loading-skeleton"
+import PageWrapper from "./page-wrapper"
+
+export function LayoutWrapper({ children }: { children: React.ReactNode }) {
+ const skeletonBaseColor = "var(--light-gray)"
+ const skeletonHighlightColor = "var(--lighter-gray)"
+
+ const customTheme = Themes.createFromLight({
+ type: "custom",
+ palette: {
+ background: "var(--bg)",
+ foreground: "var(--fg)",
+ accents_1: "var(--lightest-gray)",
+ accents_2: "var(--lighter-gray)",
+ accents_3: "var(--light-gray)",
+ accents_4: "var(--gray)",
+ accents_5: "var(--darker-gray)",
+ accents_6: "var(--darker-gray)",
+ accents_7: "var(--darkest-gray)",
+ accents_8: "var(--darkest-gray)",
+ border: "var(--light-gray)",
+ warning: "var(--warning)"
+ },
+ expressiveness: {
+ dropdownBoxShadow: "0 0 0 1px var(--light-gray)",
+ shadowSmall: "0 0 0 1px var(--light-gray)",
+ shadowLarge: "0 0 0 1px var(--light-gray)",
+ shadowMedium: "0 0 0 1px var(--light-gray)"
+ },
+ layout: {
+ gap: "var(--gap)",
+ gapHalf: "var(--gap-half)",
+ gapQuarter: "var(--gap-quarter)",
+ gapNegative: "var(--gap-negative)",
+ gapHalfNegative: "var(--gap-half-negative)",
+ gapQuarterNegative: "var(--gap-quarter-negative)",
+ radius: "var(--radius)"
+ },
+ font: {
+ mono: "var(--font-mono)",
+ sans: "var(--font-sans)"
+ }
+ })
+
+ return (
+
+
+
+
+ {children}
+
+
+
+ )
+}
diff --git a/client/components/admin/action-dropdown/index.tsx b/client/components/admin/action-dropdown/index.tsx
index 41516896..11256170 100644
--- a/client/components/admin/action-dropdown/index.tsx
+++ b/client/components/admin/action-dropdown/index.tsx
@@ -1,4 +1,4 @@
-import { Popover, Button } from "@geist-ui/core"
+import { Popover, Button } from "@geist-ui/core/dist"
import { MoreVertical } from "@geist-ui/icons"
type Action = {
diff --git a/client/components/admin/post-table.tsx b/client/components/admin/post-table.tsx
index 6bbb52d1..312575bf 100644
--- a/client/components/admin/post-table.tsx
+++ b/client/components/admin/post-table.tsx
@@ -1,5 +1,5 @@
import SettingsGroup from "@components/settings-group"
-import { Fieldset, useToasts } from "@geist-ui/core"
+import { Fieldset, useToasts } from "@geist-ui/core/dist"
import byteToMB from "@lib/byte-to-mb"
import { Post } from "@lib/types"
import Table from "rc-table"
diff --git a/client/components/admin/user-table.tsx b/client/components/admin/user-table.tsx
index b931db70..61ae8d4b 100644
--- a/client/components/admin/user-table.tsx
+++ b/client/components/admin/user-table.tsx
@@ -1,4 +1,4 @@
-import { Fieldset, useToasts } from "@geist-ui/core"
+import { Fieldset, useToasts } from "@geist-ui/core/dist"
import { User } from "@lib/types"
import { useEffect, useMemo, useState } from "react"
import { adminFetcher } from "."
diff --git a/client/components/app/index.tsx b/client/components/app/index.tsx
index ab0a85a2..943ff951 100644
--- a/client/components/app/index.tsx
+++ b/client/components/app/index.tsx
@@ -1,5 +1,5 @@
import Header from "@components/header"
-import { GeistProvider, CssBaseline, Themes, Page } from "@geist-ui/core"
+import { GeistProvider, CssBaseline, Themes, Page } from "@geist-ui/core/dist"
import type { NextComponentType, NextPageContext } from "next"
import { SkeletonTheme } from "react-loading-skeleton"
diff --git a/client/components/auth/index.tsx b/client/components/auth/index.tsx
index a5e48fe7..f025c9ef 100644
--- a/client/components/auth/index.tsx
+++ b/client/components/auth/index.tsx
@@ -1,6 +1,8 @@
+"use client"
+
import { FormEvent, useEffect, useState } from "react"
import styles from "./auth.module.css"
-import { useRouter } from "next/router"
+import { useRouter } from "next/navigation"
import Link from "../link"
import Cookies from "js-cookie"
import useSignedIn from "@lib/hooks/use-signed-in"
@@ -12,32 +14,21 @@ const NO_EMPTY_SPACE_REGEX = /^\S*$/
const ERROR_MESSAGE =
"Provide a non empty username and a password with at least 6 characters"
-const Auth = ({ page }: { page: "signup" | "signin" }) => {
+const Auth = ({
+ page,
+ requiresServerPassword
+}: {
+ page: "signup" | "signin"
+ requiresServerPassword?: boolean
+}) => {
const router = useRouter()
const [username, setUsername] = useState("")
const [password, setPassword] = useState("")
const [serverPassword, setServerPassword] = useState("")
const [errorMsg, setErrorMsg] = useState("")
- const [requiresServerPassword, setRequiresServerPassword] = useState(false)
const signingIn = page === "signin"
const { signin } = useSignedIn()
- useEffect(() => {
- async function fetchRequiresPass() {
- if (!signingIn) {
- const resp = await fetch("/server-api/auth/requires-passcode", {
- method: "GET"
- })
- if (resp.ok) {
- const res = await resp.json()
- setRequiresServerPassword(res.requiresPasscode)
- } else {
- setErrorMsg("Something went wrong. Is the server running?")
- }
- }
- }
- fetchRequiresPass()
- }, [page, signingIn])
const handleJson = (json: any) => {
signin(json.token)
@@ -70,9 +61,7 @@ const Auth = ({ page }: { page: "signup" | "signin" }) => {
}
try {
- const signUrl = signingIn
- ? "/server-api/auth/signin"
- : "/server-api/auth/signup"
+ const signUrl = signingIn ? "/api/auth/signin" : "/api/auth/signup"
const resp = await fetch(signUrl, reqOpts)
const json = await resp.json()
if (!resp.ok) throw new Error(json.error.message)
@@ -141,11 +130,7 @@ const Auth = ({ page }: { page: "signup" | "signin" }) => {
)}
- {errorMsg && (
-
- {errorMsg}
-
- )}
+ {errorMsg && {errorMsg}}
diff --git a/client/components/badges/created-ago-badge/index.tsx b/client/components/badges/created-ago-badge/index.tsx
index 9b84991b..3680beef 100644
--- a/client/components/badges/created-ago-badge/index.tsx
+++ b/client/components/badges/created-ago-badge/index.tsx
@@ -1,4 +1,4 @@
-import { Badge, Tooltip } from "@geist-ui/core"
+import { Badge, Tooltip } from "@geist-ui/core/dist"
import { timeAgo } from "@lib/time-ago"
import { useMemo, useState, useEffect } from "react"
diff --git a/client/components/badges/expiration-badge/index.tsx b/client/components/badges/expiration-badge/index.tsx
index 9151d915..0326f19c 100644
--- a/client/components/badges/expiration-badge/index.tsx
+++ b/client/components/badges/expiration-badge/index.tsx
@@ -1,4 +1,4 @@
-import { Badge, Tooltip } from "@geist-ui/core"
+import { Badge, Tooltip } from "@geist-ui/core/dist"
import { timeUntil } from "@lib/time-ago"
import { useCallback, useEffect, useMemo, useState } from "react"
diff --git a/client/components/badges/visibility-badge/index.tsx b/client/components/badges/visibility-badge/index.tsx
index 0385463f..42fc899f 100644
--- a/client/components/badges/visibility-badge/index.tsx
+++ b/client/components/badges/visibility-badge/index.tsx
@@ -1,4 +1,4 @@
-import { Badge } from "@geist-ui/core"
+import { Badge } from "@geist-ui/core/dist"
import type { PostVisibility } from "@lib/types"
type Props = {
diff --git a/client/components/badges/visibility-control/index.tsx b/client/components/badges/visibility-control/index.tsx
index 2fbcd9dc..72234e9d 100644
--- a/client/components/badges/visibility-control/index.tsx
+++ b/client/components/badges/visibility-control/index.tsx
@@ -1,5 +1,5 @@
import PasswordModal from "@components/new-post/password-modal"
-import { Button, ButtonGroup, Loading, useToasts } from "@geist-ui/core"
+import { Button, ButtonGroup, Loading, useToasts } from "@geist-ui/core/dist"
import type { PostVisibility } from "@lib/types"
import Cookies from "js-cookie"
import { useCallback, useState } from "react"
diff --git a/client/components/edit-document/formatting-icons/index.tsx b/client/components/edit-document/formatting-icons/index.tsx
index b3b0a06d..26631b1b 100644
--- a/client/components/edit-document/formatting-icons/index.tsx
+++ b/client/components/edit-document/formatting-icons/index.tsx
@@ -7,7 +7,7 @@ import List from "@geist-ui/icons/list"
import ImageIcon from "@geist-ui/icons/image"
import { RefObject, useMemo } from "react"
import styles from "../document.module.css"
-import { Button, ButtonGroup, Tooltip } from "@geist-ui/core"
+import { Button, ButtonGroup, Tooltip } from "@geist-ui/core/dist"
import { TextareaMarkdownRef } from "textarea-markdown-editor"
// TODO: clean up
diff --git a/client/components/edit-document/index.tsx b/client/components/edit-document/index.tsx
index a675f17a..cdb29d69 100644
--- a/client/components/edit-document/index.tsx
+++ b/client/components/edit-document/index.tsx
@@ -11,7 +11,7 @@ import Trash from "@geist-ui/icons/trash"
import FormattingIcons from "./formatting-icons"
import TextareaMarkdown, { TextareaMarkdownRef } from "textarea-markdown-editor"
-import { Button, Input, Spacer, Tabs, Textarea } from "@geist-ui/core"
+import { Button, Input, Spacer, Tabs, Textarea } from "@geist-ui/core/dist"
import Preview from "@components/preview"
// import Link from "next/link"
diff --git a/client/components/error/index.tsx b/client/components/error/index.tsx
index 1b262243..a2b7b72e 100644
--- a/client/components/error/index.tsx
+++ b/client/components/error/index.tsx
@@ -1,4 +1,4 @@
-import { Page } from "@geist-ui/core"
+import { Page } from "@geist-ui/core/dist"
const Error = ({ status }: { status: number }) => {
return (
diff --git a/client/components/file-dropdown/index.tsx b/client/components/file-dropdown/index.tsx
index b9ef188e..e299b3e1 100644
--- a/client/components/file-dropdown/index.tsx
+++ b/client/components/file-dropdown/index.tsx
@@ -1,5 +1,5 @@
import ShiftBy from "@components/shift-by"
-import { Button, Popover } from "@geist-ui/core"
+import { Button, Popover } from "@geist-ui/core/dist"
import ChevronDown from "@geist-ui/icons/chevronDown"
import CodeIcon from "@geist-ui/icons/fileFunction"
import FileIcon from "@geist-ui/icons/fileText"
diff --git a/client/components/header/controls.tsx b/client/components/header/controls.tsx
index 49b7ff45..ba949952 100644
--- a/client/components/header/controls.tsx
+++ b/client/components/header/controls.tsx
@@ -3,7 +3,7 @@ import MoonIcon from "@geist-ui/icons/moon"
import SunIcon from "@geist-ui/icons/sun"
// import { useAllThemes, useTheme } from '@geist-ui/core'
import styles from "./header.module.css"
-import { Select } from "@geist-ui/core"
+import { Select } from "@geist-ui/core/dist"
import { useTheme } from "next-themes"
const Controls = () => {
diff --git a/client/components/header/index.tsx b/client/components/header/index.tsx
index 869d12bd..a53b954b 100644
--- a/client/components/header/index.tsx
+++ b/client/components/header/index.tsx
@@ -1,4 +1,4 @@
-'use client';
+"use client"
import {
ButtonGroup,
@@ -7,7 +7,7 @@ import {
Spacer,
useBodyScroll,
useMediaQuery
-} from "@geist-ui/core"
+} from "@geist-ui/core/dist"
import { useCallback, useEffect, useMemo, useState } from "react"
import styles from "./header.module.css"
@@ -27,7 +27,7 @@ import SunIcon from "@geist-ui/icons/sun"
import { useTheme } from "next-themes"
import useUserData from "@lib/hooks/use-user-data"
import Link from "next/link"
-import { useRouter } from "next/router"
+import { usePathname } from "next/navigation"
type Tab = {
name: string
@@ -38,7 +38,7 @@ type Tab = {
}
const Header = () => {
- const router = useRouter()
+ const pathname = usePathname()
const [expanded, setExpanded] = useState(false)
const [, setBodyHidden] = useBodyScroll(null, { scrollLayer: true })
const isMobile = useMediaQuery("xs", { match: "down" })
@@ -154,7 +154,7 @@ const Header = () => {
const getButton = useCallback(
(tab: Tab) => {
- const activeStyle = router.pathname === tab.href ? styles.active : ""
+ const activeStyle = pathname === tab.href ? styles.active : ""
if (tab.onClick) {
return (