Skip to content

Commit

Permalink
- Upgrade dependecies (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
nphivu414 authored Apr 1, 2024
1 parent 62b6f81 commit 65293f1
Show file tree
Hide file tree
Showing 31 changed files with 1,166 additions and 359 deletions.
6 changes: 3 additions & 3 deletions app/(auth)/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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`);
}

Expand Down
6 changes: 3 additions & 3 deletions app/(auth)/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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`);
}

Expand Down
6 changes: 3 additions & 3 deletions app/api/auth/logout/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
8 changes: 4 additions & 4 deletions app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions app/apps/chat/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 <div className="pt-4">No app found</div>;
}

const currentProfileId = session.user.id;
const currentProfileId = user.id;
const chats = await getChats(supabase, {
appId: currentApp.id,
profileId: currentProfileId,
Expand Down
8 changes: 4 additions & 4 deletions app/apps/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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 <div className="pt-4">No app found</div>;
}

const currentProfileId = session.user.id;
const currentProfileId = user.id;
const chats = await getChats(supabase, {
appId: currentApp.id,
profileId: currentProfileId,
Expand Down
8 changes: 4 additions & 4 deletions app/apps/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 <div className="pt-4">No app found</div>;
}

const currentProfileId = session.user.id;
const currentProfileId = user.id;

const chats = await getChats(supabase, {
appId: currentApp.id,
Expand Down
2 changes: 2 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@import url('./styles/custom.css');

.drawer-toggle:checked ~ .drawer-side {
backdrop-filter: blur(5px);
Expand Down
5 changes: 3 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default async function Home() {
<MainLayout>
<div className="px-4 pt-16">
<section className="space-y-6 pb-8 pt-6 md:pb-12 md:pt-10 lg:py-20">
<div className="container flex max-w-[64rem] flex-col items-center gap-6 text-center">
<div className="container flex max-w-5xl flex-col items-center gap-6 text-center">
<h1 className="font-heading bg-gradient-to-r from-gray-900 to-gray-500 bg-clip-text text-3xl font-bold leading-[1.1] tracking-tighter text-transparent dark:from-white dark:to-gray-500 sm:text-5xl md:text-6xl">
{siteConfig.name}
</h1>
Expand Down
6 changes: 3 additions & 3 deletions app/profile/page.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
Expand All @@ -32,7 +32,7 @@ export default async function Profile() {
<div className="container mx-auto sm:max-w-screen-sm">
<Header
avatarUrl={avatar_url}
email={session?.user.email}
email={user?.email}
fullName={full_name}
username={username}
website={website}
Expand Down
Loading

0 comments on commit 65293f1

Please sign in to comment.