diff --git a/components/DuesActionCard.vue b/components/DuesActionCard.vue index b2e0e06..1801f93 100644 --- a/components/DuesActionCard.vue +++ b/components/DuesActionCard.vue @@ -224,8 +224,9 @@ mdi-email @@ -280,6 +281,9 @@ const showPaymentDateDialog = ref(false); const selectedPaymentDate = ref(''); const selectedPaymentModel = ref(null); +// Reactive state for email sending +const emailLoading = ref(false); + // Initialize with today's date when dialog opens watch(showPaymentDateDialog, (isOpen) => { if (isOpen) { @@ -438,6 +442,38 @@ const confirmMarkAsPaid = async () => { // You could show an error message here if needed } }; + +const sendDuesReminder = async () => { + if (!props.member.email || emailLoading.value) return; + + emailLoading.value = true; + + try { + // Determine the reminder type based on the member's status + const reminderType = props.status === 'overdue' ? 'overdue' : 'due-soon'; + + const response = await $fetch<{ + success: boolean; + message: string; + data: any; + }>(`/api/members/${props.member.Id}/send-dues-reminder`, { + method: 'post', + body: { + reminderType + } + }); + + if (response?.success) { + console.log(`Dues reminder sent successfully to ${props.member.email}`); + // You could show a success toast here if needed + } + } catch (error: any) { + console.error('Error sending dues reminder:', error); + // You could show an error toast here if needed + } finally { + emailLoading.value = false; + } +};