-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
15 changed files
with
387 additions
and
108 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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const EmptyState = () => { | ||
return ( | ||
<div className="px-4 py-10 sm:px-6 lg:px-8 h-full flex justify-center items-center bg-gray-100"> | ||
<div className="text-center items-center flex flex-col"> | ||
<h3 className="mt-2 text-2xl font-semibold text-gray-900"> | ||
Select a chat or start a new conversation | ||
</h3> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default EmptyState |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use client' | ||
|
||
import clsx from 'clsx' | ||
import Link from 'next/link' | ||
|
||
interface DesktopItemProps { | ||
label: string | ||
icon: any | ||
href: string | ||
onClick?: () => void | ||
active?: boolean | ||
} | ||
|
||
const DesktopItem: React.FC<DesktopItemProps> = ({ | ||
label, | ||
icon: Icon, | ||
href, | ||
onClick, | ||
active, | ||
}) => { | ||
const handleClick = () => { | ||
if (onClick) { | ||
return onClick() | ||
} | ||
} | ||
|
||
return ( | ||
<li onClick={handleClick}> | ||
<Link | ||
href={href} | ||
className={clsx( | ||
`group flex gap-x-3 rounded-md p-3 text-sm leading-6 font-semibold text-gray-500 hover:text-black hover:bg-gray-100`, | ||
active && 'bg-gray-100 text-black' | ||
)} | ||
> | ||
<Icon className="h-6 w-6 shrink-0" /> | ||
<span className="sr-only">{label}</span> | ||
</Link> | ||
</li> | ||
) | ||
} | ||
|
||
export default DesktopItem |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use client' | ||
|
||
import useRoutes from '@/app/hooks/useRoutes' | ||
import { useState } from 'react' | ||
import DesktopItem from './DesktopItem' | ||
|
||
const DesktopSidebar = () => { | ||
const routes = useRoutes() | ||
const [isOpen, setIsOpen] = useState(false) | ||
return ( | ||
<div className="hidden lg:fixed lg:inset-y-0 lg:left-0 lg:z-40 lg:w-20 xl:px-6 lg:overflow-y-auto lg:bg-white lg:border-r-[1px] lg:pb-4 lg:flex lg:flex-col justify-between"> | ||
<nav className="mt-4 flex-4 flex-col justify-between"> | ||
<ul role="list" className="flex flex-col items-center space-y-1"> | ||
{routes.map((item) => ( | ||
<DesktopItem | ||
key={item.label} | ||
href={item.href} | ||
label={item.label} | ||
icon={item.icon} | ||
active={item.active} | ||
onClick={item.onClick} | ||
/> | ||
))} | ||
</ul> | ||
</nav> | ||
</div> | ||
) | ||
} | ||
|
||
export default DesktopSidebar |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use client' | ||
|
||
import useConversation from '@/app/hooks/useConversation' | ||
import useRoutes from '@/app/hooks/useRoutes' | ||
import MobileItem from './MobileItem' | ||
|
||
const MobileFooter = () => { | ||
const routes = useRoutes() | ||
const { isOpen } = useConversation() | ||
if (isOpen) return null | ||
return ( | ||
<div className="fixed justify-between w-full bottom-0 z-40 flex items-center bg-white border-t-[1px] lg:hidden"> | ||
{routes.map((route) => ( | ||
<MobileItem | ||
key={route.href} | ||
href={route.href} | ||
active={route.active} | ||
icon={route.icon} | ||
onClick={route.onClick} | ||
/> | ||
))}{' '} | ||
</div> | ||
) | ||
} | ||
|
||
export default MobileFooter |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use client' | ||
|
||
import clsx from 'clsx' | ||
import Link from 'next/link' | ||
|
||
interface MobileItemProps { | ||
icon: any | ||
href: string | ||
onClick?: () => void | ||
active?: boolean | ||
} | ||
|
||
const MobileItem: React.FC<MobileItemProps> = ({ | ||
href, | ||
icon: Icon, | ||
active, | ||
onClick, | ||
}) => { | ||
const handleClick = () => { | ||
if (onClick) { | ||
return onClick() | ||
} | ||
} | ||
return ( | ||
<Link | ||
href={href} | ||
onClick={onClick} | ||
className={clsx( | ||
`group flex gap-x-3 text-sm leading-6 font-semibold w-full justify-center p-4 text-gray-500 hover:text-black hover:bg-gray-100`, | ||
active && 'bg-gray-100 text-black' | ||
)} | ||
> | ||
<Icon className="h-6 w-6" /> | ||
</Link> | ||
) | ||
} | ||
|
||
export default MobileItem |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import DesktopSidebar from './DesktopSidebar' | ||
import MobileFooter from './MobileFooter' | ||
|
||
async function Sidebar({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<div className="h-full"> | ||
<DesktopSidebar /> | ||
<MobileFooter /> | ||
<main className="lg:pl-20 h-full"> {children}</main> | ||
</div> | ||
) | ||
} | ||
|
||
export default Sidebar |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client' | ||
|
||
import { SessionProvider } from 'next-auth/react' | ||
|
||
interface AuthContextProps { | ||
children: React.ReactNode | ||
} | ||
|
||
export default function AuthContext({ children }: AuthContextProps) { | ||
return <SessionProvider>{children}</SessionProvider> | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useParams } from 'next/navigation' | ||
import { useMemo } from 'react' | ||
|
||
const useConversation = () => { | ||
const params = useParams() | ||
|
||
const conversationId = useMemo(() => { | ||
if (!params?.conversationId) { | ||
return '' | ||
} | ||
return params.conversationId as string | ||
}, [params?.conversationId]) | ||
|
||
const isOpen = useMemo(() => !!conversationId, [conversationId]) | ||
|
||
return useMemo( | ||
() => ({ | ||
isOpen, | ||
conversationId, | ||
}), | ||
[isOpen, conversationId] | ||
) | ||
} | ||
|
||
export default useConversation |
Oops, something went wrong.