diff --git a/src/components/shared/FailedEmailsTable.tsx b/src/components/shared/FailedEmailsTable.tsx index f3531b6..8dcc3b8 100644 --- a/src/components/shared/FailedEmailsTable.tsx +++ b/src/components/shared/FailedEmailsTable.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { failedEmailsService, type FailedEmail } from '../../services/failed-emails-service'; -import { DataTable } from './DataTable'; +import { DataTable, type Column } from './DataTable'; import { Modal } from './Modal'; import { Button } from '@/components/ui/button'; import { StatusBadge } from './StatusBadge'; @@ -8,6 +8,8 @@ import { Eye, RefreshCw, Trash2, Loader2 } from 'lucide-react'; import { format } from 'date-fns'; import { toast } from 'sonner'; import { Pagination } from './Pagination'; +import { ActionDropdown } from './ActionDropdown'; +import { PrimaryButton } from './PrimaryButton'; export const FailedEmailsTable: React.FC = () => { const [emails, setEmails] = useState([]); @@ -84,7 +86,7 @@ export const FailedEmailsTable: React.FC = () => { setIsModalVisible(true); }; - const columns = [ + const columns: Column[] = [ { label: 'Date', key: 'created_at', @@ -112,80 +114,81 @@ export const FailedEmailsTable: React.FC = () => { { label: 'Actions', key: 'actions', + align: 'right', render: (record: FailedEmail) => ( -
- - {record.status === 'failed' && ( - - )} - +
+ showEmailDetails(record), + icon: + }, + ...(record.status === 'failed' + ? [ + { + label: resendingId === record.id ? 'Resending...' : 'Resend Email', + onClick: () => handleResend(record.id), + icon: resendingId === record.id ? ( + + ) : ( + + ) + } + ] + : []), + { + label: 'Delete Email', + onClick: () => handleDelete(record.id), + icon: , + variant: 'danger' + } + ]} + />
) } ]; return ( -
-
-

Failed Emails Log

-
- - +
-
- item.id} - isLoading={loading} - emptyMessage="No failed emails found" - error={error} - /> - - {total > limit && ( + {/* Table Section */} + item.id} + isLoading={loading} + emptyMessage="No failed emails found" + error={error} + /> + + {/* Pagination Footer */} + {total > limit && ( +
{ fetchEmails(1, newLimit); }} /> - )} -
+
+ )} + {/* Modal Details */} { {selectedEmail && (
-

To: {selectedEmail.to_email}

-

Subject: {selectedEmail.subject}

-

Error Message: {selectedEmail.error_message}

+

To: {selectedEmail.to_email}

+

Subject: {selectedEmail.subject}

+

Error Message: {selectedEmail.error_message}

- Body: + Body:
{ {isOpen && ( -
+
{/* Header */} -
+

Notifications

@@ -206,7 +206,7 @@ export const NotificationBell = () => {
{/* List */} -
+
{notifications.length === 0 ? (
@@ -296,7 +296,7 @@ export const NotificationBell = () => {
{/* Footer */} -
+