Spaces:
Paused
Paused
Upload 60 files
Browse files
client/src/components/chat/ChatSidebar.tsx
CHANGED
|
@@ -6,14 +6,12 @@ import { Input } from '@/components/ui/input'
|
|
| 6 |
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
| 7 |
import { Badge } from '@/components/ui/badge'
|
| 8 |
import { ScrollArea } from '@/components/ui/scroll-area'
|
| 9 |
-
import {
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
Settings,
|
| 14 |
MessageSquare,
|
| 15 |
-
Users
|
| 16 |
-
MoreVertical
|
| 17 |
} from 'lucide-react'
|
| 18 |
import { formatTime, getInitials } from '@/lib/utils'
|
| 19 |
|
|
|
|
| 6 |
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
| 7 |
import { Badge } from '@/components/ui/badge'
|
| 8 |
import { ScrollArea } from '@/components/ui/scroll-area'
|
| 9 |
+
import {
|
| 10 |
+
Search,
|
| 11 |
+
Plus,
|
| 12 |
+
Settings,
|
|
|
|
| 13 |
MessageSquare,
|
| 14 |
+
Users
|
|
|
|
| 15 |
} from 'lucide-react'
|
| 16 |
import { formatTime, getInitials } from '@/lib/utils'
|
| 17 |
|
client/src/components/chat/ChatWindow.tsx
CHANGED
|
@@ -5,13 +5,12 @@ import { Button } from '@/components/ui/button'
|
|
| 5 |
import { Input } from '@/components/ui/input'
|
| 6 |
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
| 7 |
import { ScrollArea } from '@/components/ui/scroll-area'
|
| 8 |
-
import {
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
Video,
|
| 15 |
MoreVertical,
|
| 16 |
Users,
|
| 17 |
Info
|
|
@@ -22,7 +21,6 @@ export default function ChatWindow() {
|
|
| 22 |
const { user } = useAuthStore()
|
| 23 |
const { currentChat, messages, sendMessage, loading } = useChatStore()
|
| 24 |
const [messageText, setMessageText] = useState('')
|
| 25 |
-
const [isTyping, setIsTyping] = useState(false)
|
| 26 |
const messagesEndRef = useRef<HTMLDivElement>(null)
|
| 27 |
const inputRef = useRef<HTMLInputElement>(null)
|
| 28 |
|
|
|
|
| 5 |
import { Input } from '@/components/ui/input'
|
| 6 |
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
| 7 |
import { ScrollArea } from '@/components/ui/scroll-area'
|
| 8 |
+
import {
|
| 9 |
+
Send,
|
| 10 |
+
Paperclip,
|
| 11 |
+
Smile,
|
| 12 |
+
Phone,
|
| 13 |
+
Video,
|
|
|
|
| 14 |
MoreVertical,
|
| 15 |
Users,
|
| 16 |
Info
|
|
|
|
| 21 |
const { user } = useAuthStore()
|
| 22 |
const { currentChat, messages, sendMessage, loading } = useChatStore()
|
| 23 |
const [messageText, setMessageText] = useState('')
|
|
|
|
| 24 |
const messagesEndRef = useRef<HTMLDivElement>(null)
|
| 25 |
const inputRef = useRef<HTMLInputElement>(null)
|
| 26 |
|
client/src/pages/AdminPage.tsx
CHANGED
|
@@ -1,9 +1,6 @@
|
|
| 1 |
import { useState, useEffect } from 'react'
|
| 2 |
import { Routes, Route, Link, useLocation } from 'react-router-dom'
|
| 3 |
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
| 4 |
-
import { Button } from '@/components/ui/button'
|
| 5 |
-
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
| 6 |
-
import { Badge } from '@/components/ui/badge'
|
| 7 |
import {
|
| 8 |
Users,
|
| 9 |
MessageSquare,
|
|
@@ -26,7 +23,7 @@ const mockStats = {
|
|
| 26 |
}
|
| 27 |
|
| 28 |
export default function AdminPage() {
|
| 29 |
-
const [stats
|
| 30 |
const location = useLocation()
|
| 31 |
|
| 32 |
useEffect(() => {
|
|
|
|
| 1 |
import { useState, useEffect } from 'react'
|
| 2 |
import { Routes, Route, Link, useLocation } from 'react-router-dom'
|
| 3 |
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
|
|
|
|
|
|
|
|
|
| 4 |
import {
|
| 5 |
Users,
|
| 6 |
MessageSquare,
|
|
|
|
| 23 |
}
|
| 24 |
|
| 25 |
export default function AdminPage() {
|
| 26 |
+
const [stats] = useState(mockStats)
|
| 27 |
const location = useLocation()
|
| 28 |
|
| 29 |
useEffect(() => {
|
client/src/services/socketService.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import { io, Socket } from 'socket.io-client'
|
| 2 |
-
import { Message, User, Chat
|
| 3 |
|
| 4 |
class SocketService {
|
| 5 |
private socket: Socket | null = null
|
|
|
|
| 1 |
import { io, Socket } from 'socket.io-client'
|
| 2 |
+
import { Message, User, Chat } from '../../../shared/types'
|
| 3 |
|
| 4 |
class SocketService {
|
| 5 |
private socket: Socket | null = null
|
client/src/store/chatStore.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import { create } from 'zustand'
|
| 2 |
-
import { Chat, Message
|
| 3 |
import { chatService } from '../services/chatService'
|
| 4 |
|
| 5 |
interface ChatState {
|
|
@@ -36,7 +36,7 @@ interface ChatActions {
|
|
| 36 |
addMessage: (message: Message) => void
|
| 37 |
updateMessage: (message: Message) => void
|
| 38 |
removeMessage: (messageId: string) => void
|
| 39 |
-
|
| 40 |
|
| 41 |
// Typing indicators
|
| 42 |
setTyping: (chatId: string, userId: string, isTyping: boolean) => void
|
|
@@ -145,7 +145,7 @@ export const useChatStore = create<ChatState & ChatActions>((set, get) => ({
|
|
| 145 |
|
| 146 |
sendMessage: async (chatId: string, content: string, attachments?: File[]) => {
|
| 147 |
try {
|
| 148 |
-
|
| 149 |
content,
|
| 150 |
type: 'text',
|
| 151 |
attachments
|
|
@@ -228,7 +228,7 @@ export const useChatStore = create<ChatState & ChatActions>((set, get) => ({
|
|
| 228 |
})
|
| 229 |
},
|
| 230 |
|
| 231 |
-
|
| 232 |
set(state => ({
|
| 233 |
chats: state.chats.map(c => c.id === chat.id ? chat : c),
|
| 234 |
currentChat: state.currentChat?.id === chat.id ? chat : state.currentChat
|
|
|
|
| 1 |
import { create } from 'zustand'
|
| 2 |
+
import { Chat, Message } from '../../../shared/types'
|
| 3 |
import { chatService } from '../services/chatService'
|
| 4 |
|
| 5 |
interface ChatState {
|
|
|
|
| 36 |
addMessage: (message: Message) => void
|
| 37 |
updateMessage: (message: Message) => void
|
| 38 |
removeMessage: (messageId: string) => void
|
| 39 |
+
updateChatFromSocket: (chat: Chat) => void
|
| 40 |
|
| 41 |
// Typing indicators
|
| 42 |
setTyping: (chatId: string, userId: string, isTyping: boolean) => void
|
|
|
|
| 145 |
|
| 146 |
sendMessage: async (chatId: string, content: string, attachments?: File[]) => {
|
| 147 |
try {
|
| 148 |
+
await chatService.sendMessage(chatId, {
|
| 149 |
content,
|
| 150 |
type: 'text',
|
| 151 |
attachments
|
|
|
|
| 228 |
})
|
| 229 |
},
|
| 230 |
|
| 231 |
+
updateChatFromSocket: (chat: Chat) => {
|
| 232 |
set(state => ({
|
| 233 |
chats: state.chats.map(c => c.id === chat.id ? chat : c),
|
| 234 |
currentChat: state.currentChat?.id === chat.id ? chat : state.currentChat
|
client/src/vite-env.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/// <reference types="vite/client" />
|
| 2 |
+
|
| 3 |
+
interface ImportMetaEnv {
|
| 4 |
+
readonly VITE_API_URL: string
|
| 5 |
+
readonly VITE_SOCKET_URL: string
|
| 6 |
+
readonly VITE_WS_URL: string
|
| 7 |
+
readonly VITE_APP_NAME: string
|
| 8 |
+
readonly VITE_APP_VERSION: string
|
| 9 |
+
// more env variables...
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
interface ImportMeta {
|
| 13 |
+
readonly env: ImportMetaEnv
|
| 14 |
+
}
|
shared/types/index.ts
CHANGED
|
@@ -86,6 +86,7 @@ export interface Message {
|
|
| 86 |
reactions: MessageReaction[]
|
| 87 |
isEdited: boolean
|
| 88 |
isDeleted: boolean
|
|
|
|
| 89 |
createdAt: Date
|
| 90 |
updatedAt: Date
|
| 91 |
}
|
|
|
|
| 86 |
reactions: MessageReaction[]
|
| 87 |
isEdited: boolean
|
| 88 |
isDeleted: boolean
|
| 89 |
+
status?: 'sent' | 'delivered' | 'read'
|
| 90 |
createdAt: Date
|
| 91 |
updatedAt: Date
|
| 92 |
}
|