-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
213 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs"; | ||
import { cookies } from "next/headers"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
export async function GET(req: NextRequest) { | ||
const supabase = createRouteHandlerClient({ cookies }); | ||
const { searchParams } = new URL(req.url); | ||
const code = searchParams.get("code"); | ||
|
||
if (code) { | ||
await supabase.auth.exchangeCodeForSession(code); | ||
} | ||
|
||
return NextResponse.redirect(new URL("/", req.url)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use client"; | ||
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs"; | ||
import { Auth } from "@supabase/auth-ui-react"; | ||
import { ThemeSupa } from "@supabase/auth-ui-shared"; | ||
|
||
export function AuthForm() { | ||
const supabase = createClientComponentClient(); | ||
const host = process.env.NEXT_PUBLIC_VERCEL_URL | ||
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` | ||
: `http://localhost:3000`; | ||
return ( | ||
<Auth | ||
supabaseClient={supabase} | ||
appearance={{ theme: ThemeSupa }} | ||
showLinks={false} | ||
providers={["google"]} | ||
redirectTo={`${host}/auth/callback`} | ||
onlyThirdPartyProviders={true} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { AuthForm } from "./AuthForm"; | ||
|
||
export default function App() { | ||
return <AuthForm />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"use client"; | ||
import { BlockNoteEditor, Editor } from "@/components/Editor"; | ||
import { EmojiContainer } from "@/components/EmojiContainer"; | ||
import { User } from "@supabase/auth-helpers-nextjs"; | ||
import { useState } from "react"; | ||
|
||
export function Feedbacker({ user }: { user: User | null }) { | ||
console.log("user", user); | ||
const [editor, setEditor] = useState<BlockNoteEditor | null>(null); | ||
|
||
const handleEditorReady = (editor: BlockNoteEditor | null) => { | ||
console.log("handleEditorReady"); | ||
setEditor(editor); | ||
}; | ||
|
||
const [editable, setEditable] = useState(false); | ||
|
||
return ( | ||
<> | ||
<div className="w-full"> | ||
<div className="flex justify-center"> | ||
{editor ? <EmojiContainer editor={editor} /> : null} | ||
</div> | ||
<div className="flex justify-center items-center mt-2"> | ||
<input | ||
type="checkbox" | ||
id="checkbox" | ||
checked={editable} | ||
onChange={() => setEditable(!editable)} | ||
className="h-5 w-5 mr-2" | ||
/> | ||
<label htmlFor="checkbox">편집 활성화</label> | ||
</div> | ||
<div className="p-28"> | ||
<Editor | ||
editable={editable} | ||
onEditorReady={handleEditorReady} | ||
userName={user?.user_metadata?.full_name} | ||
/> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,17 @@ | ||
"use client"; | ||
import { BlockNoteEditor, Editor, PartialBlock } from "@/components/Editor"; | ||
import { EmojiContainer } from "@/components/EmojiContainer"; | ||
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs"; | ||
import { useState } from "react"; | ||
const emojis = ["👍", "🤔", "🌟", "👎"]; // Your emoji list | ||
import { createServerComponentClient } from "@supabase/auth-helpers-nextjs"; | ||
import { cookies } from "next/headers"; | ||
import { Feedbacker } from "./Feedbacker"; | ||
|
||
export default function Feedbacker() { | ||
const supabase = createClientComponentClient(); | ||
const [textCursorPosition, setTextCursorPosition] = useState<{ | ||
blockId: string | null; | ||
nextBlockId: string | null; | ||
prevBlockId: string | null; | ||
}>({ | ||
blockId: null, | ||
nextBlockId: null, | ||
prevBlockId: null, | ||
}); | ||
export default async function Page() { | ||
const supabase = createServerComponentClient({ cookies }); | ||
|
||
const [editor, setEditor] = useState<BlockNoteEditor | null>(null); | ||
|
||
const handleEditorReady = (editor: BlockNoteEditor | null) => { | ||
console.log("handleEditorReady"); | ||
setEditor(editor); | ||
}; | ||
|
||
|
||
|
||
const [editable, setEditable] = useState(false); | ||
const { | ||
data: { user }, | ||
} = await supabase.auth.getUser(); | ||
|
||
return ( | ||
<> | ||
<div className="w-full"> | ||
<div className="flex justify-center"> | ||
{editor ? | ||
<EmojiContainer | ||
editor={editor} | ||
/> : null | ||
} | ||
</div> | ||
<div className="flex justify-center items-center mt-2"> | ||
<input | ||
type="checkbox" | ||
id="checkbox" | ||
checked={editable} | ||
onChange={() => setEditable(!editable)} | ||
className="h-5 w-5 mr-2" | ||
/> | ||
<label htmlFor="checkbox">편집 활성화</label> | ||
</div> | ||
<div className="p-28"> | ||
<Editor | ||
editable={editable} | ||
onEditorReady={handleEditorReady} | ||
onTextCursorPositionChange={setTextCursorPosition} | ||
/> | ||
</div> | ||
</div> | ||
<Feedbacker user={user} /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use client"; | ||
|
||
import Link from "next/link"; | ||
import { usePathname } from "next/navigation"; | ||
|
||
export function LinkWithRoute({ href, text }: { href: string; text: string }) { | ||
const pathname = usePathname(); | ||
return ( | ||
<Link | ||
href={href} | ||
className={`text-white hover:text-blue-300 ${ | ||
pathname === href ? "font-bold" : "" | ||
}`} | ||
> | ||
{text} | ||
</Link> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use client"; | ||
|
||
import { | ||
User, | ||
createClientComponentClient, | ||
} from "@supabase/auth-helpers-nextjs"; | ||
|
||
export const UserInfo = ({ user }: { user: User }) => { | ||
const supabase = createClientComponentClient(); | ||
return ( | ||
<div | ||
className="cursor-pointer text-white hover:text-blue-300" | ||
onClick={async () => { | ||
await supabase.auth.signOut(); | ||
window.location.reload(); | ||
}} | ||
> | ||
{user.email} | ||
</div> | ||
); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.