This commit is contained in:
Jin Yucong 2024-07-05 14:36:50 +08:00
parent 5b1aaee605
commit 3b737a078a
63 changed files with 1132 additions and 1853 deletions

View file

@ -1,4 +1,4 @@
import ChatWindow from '@/components/ChatWindow';
import ChatWindow from "@/components/ChatWindow";
const Page = ({ params }: { params: { chatId: string } }) => {
return <ChatWindow id={params.chatId} />;

View file

@ -1,22 +1,21 @@
import type { Metadata } from 'next';
import { Montserrat } from 'next/font/google';
import './globals.css';
import { cn } from '@/lib/utils';
import Sidebar from '@/components/Sidebar';
import { Toaster } from 'sonner';
import ThemeProvider from '@/components/theme/Provider';
import type { Metadata } from "next";
import { Montserrat } from "next/font/google";
import "./globals.css";
import { cn } from "@/lib/utils";
import Sidebar from "@/components/Sidebar";
import { Toaster } from "sonner";
import ThemeProvider from "@/components/theme/Provider";
const montserrat = Montserrat({
weight: ['300', '400', '500', '700'],
subsets: ['latin'],
display: 'swap',
fallback: ['Arial', 'sans-serif'],
weight: ["300", "400", "500", "700"],
subsets: ["latin"],
display: "swap",
fallback: ["Arial", "sans-serif"],
});
export const metadata: Metadata = {
title: 'Perplexica - Chat with the internet',
description:
'Perplexica is an AI powered chatbot that is connected to the internet.',
title: "Perplexica - Chat with the internet",
description: "Perplexica is an AI powered chatbot that is connected to the internet.",
};
export default function RootLayout({
@ -26,7 +25,7 @@ export default function RootLayout({
}>) {
return (
<html className="h-full" lang="en" suppressHydrationWarning>
<body className={cn('h-full', montserrat.className)}>
<body className={cn("h-full", montserrat.className)}>
<ThemeProvider>
<Sidebar>{children}</Sidebar>
<Toaster
@ -34,7 +33,7 @@ export default function RootLayout({
unstyled: true,
classNames: {
toast:
'bg-light-primary dark:bg-dark-primary text-white rounded-lg p-4 flex flex-row items-center space-x-2',
"bg-light-primary dark:bg-dark-primary text-white rounded-lg p-4 flex flex-row items-center space-x-2",
},
}}
/>

View file

@ -1,8 +1,8 @@
import { Metadata } from 'next';
import React from 'react';
import { Metadata } from "next";
import React from "react";
export const metadata: Metadata = {
title: 'Library - Perplexica',
title: "Library - Perplexica",
};
const Layout = ({ children }: { children: React.ReactNode }) => {

View file

@ -1,10 +1,10 @@
'use client';
"use client";
import DeleteChat from '@/components/DeleteChat';
import { formatTimeDifference } from '@/lib/utils';
import { BookOpenText, ClockIcon } from 'lucide-react';
import Link from 'next/link';
import { useEffect, useState } from 'react';
import DeleteChat from "@/components/DeleteChat";
import { formatTimeDifference } from "@/lib/utils";
import { BookOpenText, ClockIcon } from "lucide-react";
import Link from "next/link";
import { useEffect, useState } from "react";
export interface Chat {
id: string;
@ -22,9 +22,9 @@ const Page = () => {
setLoading(true);
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/chats`, {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
},
});
@ -61,16 +61,12 @@ const Page = () => {
<div className="fixed z-40 top-0 left-0 right-0 lg:pl-[104px] lg:pr-6 lg:px-8 px-4 py-4 lg:py-6 border-b border-light-200 dark:border-dark-200">
<div className="flex flex-row items-center space-x-2 max-w-screen-lg lg:mx-auto">
<BookOpenText />
<h2 className="text-black dark:text-white lg:text-3xl lg:font-medium">
Library
</h2>
<h2 className="text-black dark:text-white lg:text-3xl lg:font-medium">Library</h2>
</div>
</div>
{chats.length === 0 && (
<div className="flex flex-row items-center justify-center min-h-screen">
<p className="text-black/70 dark:text-white/70 text-sm">
No chats found.
</p>
<p className="text-black/70 dark:text-white/70 text-sm">No chats found.</p>
</div>
)}
{chats.length > 0 && (
@ -89,15 +85,9 @@ const Page = () => {
<div className="flex flex-row items-center justify-between w-full">
<div className="flex flex-row items-center space-x-1 lg:space-x-1.5 text-black/70 dark:text-white/70">
<ClockIcon size={15} />
<p className="text-xs">
{formatTimeDifference(new Date(), chat.createdAt)} Ago
</p>
<p className="text-xs">{formatTimeDifference(new Date(), chat.createdAt)} Ago</p>
</div>
<DeleteChat
chatId={chat.id}
chats={chats}
setChats={setChats}
/>
<DeleteChat chatId={chat.id} chats={chats} setChats={setChats} />
</div>
</div>
))}

View file

@ -1,10 +1,10 @@
import ChatWindow from '@/components/ChatWindow';
import { Metadata } from 'next';
import { Suspense } from 'react';
import ChatWindow from "@/components/ChatWindow";
import { Metadata } from "next";
import { Suspense } from "react";
export const metadata: Metadata = {
title: 'Chat - Perplexica',
description: 'Chat with the internet, chat with Perplexica.',
title: "Chat - Perplexica",
description: "Chat with the internet, chat with Perplexica.",
};
const Home = () => {