fix: gift card friend purchase notifies admin, frontend no longer falsely claims email sent

This commit is contained in:
2026-07-11 14:39:54 +01:00
parent 9f9f0eed98
commit d410dce0e0
3 changed files with 11 additions and 4 deletions
+8 -1
View File
@@ -1080,7 +1080,14 @@ func BuyGiftCard(w http.ResponseWriter, r *http.Request) {
}
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, `
INSERT INTO gift_card_transactions (gift_card_id, transaction_type, amount, reference_type, reference_id, user_id, notes)