mail page ui correction maj 6
This commit is contained in:
parent
0ad7e04bfb
commit
11ef993541
@ -558,11 +558,21 @@ export default function MailPage() {
|
|||||||
const email = emails.find(e => e.id === emailId);
|
const email = emails.find(e => e.id === emailId);
|
||||||
if (email) {
|
if (email) {
|
||||||
setSelectedEmail(email);
|
setSelectedEmail(email);
|
||||||
// Mark as read
|
if (!email.read) {
|
||||||
const updatedEmails = emails.map(e =>
|
// Mark as read in state
|
||||||
e.id === emailId ? { ...e, read: true } : e
|
setEmails(emails.map(e =>
|
||||||
);
|
e.id === emailId ? { ...e, read: true } : e
|
||||||
setEmails(updatedEmails);
|
));
|
||||||
|
|
||||||
|
// Update read status on server
|
||||||
|
fetch('/api/mail/mark-read', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ emailId })
|
||||||
|
}).catch(error => {
|
||||||
|
console.error('Error marking email as read:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1037,36 +1047,29 @@ export default function MailPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Delete Confirmation Dialog */}
|
{/* Compose Email Modal */}
|
||||||
<AlertDialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>
|
|
||||||
{deleteType === 'email' ? 'Delete Email' :
|
|
||||||
deleteType === 'emails' ? 'Delete Selected Emails' :
|
|
||||||
'Delete Account'}
|
|
||||||
</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>
|
|
||||||
This action cannot be undone.
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
||||||
<AlertDialogAction onClick={handleDeleteConfirm}>Delete</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
|
|
||||||
{/* Compose Modal */}
|
|
||||||
{showCompose && (
|
{showCompose && (
|
||||||
<div className="fixed inset-0 bg-black/50 z-50">
|
<div className="fixed inset-0 bg-black/50 z-50">
|
||||||
<div className="absolute inset-4 sm:inset-6 md:inset-8 bg-white rounded-lg shadow-xl flex flex-col">
|
<div className="absolute inset-4 sm:inset-6 md:inset-8 bg-white rounded-lg shadow-xl flex flex-col">
|
||||||
<div className="flex items-center justify-between p-4 border-b">
|
<div className="flex items-center justify-between p-4 border-b">
|
||||||
<h2 className="text-lg font-semibold">New Message</h2>
|
<h2 className="text-lg font-semibold">New Message</h2>
|
||||||
<Button variant="ghost" size="icon" onClick={() => setShowCompose(false)}>
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
onClick={() => {
|
||||||
|
setShowCompose(false);
|
||||||
|
setComposeTo('');
|
||||||
|
setComposeSubject('');
|
||||||
|
setComposeBody('');
|
||||||
|
setShowCc(false);
|
||||||
|
setComposeCc('');
|
||||||
|
setComposeBcc('');
|
||||||
|
}}
|
||||||
|
>
|
||||||
<X className="h-4 w-4" />
|
<X className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="p-4 flex-1 overflow-auto space-y-4">
|
<div className="p-4 flex-1 overflow-auto space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="to">To</Label>
|
<Label htmlFor="to">To</Label>
|
||||||
@ -1074,15 +1077,16 @@ export default function MailPage() {
|
|||||||
id="to"
|
id="to"
|
||||||
value={composeTo}
|
value={composeTo}
|
||||||
onChange={(e) => setComposeTo(e.target.value)}
|
onChange={(e) => setComposeTo(e.target.value)}
|
||||||
|
placeholder="recipient@example.com"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* CC/BCC controls */}
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => setShowCc(!showCc)}
|
onClick={() => setShowCc(!showCc)}
|
||||||
|
className="text-gray-500"
|
||||||
>
|
>
|
||||||
{showCc ? 'Hide' : 'Show'} CC/BCC
|
{showCc ? 'Hide' : 'Show'} CC/BCC
|
||||||
</Button>
|
</Button>
|
||||||
@ -1096,6 +1100,7 @@ export default function MailPage() {
|
|||||||
id="cc"
|
id="cc"
|
||||||
value={composeCc}
|
value={composeCc}
|
||||||
onChange={(e) => setComposeCc(e.target.value)}
|
onChange={(e) => setComposeCc(e.target.value)}
|
||||||
|
placeholder="cc@example.com"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -1104,6 +1109,7 @@ export default function MailPage() {
|
|||||||
id="bcc"
|
id="bcc"
|
||||||
value={composeBcc}
|
value={composeBcc}
|
||||||
onChange={(e) => setComposeBcc(e.target.value)}
|
onChange={(e) => setComposeBcc(e.target.value)}
|
||||||
|
placeholder="bcc@example.com"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@ -1115,6 +1121,7 @@ export default function MailPage() {
|
|||||||
id="subject"
|
id="subject"
|
||||||
value={composeSubject}
|
value={composeSubject}
|
||||||
onChange={(e) => setComposeSubject(e.target.value)}
|
onChange={(e) => setComposeSubject(e.target.value)}
|
||||||
|
placeholder="Email subject"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -1125,12 +1132,24 @@ export default function MailPage() {
|
|||||||
value={composeBody}
|
value={composeBody}
|
||||||
onChange={(e) => setComposeBody(e.target.value)}
|
onChange={(e) => setComposeBody(e.target.value)}
|
||||||
className="min-h-[200px]"
|
className="min-h-[200px]"
|
||||||
|
placeholder="Write your message here..."
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="p-4 border-t flex justify-end gap-2">
|
<div className="p-4 border-t flex justify-end gap-2">
|
||||||
<Button variant="outline" onClick={() => setShowCompose(false)}>
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => {
|
||||||
|
setShowCompose(false);
|
||||||
|
setComposeTo('');
|
||||||
|
setComposeSubject('');
|
||||||
|
setComposeBody('');
|
||||||
|
setShowCc(false);
|
||||||
|
setComposeCc('');
|
||||||
|
setComposeBcc('');
|
||||||
|
}}
|
||||||
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button>Send</Button>
|
<Button>Send</Button>
|
||||||
@ -1138,6 +1157,31 @@ export default function MailPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Delete Confirmation Dialog */}
|
||||||
|
<AlertDialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>
|
||||||
|
{deleteType === 'email' ? 'Delete Email' :
|
||||||
|
deleteType === 'emails' ? 'Delete Selected Emails' :
|
||||||
|
'Delete Account'}
|
||||||
|
</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>
|
||||||
|
This action cannot be undone. Are you sure you want to proceed?
|
||||||
|
</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||||
|
<AlertDialogAction
|
||||||
|
onClick={handleDeleteConfirm}
|
||||||
|
className="bg-red-600 text-white hover:bg-red-700"
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user