forked from matijagrcic/azurechatgpt
-
Notifications
You must be signed in to change notification settings - Fork 45
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
1 parent
75c2c5b
commit d82e242
Showing
1 changed file
with
28 additions
and
38 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 |
---|---|---|
@@ -1,46 +1,36 @@ | ||
'use client' | ||
import { FC, useEffect, useState } from 'react'; | ||
import { Menu, MenuContent, MenuFooter, MenuHeader } from '@/components/menu'; | ||
import { FindAllChatThreadForCurrentUser } from '@/features/chat/chat-services/chat-thread-service'; | ||
import { ThemeToggle } from '@/features/theme/theme-toggle'; | ||
import { MenuItems } from './menu-items'; | ||
import { NewChat } from './new-chat'; | ||
import { Menu, MenuContent, MenuFooter, MenuHeader } from "@/components/menu"; | ||
import { FindAllChatThreadForCurrentUser } from "@/features/chat/chat-services/chat-thread-service"; | ||
import { ThemeToggle } from "@/features/theme/theme-toggle"; | ||
import { MenuItems } from "./menu-items"; | ||
import { NewChat } from "./new-chat"; | ||
import { useState } from "react"; | ||
|
||
type Prop = {}; | ||
|
||
export const ChatMenu: FC<Prop> = (prop) => { | ||
export const ChatMenu = () => { | ||
const [isCollapsed, setIsCollapsed] = useState(true); | ||
const [items, setItems] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
const data = await FindAllChatThreadForCurrentUser(); | ||
setItems(data); | ||
}; | ||
fetchData(); | ||
}, []); | ||
const toggleMenu = () => { | ||
setIsCollapsed(!isCollapsed); | ||
}; | ||
|
||
const [isOpen, setIsOpen] = useState(false); | ||
FindAllChatThreadForCurrentUser().then((data) => { | ||
setItems(data); | ||
}); | ||
|
||
return ( | ||
<div> | ||
<button onClick={() => setIsOpen(!isOpen)}> | ||
{isOpen ? '-' : '+'} | ||
</button> | ||
{isOpen ? ( | ||
<Menu> | ||
<MenuHeader className="justify-end"> | ||
<NewChat /> | ||
</MenuHeader> | ||
<MenuContent> | ||
<MenuItems menuItems={items} /> | ||
</MenuContent> | ||
<MenuFooter> | ||
<div className="flex flex-col gap-3"> | ||
<ThemeToggle /> | ||
</div> | ||
</MenuFooter> | ||
</Menu> | ||
) : null} | ||
</div> | ||
<Menu> | ||
<MenuHeader className="justify-end"> | ||
<NewChat /> | ||
</MenuHeader> | ||
<MenuContent> | ||
{!isCollapsed && <MenuItems menuItems={items} />} | ||
</MenuContent> | ||
<MenuFooter> | ||
<div className="flex flex-col gap-3"> | ||
<button onClick={toggleMenu}>Toggle Menu</button> | ||
<ThemeToggle /> | ||
</div> | ||
</MenuFooter> | ||
</Menu> | ||
); | ||
}; |