diff --git a/client/app/(auth)/components/index.tsx b/client/app/(auth)/components/index.tsx
index dd7af02a..8bf68664 100644
--- a/client/app/(auth)/components/index.tsx
+++ b/client/app/(auth)/components/index.tsx
@@ -71,7 +71,12 @@ const Auth = ({
auto
width="100%"
icon={}
- onClick={() => signIn("github").catch((err) => setErrorMsg(err.message))}
+ onClick={(e) => {
+ e.preventDefault()
+ signIn("github", {
+ callbackUrl: "/",
+ })
+ }}
>
Sign in with GitHub
diff --git a/client/app/(auth)/signin/head.tsx b/client/app/(auth)/signin/head.tsx
index 1110d61b..6a70b7ad 100644
--- a/client/app/(auth)/signin/head.tsx
+++ b/client/app/(auth)/signin/head.tsx
@@ -1,4 +1,4 @@
-import PageSeo from "app/components/page-seo"
+import PageSeo from "@components/page-seo"
export default function AuthHead() {
return
diff --git a/client/app/(auth)/signin/page.tsx b/client/app/(auth)/signin/page.tsx
index 495eb6d2..6a21de40 100644
--- a/client/app/(auth)/signin/page.tsx
+++ b/client/app/(auth)/signin/page.tsx
@@ -1,5 +1,5 @@
import Auth from "../components"
-import Header from "app/components/header"
+import Header from "@components/header"
export default function SignInPage() {
return (
diff --git a/client/app/(auth)/signup/head.tsx b/client/app/(auth)/signup/head.tsx
index 907f08c7..17e8cac1 100644
--- a/client/app/(auth)/signup/head.tsx
+++ b/client/app/(auth)/signup/head.tsx
@@ -1,4 +1,4 @@
-import PageSeo from "app/components/page-seo"
+import PageSeo from "@components/page-seo"
export default function AuthHead() {
return
diff --git a/client/app/(auth)/signup/page.tsx b/client/app/(auth)/signup/page.tsx
index deba8ab5..cf3e8cd6 100644
--- a/client/app/(auth)/signup/page.tsx
+++ b/client/app/(auth)/signup/page.tsx
@@ -1,5 +1,5 @@
import Auth from "../components"
-import Header from "app/components/header"
+import Header from "@components/header"
import { getRequiresPasscode } from "pages/api/auth/requires-passcode"
const getPasscode = async () => {
diff --git a/client/app/(posts)/components/file-dropdown/index.tsx b/client/app/(posts)/components/file-dropdown/index.tsx
index ab0f6dc5..5ceb75ab 100644
--- a/client/app/(posts)/components/file-dropdown/index.tsx
+++ b/client/app/(posts)/components/file-dropdown/index.tsx
@@ -1,10 +1,10 @@
-import ShiftBy from "app/components/shift-by"
+import ShiftBy from "@components/shift-by"
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"
import { codeFileExtensions } from "@lib/constants"
-import type { File } from "@lib/types"
+import type { File } from "lib/server/prisma"
import { useCallback, useEffect, useState } from "react"
import styles from "./dropdown.module.css"
diff --git a/client/app/(posts)/components/file-tree/index.tsx b/client/app/(posts)/components/file-tree/index.tsx
index af21953f..c6cf04e1 100644
--- a/client/app/(posts)/components/file-tree/index.tsx
+++ b/client/app/(posts)/components/file-tree/index.tsx
@@ -2,10 +2,10 @@ import { File } from "@lib/types"
import FileIcon from "@geist-ui/icons/fileText"
import CodeIcon from "@geist-ui/icons/fileLambda"
import styles from "./file-tree.module.css"
-import ShiftBy from "app/components/shift-by"
+import ShiftBy from "@components/shift-by"
import { useEffect, useState } from "react"
import { codeFileExtensions } from "@lib/constants"
-import Link from "app/components/link"
+import Link from "@components/link"
type Item = File & {
icon: JSX.Element
diff --git a/client/app/(posts)/new/components/drag-and-drop/index.tsx b/client/app/(posts)/new/components/drag-and-drop/index.tsx
index f4748916..f764dc92 100644
--- a/client/app/(posts)/new/components/drag-and-drop/index.tsx
+++ b/client/app/(posts)/new/components/drag-and-drop/index.tsx
@@ -114,4 +114,4 @@ function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) {
)
}
-export default memo(FileDropzone)
+export default FileDropzone
diff --git a/client/app/(posts)/new/components/new.tsx b/client/app/(posts)/new/components/new.tsx
index cb65dfae..c575db85 100644
--- a/client/app/(posts)/new/components/new.tsx
+++ b/client/app/(posts)/new/components/new.tsx
@@ -12,9 +12,9 @@ import DatePicker from "react-datepicker"
import getTitleForPostCopy from "@lib/get-title-for-post-copy"
import Description from "./description"
import { PostWithFiles } from "@lib/server/prisma"
-import PasswordModal from "./password-modal"
+import PasswordModal from "../../../components/password-modal"
import Title from "./title"
-
+import FileDropzone from "./drag-and-drop"
const emptyDoc = {
title: "",
content: "",
diff --git a/client/app/(posts)/new/components/title/index.tsx b/client/app/(posts)/new/components/title/index.tsx
index f78eee26..7e781081 100644
--- a/client/app/(posts)/new/components/title/index.tsx
+++ b/client/app/(posts)/new/components/title/index.tsx
@@ -1,7 +1,7 @@
import { ChangeEvent, memo, useEffect, useState } from "react"
import { Text } from "@geist-ui/core/dist"
-import ShiftBy from "app/components/shift-by"
+import ShiftBy from "@components/shift-by"
import styles from "../post.module.css"
import { Input } from "@geist-ui/core/dist"
diff --git a/client/app/(posts)/new/from/[id]/page.tsx b/client/app/(posts)/new/from/[id]/page.tsx
index 57c95481..e68f64eb 100644
--- a/client/app/(posts)/new/from/[id]/page.tsx
+++ b/client/app/(posts)/new/from/[id]/page.tsx
@@ -1,7 +1,7 @@
-import NewPost from "app/(posts)/new/components/new"
+import NewPost from "../../components/new"
import { useRouter } from "next/navigation"
-import { getPostWithFiles } from "@lib/server/prisma"
-import Header from "app/components/header"
+import Header from "@components/header"
+import { getPostById } from "@lib/server/prisma"
const NewFromExisting = async ({
params
@@ -18,7 +18,7 @@ const NewFromExisting = async ({
return;
}
- const post = await getPostWithFiles(id)
+ const post = await getPostById(id, true)
return (
<>
diff --git a/client/app/(posts)/new/head.tsx b/client/app/(posts)/new/head.tsx
index 1dc76900..8acc8e7d 100644
--- a/client/app/(posts)/new/head.tsx
+++ b/client/app/(posts)/new/head.tsx
@@ -1,4 +1,4 @@
-import PageSeo from "app/components/page-seo"
+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
index 4943ba4d..87b49196 100644
--- a/client/app/(posts)/new/page.tsx
+++ b/client/app/(posts)/new/page.tsx
@@ -1,4 +1,4 @@
-import Header from "app/components/header"
+import Header from "@components/header"
import NewPost from "app/(posts)/new/components/new"
import "@styles/react-datepicker.css"
diff --git a/client/app/(posts)/post/[id]/components/post-page/index.tsx b/client/app/(posts)/post/[id]/components/post-page/index.tsx
index d30f1d38..873a2850 100644
--- a/client/app/(posts)/post/[id]/components/post-page/index.tsx
+++ b/client/app/(posts)/post/[id]/components/post-page/index.tsx
@@ -1,24 +1,22 @@
"use client"
-import VisibilityBadge from "app/components/badges/visibility-badge"
+import VisibilityBadge from "@components/badges/visibility-badge"
import DocumentComponent from "./view-document"
import styles from "./post-page.module.css"
-import type { PostVisibility } from "@lib/types"
import { Button, Text, ButtonGroup, useMediaQuery } from "@geist-ui/core/dist"
import { useEffect, useState } from "react"
import Archive from "@geist-ui/icons/archive"
import Edit from "@geist-ui/icons/edit"
import Parent from "@geist-ui/icons/arrowUpCircle"
import FileDropdown from "app/(posts)/components/file-dropdown"
-import ScrollToTop from "app/components/scroll-to-top"
+import ScrollToTop from "@components/scroll-to-top"
import { useRouter } from "next/navigation"
-import ExpirationBadge from "app/components/badges/expiration-badge"
-import CreatedAgoBadge from "app/components/badges/created-ago-badge"
+import ExpirationBadge from "@components/badges/expiration-badge"
+import CreatedAgoBadge from "@components/badges/created-ago-badge"
import PasswordModalPage from "./password-modal-wrapper"
-import VisibilityControl from "app/components/badges/visibility-control"
+import VisibilityControl from "@components/badges/visibility-control"
import { File, PostWithFiles } from "@lib/server/prisma"
-import Header from "app/components/header"
type Props = {
post: PostWithFiles
@@ -95,7 +93,7 @@ const PostPage = ({ post: initialPost, isProtected, isAuthor }: Props) => {
return (
<>
- {!isAvailable && }
+ {!isAvailable && }
{
>
Edit a Copy
- {post.parent && (
+ {post.parentId && (
} onClick={viewParentClick}>
View Parent
diff --git a/client/app/(posts)/post/[id]/components/post-page/password-modal-wrapper.tsx b/client/app/(posts)/post/[id]/components/post-page/password-modal-wrapper.tsx
index 405ebc05..f1ab69cd 100644
--- a/client/app/(posts)/post/[id]/components/post-page/password-modal-wrapper.tsx
+++ b/client/app/(posts)/post/[id]/components/post-page/password-modal-wrapper.tsx
@@ -1,12 +1,12 @@
-import PasswordModal from "@components/new-post/password-modal"
import { useToasts } from "@geist-ui/core/dist"
-import { Post } from "@lib/server/prisma"
+import { PostWithFiles } from "@lib/server/prisma"
+import PasswordModal from "@components/password-modal"
import { useRouter } from "next/navigation"
import { useState } from "react"
type Props = {
- setPost: (post: Post) => void
- postId: Post["id"]
+ setPost: (post: PostWithFiles) => void
+ postId: PostWithFiles["id"]
}
const PasswordModalPage = ({ setPost, postId }: Props) => {
diff --git a/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx b/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx
index 34c8d808..08a018ab 100644
--- a/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx
+++ b/client/app/(posts)/post/[id]/components/post-page/view-document/index.tsx
@@ -15,7 +15,7 @@ import {
Tag
} from "@geist-ui/core/dist"
import HtmlPreview from "app/(posts)/new/components/edit-document-list/edit-document/preview"
-import FadeIn from "app/components/fade-in"
+import FadeIn from "@components/fade-in"
// import Link from "next/link"
type Props = {
diff --git a/client/app/(posts)/post/[id]/head.tsx b/client/app/(posts)/post/[id]/head.tsx
index ec347ddf..1d175a2d 100644
--- a/client/app/(posts)/post/[id]/head.tsx
+++ b/client/app/(posts)/post/[id]/head.tsx
@@ -1,4 +1,4 @@
-import PageSeo from "app/components/page-seo"
+import PageSeo from "@components/page-seo"
import { getPostById } from "@lib/server/prisma"
export default async function Head({
diff --git a/client/app/(posts)/post/[id]/page.tsx b/client/app/(posts)/post/[id]/page.tsx
index 716564ab..595f7dad 100644
--- a/client/app/(posts)/post/[id]/page.tsx
+++ b/client/app/(posts)/post/[id]/page.tsx
@@ -6,7 +6,7 @@ import { USER_COOKIE_NAME } from "@lib/constants"
import { notFound } from "next/navigation"
import { getPostById } from "@lib/server/prisma"
import { getCurrentUser, getSession } from "@lib/server/session"
-import Header from "app/components/header"
+import Header from "@components/header"
export type PostProps = {
post: Post
@@ -17,6 +17,7 @@ const getPost = async (id: string) => {
const post = await getPostById(id, true)
const user = await getCurrentUser()
+ console.log("my post", post)
if (!post) {
return notFound()
}
@@ -39,7 +40,9 @@ const getPost = async (id: string) => {
return notFound()
}
+ console.log("HERE", post.visibility, isAuthor)
if (post.visibility === "protected" && !isAuthor) {
+ console.log("HERE2")
return {
post,
isProtected: true,
@@ -55,14 +58,13 @@ const PostView = async ({
params
}: {
params: {
- id: string,
- signedIn?: boolean
+ id: string
}
}) => {
- const { post, isProtected, isAuthor } = await getPost(params.id)
+ const { post, isProtected, isAuthor, signedIn } = await getPost(params.id)
return (
<>
-
+
>
)
diff --git a/client/app/admin/components/admin.tsx b/client/app/admin/components/admin.tsx
index 569ad857..4e3eb1f4 100644
--- a/client/app/admin/components/admin.tsx
+++ b/client/app/admin/components/admin.tsx
@@ -1,7 +1,5 @@
"use client"
-import { TOKEN_COOKIE_NAME } from "@lib/constants"
-import { getCookie } from "cookies-next"
import styles from "./admin.module.css"
import PostTable from "./post-table"
import UserTable from "./user-table"
@@ -13,11 +11,10 @@ export const adminFetcher = async (
body?: any
}
) =>
- fetch("/server-api/admin" + url, {
+ fetch("/api/admin" + url, {
method: options?.method || "GET",
headers: {
"Content-Type": "application/json",
- Authorization: `Bearer ${getCookie(TOKEN_COOKIE_NAME)}`
},
body: options?.body && JSON.stringify(options.body)
})
diff --git a/client/app/admin/components/user-table.tsx b/client/app/admin/components/user-table.tsx
index 4d3a157c..ea875ade 100644
--- a/client/app/admin/components/user-table.tsx
+++ b/client/app/admin/components/user-table.tsx
@@ -3,8 +3,8 @@ import { User } from "@lib/types"
import { useEffect, useMemo, useState } from "react"
import { adminFetcher } from "./admin"
import Table from "rc-table"
-import SettingsGroup from "@components/settings-group"
import ActionDropdown from "./action-dropdown"
+import SettingsGroup from "@components/settings-group"
const UserTable = () => {
const [users, setUsers] = useState()
diff --git a/client/app/admin/page.tsx b/client/app/admin/page.tsx
index 9ed2299f..52a2a66e 100644
--- a/client/app/admin/page.tsx
+++ b/client/app/admin/page.tsx
@@ -1,10 +1,11 @@
-import Admin from "./components/admin"
+import { isUserAdmin } from "@lib/server/prisma"
import { getCurrentUser } from "@lib/server/session"
+import Admin from "./components/admin"
+import { cookies } from "next/headers"
import { notFound } from "next/navigation"
const AdminPage = async () => {
- const user = await getCurrentUser()
-
+ const user = await getCurrentUser();
if (!user) {
return notFound()
}
diff --git a/client/app/components/badges/visibility-badge/index.tsx b/client/app/components/badges/visibility-badge/index.tsx
index 42fc899f..d90cc3f8 100644
--- a/client/app/components/badges/visibility-badge/index.tsx
+++ b/client/app/components/badges/visibility-badge/index.tsx
@@ -1,8 +1,10 @@
import { Badge } from "@geist-ui/core/dist"
import type { PostVisibility } from "@lib/types"
+type CastPostVisibility = PostVisibility | string
+
type Props = {
- visibility: PostVisibility
+ visibility: CastPostVisibility
}
const VisibilityBadge = ({ visibility }: Props) => {
diff --git a/client/app/components/badges/visibility-control/index.tsx b/client/app/components/badges/visibility-control/index.tsx
index 1dfade5e..dac801c3 100644
--- a/client/app/components/badges/visibility-control/index.tsx
+++ b/client/app/components/badges/visibility-control/index.tsx
@@ -1,7 +1,7 @@
-import PasswordModal from "@components/new-post/password-modal"
import { Button, ButtonGroup, Loading, useToasts } from "@geist-ui/core/dist"
import { TOKEN_COOKIE_NAME } from "@lib/constants"
import type { PostVisibility } from "@lib/types"
+import PasswordModal from "@components/password-modal"
import { getCookie } from "cookies-next"
import { useCallback, useState } from "react"
diff --git a/client/app/components/home.tsx b/client/app/components/home.tsx
index bd41652f..cbc69933 100644
--- a/client/app/components/home.tsx
+++ b/client/app/components/home.tsx
@@ -1,9 +1,10 @@
"use client"
-import ShiftBy from "app/components/shift-by"
+import ShiftBy from "@components/shift-by"
import { Spacer, Tabs, Card, Textarea, Text } from "@geist-ui/core/dist"
import Image from "next/image"
import styles from "./home.module.css"
-import markdownStyles from "@components/preview/preview.module.css"
+// TODO:components/new-post/ move these styles
+import markdownStyles from "app/(posts)/new/components/edit-document-list/edit-document/preview/preview.module.css";
const Home = ({
introTitle,
introContent,
diff --git a/client/app/(posts)/new/components/password-modal/index.tsx b/client/app/components/password-modal/index.tsx
similarity index 100%
rename from client/app/(posts)/new/components/password-modal/index.tsx
rename to client/app/components/password-modal/index.tsx
diff --git a/client/app/components/post-list/index.tsx b/client/app/components/post-list/index.tsx
index 049fb77b..9fa80784 100644
--- a/client/app/components/post-list/index.tsx
+++ b/client/app/components/post-list/index.tsx
@@ -7,7 +7,7 @@ import ListItemSkeleton from "./list-item-skeleton"
import ListItem from "./list-item"
import { ChangeEvent, useCallback, useEffect, useState } from "react"
import useDebounce from "@lib/hooks/use-debounce"
-import Link from "app/components/link"
+import Link from "@components/link"
import { TOKEN_COOKIE_NAME } from "@lib/constants"
import { getCookie } from "cookies-next"
import type { PostWithFiles } from "@lib/server/prisma"
diff --git a/client/app/components/post-list/list-item.tsx b/client/app/components/post-list/list-item.tsx
index a4c06e80..15f7618d 100644
--- a/client/app/components/post-list/list-item.tsx
+++ b/client/app/components/post-list/list-item.tsx
@@ -7,15 +7,15 @@ import {
Badge,
Button
} from "@geist-ui/core/dist"
-import FadeIn from "app/components/fade-in"
+import FadeIn from "@components/fade-in"
import Trash from "@geist-ui/icons/trash"
-import ExpirationBadge from "app/components/badges/expiration-badge"
-import CreatedAgoBadge from "app/components/badges/created-ago-badge"
+import ExpirationBadge from "@components/badges/expiration-badge"
+import CreatedAgoBadge from "@components/badges/created-ago-badge"
import Edit from "@geist-ui/icons/edit"
import { useRouter } from "next/navigation"
import Parent from "@geist-ui/icons/arrowUpCircle"
import styles from "./list-item.module.css"
-import Link from "app/components/link"
+import Link from "@components/link"
import type { PostWithFiles } from "@lib/server/prisma"
import type { PostVisibility } from "@lib/types"
import type { File } from "@lib/server/prisma"
diff --git a/client/app/settings/components/settings-group/index.tsx b/client/app/components/settings-group/index.tsx
similarity index 100%
rename from client/app/settings/components/settings-group/index.tsx
rename to client/app/components/settings-group/index.tsx
diff --git a/client/app/settings/components/settings-group/settings-group.module.css b/client/app/components/settings-group/settings-group.module.css
similarity index 100%
rename from client/app/settings/components/settings-group/settings-group.module.css
rename to client/app/components/settings-group/settings-group.module.css
diff --git a/client/app/mine/head.tsx b/client/app/mine/head.tsx
index cf5f536a..8b9fc207 100644
--- a/client/app/mine/head.tsx
+++ b/client/app/mine/head.tsx
@@ -1,4 +1,4 @@
-import PageSeo from "app/components/page-seo"
+import PageSeo from "@components/page-seo"
export default function Head() {
return
diff --git a/client/app/mine/page.tsx b/client/app/mine/page.tsx
index 38fdee1f..f35be304 100644
--- a/client/app/mine/page.tsx
+++ b/client/app/mine/page.tsx
@@ -1,8 +1,8 @@
import { redirect } from "next/navigation"
import { getPostsByUser } from "@lib/server/prisma"
-import PostList from "app/components/post-list"
+import PostList from "@components/post-list"
import { getCurrentUser } from "@lib/server/session"
-import Header from "app/components/header"
+import Header from "@components/header"
import { authOptions } from "@lib/server/auth"
export default async function Mine() {
diff --git a/client/app/page.tsx b/client/app/page.tsx
index bf787a56..d8070a93 100644
--- a/client/app/page.tsx
+++ b/client/app/page.tsx
@@ -1,4 +1,4 @@
-import Header from "app/components/header"
+import Header from "@components/header"
import { getCurrentUser } from "@lib/server/session"
import { getWelcomeContent } from "pages/api/welcome"
import Home from "./components/home"
diff --git a/client/app/settings/components/sections/profile.tsx b/client/app/settings/components/sections/profile.tsx
index dae4d1c7..3b293250 100644
--- a/client/app/settings/components/sections/profile.tsx
+++ b/client/app/settings/components/sections/profile.tsx
@@ -4,7 +4,7 @@ import { Note, Input, Textarea, Button, useToasts } from "@geist-ui/core/dist"
import { TOKEN_COOKIE_NAME } from "@lib/constants"
import { getCookie } from "cookies-next"
import { User } from "next-auth"
-import { useEffect, useState } from "react"
+import { useState } from "react"
const Profile = ({ user }: { user: User }) => {
const [name, setName] = useState(user.name || "")
diff --git a/client/app/settings/head.tsx b/client/app/settings/head.tsx
index ae3f2488..6404a743 100644
--- a/client/app/settings/head.tsx
+++ b/client/app/settings/head.tsx
@@ -1,4 +1,4 @@
-import PageSeo from "app/components/page-seo"
+import PageSeo from "@components/page-seo"
export default function Head() {
return
diff --git a/client/app/settings/page.tsx b/client/app/settings/page.tsx
index 76126f79..2ee672ea 100644
--- a/client/app/settings/page.tsx
+++ b/client/app/settings/page.tsx
@@ -1,5 +1,5 @@
-import Header from "app/components/header"
-import SettingsGroup from "./components/settings-group"
+import Header from "@components/header"
+import SettingsGroup from "../components/settings-group"
import Password from "app/settings/components/sections/password"
import Profile from "app/settings/components/sections/profile"
import { authOptions } from "@lib/server/auth"
diff --git a/client/lib/server/auth.ts b/client/lib/server/auth.ts
index 8b22069b..e7effa1f 100644
--- a/client/lib/server/auth.ts
+++ b/client/lib/server/auth.ts
@@ -54,7 +54,7 @@ export const authOptions: NextAuthOptions = {
name: dbUser.username,
email: dbUser.email,
picture: dbUser.image,
- role: dbUser.role
+ role: dbUser.role || "user",
}
}
}
diff --git a/client/lib/server/prisma.ts b/client/lib/server/prisma.ts
index ed1e3289..c9e8705f 100644
--- a/client/lib/server/prisma.ts
+++ b/client/lib/server/prisma.ts
@@ -160,5 +160,5 @@ export const getPostById = async (postId: Post["id"], withFiles = false) => {
}
})
- return post
+ return post as PostWithFiles
}
diff --git a/client/middleware.ts b/client/middleware.ts
index 6754d7ca..2be7a66d 100644
--- a/client/middleware.ts
+++ b/client/middleware.ts
@@ -41,6 +41,5 @@ export const config = {
"/signin",
"/signup",
"/new",
- "/private/:path*"
]
}