diff --git a/pages/nft-book-store/collection/status/[collectionId].vue b/pages/nft-book-store/collection/status/[collectionId].vue index 69d6aed2..78b270a0 100644 --- a/pages/nft-book-store/collection/status/[collectionId].vue +++ b/pages/nft-book-store/collection/status/[collectionId].vue @@ -579,6 +579,16 @@ function getOrdersTableActionItems (purchaseListItem: any) { }]) } + if (purchaseListItem.status === 'paid') { + actionItems.push([{ + label: 'Send Reminder Email', + icon: 'i-heroicons-envelope', + click: () => { + sendReminderEmail(purchaseListItem) + } + }]) + } + if (['pendingNFT', 'paid'].includes(purchaseListItem.status)) { actionItems.push([{ label: 'Mark Complete', @@ -801,6 +811,32 @@ onMounted(async () => { } }) +async function sendReminderEmail (purchase: any) { + const orderData = ordersData.value?.orders?.find((p: any) => p.id === purchase.id) + if (!orderData) { + throw new Error('ORDER_NOT_FOUND') + } + + const { error: fetchError } = await useFetch(`${LIKE_CO_API}/likernft/book/collection/purchase/${collectionId.value}/status/${purchase.id}/remind`, + { + method: 'POST', + headers: { + authorization: `Bearer ${token.value}` + } + }) + + if (fetchError.value) { + throw fetchError.value + } + + toast.add({ + icon: 'i-heroicons-check-circle', + title: 'Reminder email sent', + timeout: 2000, + color: 'green' + }) +} + async function hardSetStatusToCompleted (purchase: any) { const userConfirmed = confirm('Do you want to skip the \'Send NFT\' action and override this payment status to \'completed\'?') if (!userConfirmed) { diff --git a/pages/nft-book-store/status/[classId].vue b/pages/nft-book-store/status/[classId].vue index 1b2356b2..3a4ca212 100644 --- a/pages/nft-book-store/status/[classId].vue +++ b/pages/nft-book-store/status/[classId].vue @@ -880,6 +880,16 @@ function getOrdersTableActionItems (purchaseListItem: any) { }]) } + if (purchaseListItem.status === 'paid') { + actionItems.push([{ + label: 'Send Reminder Email', + icon: 'i-heroicons-envelope', + click: () => { + sendReminderEmail(purchaseListItem) + } + }]) + } + if (['pendingNFT', 'paid'].includes(purchaseListItem.status)) { actionItems.push([{ label: 'Mark Complete', @@ -1140,6 +1150,32 @@ async function handlePriceReorder ({ } } +async function sendReminderEmail (purchase: any) { + const orderData = ordersData.value?.orders?.find((p: any) => p.id === purchase.id) + if (!orderData) { + throw new Error('ORDER_NOT_FOUND') + } + + const { error: fetchError } = await useFetch(`${LIKE_CO_API}/likernft/book/purchase/${classId.value}/status/${purchase.id}/remind`, + { + method: 'POST', + headers: { + authorization: `Bearer ${token.value}` + } + }) + + if (fetchError.value) { + throw fetchError.value + } + + toast.add({ + icon: 'i-heroicons-check-circle', + title: 'Reminder email sent', + timeout: 2000, + color: 'green' + }) +} + async function hardSetStatusToCompleted (purchase: any) { const userConfirmed = confirm('Do you want to skip the \'Send NFT\' action and override this payment status to \'completed\'?') if (!userConfirmed) {