diff --git a/app/(auth)/signin/page.tsx b/app/(auth)/signin/page.tsx index 6984c12..da4d076 100644 --- a/app/(auth)/signin/page.tsx +++ b/app/(auth)/signin/page.tsx @@ -3,7 +3,7 @@ import { cookies } from "next/headers"; import { redirect } from "next/navigation"; import { siteConfig } from "@/config/site"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; import { Heading3 } from "@/components/ui/typography"; import { UserAuthForm } from "@/components/modules/auth/UserAuthForm"; @@ -19,9 +19,9 @@ export const dynamic = "force-dynamic"; export default async function LoginPage() { const cookieStore = cookies(); const supabase = createClient(cookieStore); - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); - if (session) { + if (user) { redirect(`/apps/chat`); } diff --git a/app/(auth)/signup/page.tsx b/app/(auth)/signup/page.tsx index 71bb574..4f33b91 100644 --- a/app/(auth)/signup/page.tsx +++ b/app/(auth)/signup/page.tsx @@ -3,7 +3,7 @@ import { cookies } from "next/headers"; import { redirect } from "next/navigation"; import { siteConfig } from "@/config/site"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; import { Heading3 } from "@/components/ui/typography"; import { UserSignupForm } from "@/components/modules/auth/UserSignupForm"; @@ -19,9 +19,9 @@ export const dynamic = "force-dynamic"; export default async function LoginPage() { const cookieStore = cookies(); const supabase = createClient(cookieStore); - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); - if (session) { + if (user) { redirect(`/apps/chat`); } diff --git a/app/api/auth/logout/route.ts b/app/api/auth/logout/route.ts index 4624d7a..0428274 100644 --- a/app/api/auth/logout/route.ts +++ b/app/api/auth/logout/route.ts @@ -11,10 +11,10 @@ export async function POST(req: NextRequest) { // Check if we have a session const { - data: { session }, - } = await supabase.auth.getSession(); + data: { user }, + } = await supabase.auth.getUser(); - if (session) { + if (user) { await supabase.auth.signOut(); } diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 8725c5a..075879f 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -12,7 +12,7 @@ import { deleteMessagesFrom, getMessageById, } from "@/lib/db/message"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; export const dynamic = "force-dynamic"; @@ -45,15 +45,15 @@ export const POST = withAxiom(async (req: AxiomRequest) => { isNewChat, } = params; - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); const currentApp = await getAppBySlug(supabase, "/apps/chat"); - if (!session) { + if (!user) { return new Response("Unauthorized", { status: 401 }); } const lastMessage = messages[messages.length - 1]; - const profileId = session.user.id; + const profileId = user.id; if (!isRegenerate) { if (isNewChat && currentApp) { diff --git a/app/apps/chat/[id]/page.tsx b/app/apps/chat/[id]/page.tsx index 6c1e17b..c0135c3 100644 --- a/app/apps/chat/[id]/page.tsx +++ b/app/apps/chat/[id]/page.tsx @@ -6,7 +6,7 @@ import { Message } from "ai"; import { getAppBySlug } from "@/lib/db/apps"; import { getChatById, getChats } from "@/lib/db/chats"; import { getMessages } from "@/lib/db/message"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; import { ChatPanel } from "@/components/modules/apps/chat/ChatPanel"; import { ChatParams } from "@/components/modules/apps/chat/types"; @@ -25,14 +25,14 @@ export default async function ChatPage({ params }: { params: { id: string } }) { const cookieStore = cookies(); const supabase = createClient(cookieStore); - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); const currentApp = await getAppBySlug(supabase, "/apps/chat"); - if (!currentApp || !session) { + if (!currentApp || !user) { return
No app found
; } - const currentProfileId = session.user.id; + const currentProfileId = user.id; const chats = await getChats(supabase, { appId: currentApp.id, profileId: currentProfileId, diff --git a/app/apps/chat/page.tsx b/app/apps/chat/page.tsx index 736561b..793b157 100644 --- a/app/apps/chat/page.tsx +++ b/app/apps/chat/page.tsx @@ -5,7 +5,7 @@ import { v4 as uuidv4 } from "uuid"; import { getAppBySlug } from "@/lib/db/apps"; import { getChats } from "@/lib/db/chats"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; import { ChatPanel } from "@/components/modules/apps/chat/ChatPanel"; @@ -18,14 +18,14 @@ export default async function NewChatPage() { const cookieStore = cookies(); const supabase = createClient(cookieStore); - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); const currentApp = await getAppBySlug(supabase, "/apps/chat"); - if (!currentApp || !session) { + if (!currentApp || !user) { return
No app found
; } - const currentProfileId = session.user.id; + const currentProfileId = user.id; const chats = await getChats(supabase, { appId: currentApp.id, profileId: currentProfileId, diff --git a/app/apps/layout.tsx b/app/apps/layout.tsx index faa99cb..492710e 100644 --- a/app/apps/layout.tsx +++ b/app/apps/layout.tsx @@ -2,7 +2,7 @@ import { cookies } from "next/headers"; import { getAppBySlug } from "@/lib/db/apps"; import { getChats } from "@/lib/db/chats"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; import { MainLayout } from "@/components/ui/common/MainLayout"; import { ChatHistory } from "@/components/modules/apps/chat/ChatHistory"; @@ -14,14 +14,14 @@ interface AppLayoutProps { export default async function AppLayout({ children }: AppLayoutProps) { const cookieStore = cookies(); const supabase = createClient(cookieStore); - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); const currentApp = await getAppBySlug(supabase, "/apps/chat"); - if (!currentApp || !session) { + if (!currentApp || !user) { return
No app found
; } - const currentProfileId = session.user.id; + const currentProfileId = user.id; const chats = await getChats(supabase, { appId: currentApp.id, diff --git a/app/globals.css b/app/globals.css index 32f7f5e..d1c95b5 100644 --- a/app/globals.css +++ b/app/globals.css @@ -1,6 +1,8 @@ @tailwind base; @tailwind components; @tailwind utilities; + +@import url('./styles/custom.css'); .drawer-toggle:checked ~ .drawer-side { backdrop-filter: blur(5px); diff --git a/app/layout.tsx b/app/layout.tsx index 20567dc..9e4cd2d 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -4,11 +4,12 @@ import "./globals.css"; import { Metadata, Viewport } from "next"; import { Analytics } from "@vercel/analytics/react"; -import { GeistMono, GeistSans } from "geist/font"; +import { GeistMono } from "geist/font/mono"; +import { GeistSans } from "geist/font/sans"; +import { ThemeProvider } from "next-themes"; import { siteConfig } from "@/config/site"; import { Toaster } from "@/components/ui/Toaster"; -import { ThemeProvider } from "@/components/theme/ThemeProvider"; export const metadata: Metadata = { title: { diff --git a/app/page.tsx b/app/page.tsx index 01e9b17..a246c1f 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -22,7 +22,7 @@ export default async function Home() {
-
+

{siteConfig.name}

diff --git a/app/profile/page.tsx b/app/profile/page.tsx index 7302fa1..923cc04 100644 --- a/app/profile/page.tsx +++ b/app/profile/page.tsx @@ -1,7 +1,7 @@ import { cookies } from "next/headers"; import { getCurrentProfile } from "@/lib/db/profile"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; import { Header } from "@/components/modules/profile/Header"; import { ProfileForm } from "@/components/modules/profile/ProfileForm"; @@ -15,7 +15,7 @@ export default async function Profile() { const cookieStore = cookies(); const supabase = createClient(cookieStore); const profile = await getCurrentProfile(supabase); - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); if (!profile) { return null; @@ -32,7 +32,7 @@ export default async function Profile() {
div { + display: block; + aspect-ratio: 1/1; + overflow: hidden +} + +.avatar img { + height: 100%; + width: 100%; + object-fit: cover +} + +.avatar.placeholder>div { + display: flex; + align-items: center; + justify-content: center +} + +.chat { + display: grid; + grid-template-columns: repeat(2,minmax(0,1fr)); + column-gap: .75rem; + padding-top: .25rem; + padding-bottom: .25rem +} + +.chat-image { + grid-row: span 2/span 2; + align-self: flex-end +} + +.chat-header { + grid-row-start: 1; + font-size: .875rem; + line-height: 1.25rem +} + +.chat-footer { + grid-row-start: 3; + font-size: .875rem; + line-height: 1.25rem +} + +.chat-bubble { + position: relative; + display: block; + width: -moz-fit-content; + width: fit-content; + padding: .5rem 1rem; + max-width: 90%; + border-radius: var(--rounded-box,1rem); + min-height: 2.75rem; + min-width: 2.75rem; + --tw-bg-opacity: 1; + background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity))); + --tw-text-opacity: 1; + color: var(--fallback-nc,oklch(var(--nc)/var(--tw-text-opacity))) +} + +.chat-bubble:before { + position: absolute; + bottom: 0; + height: .75rem; + width: .75rem; + background-color: inherit; + content: ""; + -webkit-mask-size: contain; + mask-size: contain; + -webkit-mask-repeat: no-repeat; + mask-repeat: no-repeat; + -webkit-mask-position: center; + mask-position: center +} + +.chat-start { + place-items: start; + grid-template-columns: auto 1fr +} + +.chat-start .chat-header,.chat-start .chat-footer { + grid-column-start: 2 +} + +.chat-start .chat-image { + grid-column-start: 1 +} + +.chat-start .chat-bubble { + grid-column-start: 2; + border-end-start-radius: 0 +} + +.chat-start .chat-bubble:before { + -webkit-mask-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMycgaGVpZ2h0PSczJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxwYXRoIGZpbGw9J2JsYWNrJyBkPSdtIDAgMyBMIDMgMyBMIDMgMCBDIDMgMSAxIDMgMCAzJy8+PC9zdmc+); + mask-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMycgaGVpZ2h0PSczJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxwYXRoIGZpbGw9J2JsYWNrJyBkPSdtIDAgMyBMIDMgMyBMIDMgMCBDIDMgMSAxIDMgMCAzJy8+PC9zdmc+); + inset-inline-start: -.749rem +} + +[dir=rtl] .chat-start .chat-bubble:before { + -webkit-mask-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMycgaGVpZ2h0PSczJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxwYXRoIGZpbGw9J2JsYWNrJyBkPSdtIDAgMyBMIDEgMyBMIDMgMyBDIDIgMyAwIDEgMCAwJy8+PC9zdmc+); + mask-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMycgaGVpZ2h0PSczJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxwYXRoIGZpbGw9J2JsYWNrJyBkPSdtIDAgMyBMIDEgMyBMIDMgMyBDIDIgMyAwIDEgMCAwJy8+PC9zdmc+) +} + +.chat-end { + place-items: end; + grid-template-columns: 1fr auto +} + +.chat-end .chat-header,.chat-end .chat-footer { + grid-column-start: 1 +} + +.chat-end .chat-image { + grid-column-start: 2 +} + +.chat-end .chat-bubble { + grid-column-start: 1; + border-end-end-radius: 0 +} + +.chat-end .chat-bubble:before { + -webkit-mask-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMycgaGVpZ2h0PSczJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxwYXRoIGZpbGw9J2JsYWNrJyBkPSdtIDAgMyBMIDEgMyBMIDMgMyBDIDIgMyAwIDEgMCAwJy8+PC9zdmc+); + mask-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMycgaGVpZ2h0PSczJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxwYXRoIGZpbGw9J2JsYWNrJyBkPSdtIDAgMyBMIDEgMyBMIDMgMyBDIDIgMyAwIDEgMCAwJy8+PC9zdmc+); + inset-inline-start: 99.9% +} + +[dir=rtl] .chat-end .chat-bubble:before { + -webkit-mask-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMycgaGVpZ2h0PSczJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxwYXRoIGZpbGw9J2JsYWNrJyBkPSdtIDAgMyBMIDMgMyBMIDMgMCBDIDMgMSAxIDMgMCAzJy8+PC9zdmc+); + mask-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMycgaGVpZ2h0PSczJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxwYXRoIGZpbGw9J2JsYWNrJyBkPSdtIDAgMyBMIDMgMyBMIDMgMCBDIDMgMSAxIDMgMCAzJy8+PC9zdmc+) +} + +.drawer { + position: relative; + display: grid; + grid-auto-columns: max-content auto; + width: 100% +} + +.drawer-content { + grid-column-start: 2; + grid-row-start: 1; + min-width: 0px +} + +.drawer-side { + pointer-events: none; + position: fixed; + inset-inline-start: 0px; + top: 0; + grid-column-start: 1; + grid-row-start: 1; + display: grid; + width: 100%; + grid-template-columns: repeat(1,minmax(0,1fr)); + grid-template-rows: repeat(1,minmax(0,1fr)); + align-items: flex-start; + justify-items: start; + overflow-x: hidden; + overflow-y: hidden; + overscroll-behavior: contain; + height: 100vh; + height: 100dvh +} + +.drawer-side>.drawer-overlay { + position: sticky; + top: 0; + place-self: stretch; + cursor: pointer; + background-color: transparent; + transition-property: color,background-color,border-color,text-decoration-color,fill,stroke; + transition-timing-function: cubic-bezier(.4,0,.2,1); + transition-timing-function: cubic-bezier(0,0,.2,1); + transition-duration: .2s +} + +.drawer-side>* { + grid-column-start: 1; + grid-row-start: 1 +} + +.drawer-side>*:not(.drawer-overlay) { + transition-property: transform; + transition-timing-function: cubic-bezier(.4,0,.2,1); + transition-timing-function: cubic-bezier(0,0,.2,1); + transition-duration: .3s; + will-change: transform; + transform: translate(-100%) +} + +[dir=rtl] .drawer-side>*:not(.drawer-overlay) { + transform: translate(100%) +} + +.drawer-toggle { + position: fixed; + height: 0px; + width: 0px; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + opacity: 0 +} + +.drawer-toggle:checked~.drawer-side { + pointer-events: auto; + visibility: visible; + overflow-y: auto +} + +.drawer-toggle:checked~.drawer-side>*:not(.drawer-overlay) { + transform: translate(0) +} + +.drawer-end { + grid-auto-columns: auto max-content +} + +.drawer-end .drawer-toggle~.drawer-content { + grid-column-start: 1 +} + +.drawer-end .drawer-toggle~.drawer-side { + grid-column-start: 2; + justify-items: end +} + +.drawer-end .drawer-toggle~.drawer-side>*:not(.drawer-overlay) { + transform: translate(100%) +} + +[dir=rtl] .drawer-end .drawer-toggle~.drawer-side>*:not(.drawer-overlay) { + transform: translate(-100%) +} + +.drawer-end .drawer-toggle:checked~.drawer-side>*:not(.drawer-overlay) { + transform: translate(0) +} diff --git a/components/modules/apps/chat/action.ts b/components/modules/apps/chat/action.ts index 96944d8..bf33ec9 100644 --- a/components/modules/apps/chat/action.ts +++ b/components/modules/apps/chat/action.ts @@ -11,20 +11,20 @@ import { deleteChat as deleteChatDb, updateChat as updateChatDb, } from "@/lib/db/chats"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; export const createNewChat = async () => { const cookieStore = cookies(); const supabase = createClient(cookieStore); - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); const currentApp = await getAppBySlug(supabase, "/apps/chat"); - if (!currentApp || !session) { + if (!currentApp || !user) { throw new Error("You must be logged in to create a chat"); } - const currentProfileId = session.user.id; + const currentProfileId = user.id; const newChats = await createNewChatDb(supabase, { appId: currentApp.id, diff --git a/components/modules/apps/chat/control-side-bar/action.ts b/components/modules/apps/chat/control-side-bar/action.ts index 11e85b4..11c3413 100644 --- a/components/modules/apps/chat/control-side-bar/action.ts +++ b/components/modules/apps/chat/control-side-bar/action.ts @@ -5,7 +5,7 @@ import { cookies } from "next/headers"; import { Chat, Update } from "@/lib/db"; import { getAppBySlug } from "@/lib/db/apps"; import { updateChat } from "@/lib/db/chats"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; export const updateChatSettings = async ( @@ -14,14 +14,14 @@ export const updateChatSettings = async ( ) => { const cookieStore = cookies(); const supabase = createClient(cookieStore); - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); const currentApp = await getAppBySlug(supabase, "/apps/chat"); - if (!currentApp || !session) { + if (!currentApp || !user) { throw new Error("You must be logged in to create a chat"); } - const currentProfileId = session.user.id; + const currentProfileId = user.id; try { await updateChat(supabase, { diff --git a/components/modules/home/DescriptionHeadingText.tsx b/components/modules/home/DescriptionHeadingText.tsx index 17fbd6d..00c65a0 100644 --- a/components/modules/home/DescriptionHeadingText.tsx +++ b/components/modules/home/DescriptionHeadingText.tsx @@ -27,7 +27,7 @@ export function DescriptionHeadingText() { return (
{ Next.js technology.

-
+
diff --git a/components/modules/profile/action.ts b/components/modules/profile/action.ts index e55762f..4196246 100644 --- a/components/modules/profile/action.ts +++ b/components/modules/profile/action.ts @@ -3,7 +3,7 @@ import { revalidatePath } from "next/cache"; import { cookies } from "next/headers"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; import { ProfileFormValues } from "./type"; @@ -15,14 +15,12 @@ export async function updateProfile({ }: ProfileFormValues) { const cookieStore = cookies(); const supabase = createClient(cookieStore); - const session = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); - if (!session) { + if (!user) { throw new Error("You must be logged in to update your profile"); } - const { user } = session; - try { const { error } = await supabase.from("profiles").upsert({ id: user.id, diff --git a/components/navigation/NavigationBar.tsx b/components/navigation/NavigationBar.tsx index 1316cc0..1186a93 100644 --- a/components/navigation/NavigationBar.tsx +++ b/components/navigation/NavigationBar.tsx @@ -2,7 +2,7 @@ import React from "react"; import { cookies } from "next/headers"; import { Menu } from "lucide-react"; -import { getCurrentSession } from "@/lib/session"; +import { getCurrentUser } from "@/lib/session"; import { createClient } from "@/lib/supabase/server"; import { cn } from "@/lib/utils"; @@ -15,7 +15,7 @@ import { NavigationMainMenu } from "./NavigationMainMenu"; export const NavigationBar = async () => { const cookieStore = cookies(); const supabase = await createClient(cookieStore); - const currentSession = await getCurrentSession(supabase); + const user = await getCurrentUser(supabase); return (
@@ -44,7 +44,7 @@ export const NavigationBar = async () => {
- +
diff --git a/components/theme/ThemeProvider.tsx b/components/theme/ThemeProvider.tsx deleted file mode 100644 index 22327be..0000000 --- a/components/theme/ThemeProvider.tsx +++ /dev/null @@ -1,9 +0,0 @@ -"use client"; - -import React from "react"; -import { ThemeProvider as NextThemesProvider } from "next-themes"; -import { ThemeProviderProps } from "next-themes/dist/types"; - -export function ThemeProvider({ children, ...props }: ThemeProviderProps) { - return {children}; -} diff --git a/components/theme/index.ts b/components/theme/index.ts index 309a9be..fcfa8c0 100644 --- a/components/theme/index.ts +++ b/components/theme/index.ts @@ -1,2 +1 @@ -export * from "./ThemeProvider"; export * from "./ThemeToggle"; diff --git a/components/ui/DropdownMenu.tsx b/components/ui/DropdownMenu.tsx index 15629d3..432ef43 100644 --- a/components/ui/DropdownMenu.tsx +++ b/components/ui/DropdownMenu.tsx @@ -47,7 +47,7 @@ const DropdownMenuSubContent = React.forwardRef< {children}{" "}