From d410dce0e000e33cfd03a3bf7355a167f5652470 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Sat, 11 Jul 2026 14:39:54 +0100 Subject: [PATCH] fix: gift card friend purchase notifies admin, frontend no longer falsely claims email sent --- backend/handlers/payments/giftcards.go | 9 ++++++++- frontend/src/routes/account/+page.svelte | 4 ++-- init-scripts/init-script.sql | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/handlers/payments/giftcards.go b/backend/handlers/payments/giftcards.go index a3c7705..5677b73 100644 --- a/backend/handlers/payments/giftcards.go +++ b/backend/handlers/payments/giftcards.go @@ -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) diff --git a/frontend/src/routes/account/+page.svelte b/frontend/src/routes/account/+page.svelte index 5990b2c..29c1338 100644 --- a/frontend/src/routes/account/+page.svelte +++ b/frontend/src/routes/account/+page.svelte @@ -2296,8 +2296,8 @@ > {formatCardCode(purchaseResultCode)} -

- 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.

{/if}