mail page imap connection 11
This commit is contained in:
parent
d6065d4934
commit
790e7ed940
@ -41,22 +41,22 @@ interface Email {
|
|||||||
category: string;
|
category: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add MIME decoding function
|
// Update MIME decoding function for better formatting
|
||||||
const decodeMimeContent = (content: string) => {
|
const decodeMimeContent = (content: string) => {
|
||||||
try {
|
try {
|
||||||
// Remove MIME headers
|
// Remove MIME headers and metadata
|
||||||
const contentWithoutHeaders = content.replace(/^.*?Content-Type:.*?\n\n/s, '');
|
const contentWithoutHeaders = content.replace(/^.*?Content-Type:.*?\n\n/s, '')
|
||||||
|
.replace(/---InfomaniakPhpMail.*?Content-Transfer-Encoding:.*?\n/g, '')
|
||||||
// Decode quoted-printable
|
.replace(/=C2=A0/g, ' ') // Replace non-breaking spaces
|
||||||
const decoded = contentWithoutHeaders
|
|
||||||
.replace(/=\n/g, '') // Remove soft line breaks
|
.replace(/=\n/g, '') // Remove soft line breaks
|
||||||
.replace(/=([0-9A-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
|
.replace(/=([0-9A-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
|
||||||
.replace(/=C2=A0/g, ' ') // Replace non-breaking spaces
|
.replace(/\[IMG:.*?\]/g, '') // Remove image placeholders
|
||||||
.replace(/\[LINK: (.*?)\]/g, '$1') // Format links
|
.replace(/\[LINK:\s*(.*?)\s*\]/g, '$1') // Clean up links
|
||||||
.replace(/\[IMG: (.*?)\]/g, '') // Remove image placeholders
|
.replace(/\*([^*]+)\*/g, '$1') // Remove asterisks
|
||||||
|
.replace(/\s+/g, ' ') // Normalize whitespace
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
return decoded;
|
return contentWithoutHeaders;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error decoding MIME content:', error);
|
console.error('Error decoding MIME content:', error);
|
||||||
return content;
|
return content;
|
||||||
@ -309,22 +309,44 @@ export default function MailPage() {
|
|||||||
{/* Sidebar */}
|
{/* Sidebar */}
|
||||||
<div className={`${sidebarOpen ? 'w-72' : 'w-20'} bg-white/95 backdrop-blur-sm border-0 shadow-lg flex flex-col transition-all duration-300 ease-in-out
|
<div className={`${sidebarOpen ? 'w-72' : 'w-20'} bg-white/95 backdrop-blur-sm border-0 shadow-lg flex flex-col transition-all duration-300 ease-in-out
|
||||||
${mobileSidebarOpen ? 'fixed inset-y-0 left-0 z-40' : 'hidden'} md:block`}>
|
${mobileSidebarOpen ? 'fixed inset-y-0 left-0 z-40' : 'hidden'} md:block`}>
|
||||||
{/* Courrier Title */}
|
{/* Mail Title */}
|
||||||
<div className="p-3 border-b border-gray-100">
|
<div className="p-3 border-b border-gray-100">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<MessageSquare className="h-5 w-5 text-gray-600" />
|
<Mail className="h-5 w-5 text-gray-600" />
|
||||||
<span className="font-semibold text-gray-900">Courrier</span>
|
<span className="font-semibold text-gray-900">Mail</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Compose button */}
|
||||||
|
<div className="p-3 border-b border-gray-100">
|
||||||
|
<Button
|
||||||
|
className="w-full bg-blue-600 text-white rounded-lg hover:bg-blue-700 flex items-center justify-center transition-all py-2"
|
||||||
|
onClick={() => setComposeOpen(true)}
|
||||||
|
>
|
||||||
|
<div className="flex items-center">
|
||||||
|
<PlusIcon className="h-4 w-4" />
|
||||||
|
<span className="ml-2">Compose</span>
|
||||||
|
</div>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Accounts Section */}
|
{/* Accounts Section */}
|
||||||
<div className="p-3 border-b border-gray-100">
|
<div className="p-3 border-b border-gray-100">
|
||||||
<div className="text-sm font-medium text-gray-500 mb-2">Accounts</div>
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
className="w-full justify-between mb-2 text-sm font-medium text-gray-500"
|
||||||
|
onClick={() => setAccountsDropdownOpen(!accountsDropdownOpen)}
|
||||||
|
>
|
||||||
|
<span>Accounts</span>
|
||||||
|
{accountsDropdownOpen ? <ChevronUp className="h-4 w-4" /> : <ChevronDown className="h-4 w-4" />}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{accountsDropdownOpen && (
|
||||||
|
<div className="space-y-1 pl-2">
|
||||||
{/* All Accounts Option */}
|
{/* All Accounts Option */}
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="w-full justify-start px-2 py-1.5 text-sm mb-1"
|
className="w-full justify-start px-2 py-1.5 text-sm"
|
||||||
onClick={() => setSelectedAccount(0)}
|
onClick={() => setSelectedAccount(0)}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2 w-full">
|
<div className="flex items-center gap-2 w-full">
|
||||||
@ -338,7 +360,7 @@ export default function MailPage() {
|
|||||||
<div key={account.id} className="relative group">
|
<div key={account.id} className="relative group">
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="w-full justify-between px-2 py-1.5 text-sm mb-1 group"
|
className="w-full justify-between px-2 py-1.5 text-sm group"
|
||||||
onClick={() => setSelectedAccount(account.id)}
|
onClick={() => setSelectedAccount(account.id)}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@ -399,21 +421,8 @@ export default function MailPage() {
|
|||||||
Add Account
|
Add Account
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Compose button */}
|
|
||||||
<Button
|
|
||||||
className={`mx-3 mt-3 mb-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 flex items-center justify-center transition-all ${sidebarOpen ? 'py-2 px-4' : 'p-2'}`}
|
|
||||||
onClick={() => setComposeOpen(true)}
|
|
||||||
>
|
|
||||||
{sidebarOpen ? (
|
|
||||||
<div className="flex items-center">
|
|
||||||
<PlusIcon className="h-4 w-4" />
|
|
||||||
<span className="ml-2">Compose</span>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<PlusIcon className="h-4 w-4" />
|
|
||||||
)}
|
)}
|
||||||
</Button>
|
</div>
|
||||||
|
|
||||||
{/* Navigation */}
|
{/* Navigation */}
|
||||||
<nav className="flex-1 overflow-y-auto py-2">
|
<nav className="flex-1 overflow-y-auto py-2">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user