-
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
1 parent
3cf0fa9
commit 7777a02
Showing
11 changed files
with
362 additions
and
214 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
5 changes: 5 additions & 0 deletions
5
migrations/20231116051633_add_user_id_to_conversation_model/migration.sql
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,5 @@ | ||
-- AlterTable | ||
ALTER TABLE "Conversation" ADD COLUMN "userId" INTEGER; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Conversation" ADD CONSTRAINT "Conversation_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
import { useState, useEffect, useRef } from "react"; | ||
|
||
import { useQuery } from "@wasp/queries"; | ||
import getChats from "@wasp/queries/getChats"; | ||
import type { Chat } from "@wasp/entities"; | ||
|
||
import CreateNewChatBtn from "./components/CreateNewChat"; | ||
import ChatsList from "./components/ChatList"; | ||
import ConversationWrapper from "./components/ConversationWrapper"; | ||
|
||
export default function ChatPage() { | ||
let { data: chats, isLoading: isLoadingChats } = useQuery(getChats); | ||
|
||
return ( | ||
<div className="relative z-0 flex h-full w-full overflow-hidden h-screen"> | ||
<div | ||
id="default-sidebar" | ||
className="md:w-[260px] flex-shrink-0 overflow-x-hidden dark bg-captn-dark-blue" | ||
aria-label="Sidebar" | ||
> | ||
<div | ||
style={{ borderRight: "1px solid #eae4d9" }} | ||
className="border-x-captn-light-cream h-full px-3 py-4 overflow-y-auto bg-captn-dark-blue" | ||
> | ||
<CreateNewChatBtn /> | ||
<div className="flex-col flex-1 transition-opacity duration-500 -mr-2 pr-2 overflow-y-auto"> | ||
<ul className="py-5 space-y-2 font-medium"> | ||
{ | ||
// Todo: remove the below ignore comment | ||
// @ts-ignore | ||
chats && <ChatsList chats={chats} /> | ||
} | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="relative z-0 flex h-full w-full overflow-hidden h-screen"> | ||
<ConversationWrapper /> | ||
</div> | ||
</div> | ||
); | ||
} |
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,36 @@ | ||
import { Link } from "@wasp/router"; | ||
import type { Chat } from "@wasp/entities"; | ||
|
||
export default function ChatsList(chats: Chat[]) { | ||
return ( | ||
<div> | ||
{ | ||
// Todo: remove the below ignore comment | ||
// @ts-ignore | ||
chats.chats.map((chat, idx) => ( | ||
<Link key={chat.id} to="/chat/:id?" params={{ id: chat.id }}> | ||
<li key={idx}> | ||
<div className="flex items-center p-2 text-white hover:bg-captn-light-blue hover:text-captn-dark-blue group rounded-lg "> | ||
<svg | ||
stroke="currentColor" | ||
fill="none" | ||
strokeWidth="2" | ||
viewBox="0 0 24 24" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
className="icon-sm" | ||
height="1em" | ||
width="1em" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path> | ||
</svg> | ||
<span className="ml-3">{chat.id}</span> | ||
</div> | ||
</li> | ||
</Link> | ||
)) | ||
} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.