fix up colocation
This commit is contained in:
parent
96da95818f
commit
86b9172527
38 changed files with 72 additions and 67 deletions
|
@ -71,7 +71,12 @@ const Auth = ({
|
|||
auto
|
||||
width="100%"
|
||||
icon={<GithubIcon />}
|
||||
onClick={() => signIn("github").catch((err) => setErrorMsg(err.message))}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
signIn("github", {
|
||||
callbackUrl: "/",
|
||||
})
|
||||
}}
|
||||
>
|
||||
Sign in with GitHub
|
||||
</Button>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import PageSeo from "app/components/page-seo"
|
||||
import PageSeo from "@components/page-seo"
|
||||
|
||||
export default function AuthHead() {
|
||||
return <PageSeo title="Sign In" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Auth from "../components"
|
||||
import Header from "app/components/header"
|
||||
import Header from "@components/header"
|
||||
|
||||
export default function SignInPage() {
|
||||
return (
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import PageSeo from "app/components/page-seo"
|
||||
import PageSeo from "@components/page-seo"
|
||||
|
||||
export default function AuthHead() {
|
||||
return <PageSeo title="Sign Up" />
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -114,4 +114,4 @@ function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) {
|
|||
)
|
||||
}
|
||||
|
||||
export default memo(FileDropzone)
|
||||
export default FileDropzone
|
||||
|
|
|
@ -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: "",
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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 (
|
||||
<>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import PageSeo from "app/components/page-seo"
|
||||
import PageSeo from "@components/page-seo"
|
||||
|
||||
export default function NewPostHead() {
|
||||
return <PageSeo title="Create a new Drift" />
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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 && <PasswordModalPage setPost={setPost} />}
|
||||
{!isAvailable && <PasswordModalPage setPost={setPost} postId={post.id} />}
|
||||
<div className={styles.header}>
|
||||
<span className={styles.buttons}>
|
||||
<ButtonGroup
|
||||
|
@ -113,7 +111,7 @@ const PostPage = ({ post: initialPost, isProtected, isAuthor }: Props) => {
|
|||
>
|
||||
Edit a Copy
|
||||
</Button>
|
||||
{post.parent && (
|
||||
{post.parentId && (
|
||||
<Button auto icon={<Parent />} onClick={viewParentClick}>
|
||||
View Parent
|
||||
</Button>
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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 (
|
||||
<>
|
||||
<Header signedIn />
|
||||
<Header signedIn={signedIn} />
|
||||
<PostPage isAuthor={isAuthor} isProtected={isProtected} post={post} />
|
||||
</>
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
|
|
@ -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<User[]>()
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import PageSeo from "app/components/page-seo"
|
||||
import PageSeo from "@components/page-seo"
|
||||
|
||||
export default function Head() {
|
||||
return <PageSeo title="Drift - Your profile" isPrivate />
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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<string>(user.name || "")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import PageSeo from "app/components/page-seo"
|
||||
import PageSeo from "@components/page-seo"
|
||||
|
||||
export default function Head() {
|
||||
return <PageSeo title="Drift - Settings" isPrivate />
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -54,7 +54,7 @@ export const authOptions: NextAuthOptions = {
|
|||
name: dbUser.username,
|
||||
email: dbUser.email,
|
||||
picture: dbUser.image,
|
||||
role: dbUser.role
|
||||
role: dbUser.role || "user",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,5 +160,5 @@ export const getPostById = async (postId: Post["id"], withFiles = false) => {
|
|||
}
|
||||
})
|
||||
|
||||
return post
|
||||
return post as PostWithFiles
|
||||
}
|
||||
|
|
|
@ -41,6 +41,5 @@ export const config = {
|
|||
"/signin",
|
||||
"/signup",
|
||||
"/new",
|
||||
"/private/:path*"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue