feat: Implement mobile responsive layout for the messaging page, enabling toggling between the conversation list and chat view on smaller screens.
This commit is contained in:
@@ -163,6 +163,7 @@ export function MessagingPage({ initialConversationId }: { initialConversationId
|
|||||||
const [isStartingConversation, setIsStartingConversation] = useState<string | null>(null);
|
const [isStartingConversation, setIsStartingConversation] = useState<string | null>(null);
|
||||||
const [isComposeOpen, setIsComposeOpen] = useState(false);
|
const [isComposeOpen, setIsComposeOpen] = useState(false);
|
||||||
const [isReportModalOpen, setIsReportModalOpen] = useState(false);
|
const [isReportModalOpen, setIsReportModalOpen] = useState(false);
|
||||||
|
const [showMobileChat, setShowMobileChat] = useState(false);
|
||||||
// Store converted avatar URLs by conversation ID
|
// Store converted avatar URLs by conversation ID
|
||||||
const [conversationAvatarUrls, setConversationAvatarUrls] = useState<Record<string, string>>({});
|
const [conversationAvatarUrls, setConversationAvatarUrls] = useState<Record<string, string>>({});
|
||||||
// Store converted file URLs by message ID (for S3-stored images/files)
|
// Store converted file URLs by message ID (for S3-stored images/files)
|
||||||
@@ -314,6 +315,7 @@ export function MessagingPage({ initialConversationId }: { initialConversationId
|
|||||||
) {
|
) {
|
||||||
initialConvHandledRef.current = initialConversationId;
|
initialConvHandledRef.current = initialConversationId;
|
||||||
selectConversation(initialConversationId);
|
selectConversation(initialConversationId);
|
||||||
|
setShowMobileChat(true);
|
||||||
}
|
}
|
||||||
}, [initialConversationId, conversations, isLoading, selectConversation]);
|
}, [initialConversationId, conversations, isLoading, selectConversation]);
|
||||||
|
|
||||||
@@ -687,8 +689,8 @@ export function MessagingPage({ initialConversationId }: { initialConversationId
|
|||||||
|
|
||||||
{/* Main content */}
|
{/* Main content */}
|
||||||
<div className="flex h-[700px]">
|
<div className="flex h-[700px]">
|
||||||
{/* Left sidebar - Conversation list */}
|
{/* Left sidebar - Conversation list (hidden on mobile when chat is open) */}
|
||||||
<div className="w-[380px] border-r border-[#00293d]/10 flex-shrink-0 overflow-hidden flex flex-col">
|
<div className={`w-full md:w-[380px] border-r border-[#00293d]/10 flex-shrink-0 overflow-hidden flex flex-col ${showMobileChat ? 'hidden md:flex' : 'flex'}`}>
|
||||||
{isLoading || isLoadingAgents ? (
|
{isLoading || isLoadingAgents ? (
|
||||||
<div className="flex-1 flex items-center justify-center">
|
<div className="flex-1 flex items-center justify-center">
|
||||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]" />
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]" />
|
||||||
@@ -779,7 +781,7 @@ export function MessagingPage({ initialConversationId }: { initialConversationId
|
|||||||
{filteredConversations.map((conversation) => (
|
{filteredConversations.map((conversation) => (
|
||||||
<div
|
<div
|
||||||
key={conversation.id}
|
key={conversation.id}
|
||||||
onClick={() => selectConversation(conversation.id)}
|
onClick={() => { selectConversation(conversation.id); setShowMobileChat(true); }}
|
||||||
className="relative flex items-start gap-3 p-4 rounded-[15px] cursor-pointer transition-colors hover:bg-[#00293d]/5"
|
className="relative flex items-start gap-3 p-4 rounded-[15px] cursor-pointer transition-colors hover:bg-[#00293d]/5"
|
||||||
style={{ border: '1px solid rgba(0, 41, 61, 0.1)' }}
|
style={{ border: '1px solid rgba(0, 41, 61, 0.1)' }}
|
||||||
>
|
>
|
||||||
@@ -837,10 +839,20 @@ export function MessagingPage({ initialConversationId }: { initialConversationId
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right panel - Chat area */}
|
{/* Right panel - Chat area (full width on mobile, hidden when no conversation on mobile) */}
|
||||||
<div className="flex-1 flex flex-col p-4">
|
<div className={`flex-1 flex flex-col p-4 ${showMobileChat ? 'flex' : 'hidden md:flex'}`}>
|
||||||
{currentConversation && selectedUserInfo ? (
|
{currentConversation && selectedUserInfo ? (
|
||||||
<>
|
<>
|
||||||
|
{/* Mobile back button */}
|
||||||
|
<button
|
||||||
|
onClick={() => setShowMobileChat(false)}
|
||||||
|
className="md:hidden flex items-center gap-2 mb-3 hover:opacity-70 transition-opacity cursor-pointer"
|
||||||
|
>
|
||||||
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
|
||||||
|
<path d="M19 12H5M5 12L12 19M5 12L12 5" stroke="#00293D" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
<span className="font-fractul font-medium text-[14px] text-[#00293D]">Back</span>
|
||||||
|
</button>
|
||||||
{/* Chat header */}
|
{/* Chat header */}
|
||||||
<ChatHeader
|
<ChatHeader
|
||||||
{...selectedUserInfo}
|
{...selectedUserInfo}
|
||||||
|
|||||||
Reference in New Issue
Block a user