fetch chats with userid
This commit is contained in:
parent
66b48146a3
commit
3558dc2ed2
2 changed files with 11 additions and 11 deletions
|
@ -20,8 +20,8 @@ const Page = () => {
|
|||
useEffect(() => {
|
||||
const fetchChats = async () => {
|
||||
setLoading(true);
|
||||
|
||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/chats`, {
|
||||
let userId = localStorage.getItem("userId");
|
||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/chats?userId=` + userId, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -65,14 +65,14 @@ const Page = () => {
|
|||
</div>
|
||||
<hr className="border-t border-[#2B2C2C] my-4 w-full"/>
|
||||
</div>
|
||||
{chats.length === 0 && (
|
||||
{chats && 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>
|
||||
</div>
|
||||
)}
|
||||
{chats.length > 0 && (
|
||||
{chats && chats.length > 0 && (
|
||||
<div className="flex flex-col pb-20 lg:pb-2">
|
||||
{chats.map((chat, i) => (
|
||||
<div
|
||||
|
|
|
@ -525,7 +525,7 @@ const ChatWindow = ({id}: { id?: string }) => {
|
|||
focusMode: focusMode,
|
||||
copilotEnabled: copilotEnabled,
|
||||
optimizationMode: optimizationMode,
|
||||
history: [...chatHistory, ['human', message]],
|
||||
history: [],
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue