feat: user registration and chat messaging (wip)
This commit is contained in:
parent
b0ce2fe0af
commit
18dd8b83f0
14 changed files with 243 additions and 33 deletions
17
client/src/contexts/ChatContext.tsx
Normal file
17
client/src/contexts/ChatContext.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { createContext, useContext } from "react";
|
||||
import { ChatMessage, User } from "../../../shared";
|
||||
|
||||
interface ChatContextType {
|
||||
messages: ChatMessage[];
|
||||
currentUser: User | null;
|
||||
addMessage: (message: ChatMessage) => void;
|
||||
setCurrentUser: (user: User) => void;
|
||||
}
|
||||
|
||||
export const ChatContext = createContext<ChatContextType | null>(null);
|
||||
|
||||
export const useChatState = () => {
|
||||
const context = useContext(ChatContext);
|
||||
if (!context) throw new Error("useChat must be used within ChatProvider");
|
||||
return context;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue