Skip to content

Commit

Permalink
✨ Add send reminder email in order action
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Jan 21, 2025
1 parent 2474ab3 commit 626181b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pages/nft-book-store/collection/status/[collectionId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down
36 changes: 36 additions & 0 deletions pages/nft-book-store/status/[classId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 626181b

Please sign in to comment.