From b47a517bd568a32a5e88c48d365ee31c5a98172a Mon Sep 17 00:00:00 2001
From: seaznCode
Date: Mon, 16 Mar 2026 20:50:12 +0100
Subject: [PATCH] refactor: remove guest email handling logic from subscription
process
---
src/app/coffee-abonnements/summary/page.tsx | 73 +--------------------
1 file changed, 2 insertions(+), 71 deletions(-)
diff --git a/src/app/coffee-abonnements/summary/page.tsx b/src/app/coffee-abonnements/summary/page.tsx
index 06cd1df..5ed3dad 100644
--- a/src/app/coffee-abonnements/summary/page.tsx
+++ b/src/app/coffee-abonnements/summary/page.tsx
@@ -530,9 +530,6 @@ export default function SummaryPage() {
setSubmitError(null)
setSubmitLoading(true)
try {
- const recipientEmail = form.recipientEmail.trim()
- const recipientName = form.recipientName.trim()
-
const payload = {
items: selectedEntries.map(entry => ({
coffeeId: entry.coffee.id,
@@ -572,57 +569,8 @@ export default function SummaryPage() {
console.info('[SummaryPage] subscribeAbo payload JSON:', JSON.stringify(payload))
await subscribeAbo(payload)
- // TEMP: Guest email workaround (ignore contract/PDF for mail)
- // Open an email draft to the recipient when subscription is for someone else.
- if (!isForSelf && recipientEmail) {
- try {
- // A referral token is required for /register, so we generate a 1-time referral link.
- const refRes = await createReferralLink({ expiresInDays: 7, maxUses: 1 })
- const refBody: any = (refRes as any)?.body
- const refCode =
- refBody?.data?.code ||
- refBody?.data?.token ||
- refBody?.data?.ref ||
- refBody?.code ||
- refBody?.token ||
- refBody?.ref ||
- ''
-
- const origin = typeof window !== 'undefined' ? window.location.origin : ''
- const guestLink = refCode
- ? (origin
- ? `${origin}/register?ref=${encodeURIComponent(String(refCode))}&guest=true`
- : `/register?ref=${encodeURIComponent(String(refCode))}&guest=true`)
- : ''
-
- setGuestInviteLink(guestLink)
-
- if (!guestLink) {
- console.warn('[SummaryPage] Guest invite: could not generate referral token/link', { refBody })
- setGuestMailtoHref('')
- } else {
- const subject = 'Profit Planet – Guest access for your coffee abonnement'
- const body =
- `Hallo${recipientName ? ` ${recipientName}` : ''},\n\n` +
- `du wurdest eingeladen, um Zugriff auf dein Kaffee-Abonnement zu erhalten.\n\n` +
- `Bitte registriere dich hier als Gast:\n${guestLink}\n\n` +
- `Liebe Grüße\nProfit Planet`
-
- const mailto = `mailto:${recipientEmail}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`
- setGuestMailtoHref(mailto)
- try {
- window.location.href = mailto
- } catch {}
- }
- } catch (e) {
- console.warn('[SummaryPage] Guest invite: failed to create referral link', e)
- setGuestMailtoHref('')
- setGuestInviteLink('')
- }
- } else {
- setGuestMailtoHref('')
- setGuestInviteLink('')
- }
+ setGuestMailtoHref('')
+ setGuestInviteLink('')
setShowThanks(true);
try { sessionStorage.removeItem('coffeeSelections'); } catch {}
@@ -979,23 +927,6 @@ export default function SummaryPage() {
Subscription created.
- {!isForSelf && guestMailtoHref && (
-
- )}
-
- {!isForSelf && guestInviteLink && (
-
- )}
-