fix: gift card friend purchase notifies admin, frontend no longer falsely claims email sent
This commit is contained in:
@@ -1080,7 +1080,14 @@ func BuyGiftCard(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
recipient = userEmail
|
recipient = userEmail
|
||||||
}
|
}
|
||||||
log.Printf("[TODO EMAIL] Send gift card code %s (Value: £%.2f) to %s", cardID, amountPounds, recipient)
|
// Notify admin about the friend gift card (email delivery not yet implemented — admin must send manually)
|
||||||
|
if _, err := db.Conn.Exec(ctx, `
|
||||||
|
INSERT INTO admin_notifications (reason, booking_id, user_id)
|
||||||
|
VALUES ('gift_card_purchased_for_friend', $1, $2)
|
||||||
|
`, cardID, userID); err != nil {
|
||||||
|
log.Printf("ALERT: failed to create admin notification for gift card %s: %v", cardID, err)
|
||||||
|
}
|
||||||
|
log.Printf("GIFT CARD FOR FRIEND — code: %s, value: £%.2f, intended for: %s", cardID, amountPounds, recipient)
|
||||||
|
|
||||||
_, err = db.Conn.Exec(ctx, `
|
_, err = db.Conn.Exec(ctx, `
|
||||||
INSERT INTO gift_card_transactions (gift_card_id, transaction_type, amount, reference_type, reference_id, user_id, notes)
|
INSERT INTO gift_card_transactions (gift_card_id, transaction_type, amount, reference_type, reference_id, user_id, notes)
|
||||||
|
|||||||
@@ -2296,8 +2296,8 @@
|
|||||||
>
|
>
|
||||||
{formatCardCode(purchaseResultCode)}
|
{formatCardCode(purchaseResultCode)}
|
||||||
</div>
|
</div>
|
||||||
<p class="text-[10px] text-green-600 italic">
|
<p class="text-[10px] text-amber-600 italic font-semibold">
|
||||||
Please save this code! It has been emailed to the recipient.
|
⚠️ Please save this code and send it to your friend — no email was sent.
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -800,7 +800,7 @@ INSERT INTO business_settings (
|
|||||||
'https://www.website.co.uk'
|
'https://www.website.co.uk'
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TYPE admin_notification_reason AS ENUM ('pending_booking', 'cancelled_booking', 'rescheduled_booking', '1_week_no_pay', '1_month_no_pay', 'affiliate_claim', 'late_cancellation', 'deposit_paid', 'edit_request', 'edit_requested', 'new_booking', 'deposit_not_paid_by_deadline');
|
CREATE TYPE admin_notification_reason AS ENUM ('pending_booking', 'cancelled_booking', 'rescheduled_booking', '1_week_no_pay', '1_month_no_pay', 'affiliate_claim', 'late_cancellation', 'deposit_paid', 'edit_request', 'edit_requested', 'new_booking', 'deposit_not_paid_by_deadline', 'gift_card_purchased_for_friend');
|
||||||
|
|
||||||
CREATE TABLE admin_notifications (
|
CREATE TABLE admin_notifications (
|
||||||
id CHAR(12) PRIMARY KEY DEFAULT generate_admin_notifications_id(),
|
id CHAR(12) PRIMARY KEY DEFAULT generate_admin_notifications_id(),
|
||||||
|
|||||||
Reference in New Issue
Block a user