File: //tmp/bewertemich-sharePlaybooks-loop.js
import { buildComparisonShareUrl, buildShareUrl } from '../../utils/tracking.js';
const formatScore = (avgScore, votes) => {
if (!avgScore || votes < 3) return 'noch kein klares Signal';
return `${avgScore.toFixed(1)}/10 bei ${votes} Stimmen`;
};
const buildWhatsappHref = (text, url) => `https://wa.me/?text=${encodeURIComponent(`${text} ${url}`)}`;
const buildTelegramHref = (text, url) =>
`https://t.me/share/url?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text)}`;
const remainingVotesText = (votes) => {
const remaining = Math.max(0, 5 - Number(votes || 0));
if (remaining <= 0) return 'Ich hole mir gerade noch ein paar zusätzliche Stimmen dazu.';
return `Mir fehlen noch ${remaining} ehrliche Stimme${remaining === 1 ? '' : 'n'}.`;
};
export const buildPhotoInvitePlaybook = ({ photoId, avgScore, votes, surface = 'upload_success' }) => {
const summary = formatScore(avgScore, votes);
const summarySentence = !avgScore || votes < 3
? 'Ich sammele gerade die ersten ehrlichen Stimmen.'
: `Aktuell steht das Bild bei ${summary}.`;
const followupText = `Kurzer Reminder: ${remainingVotesText(votes)} Kannst du mein Profilbild bitte noch kurz bewerten?`;
const directWhatsappUrl = buildShareUrl(photoId, { source: 'whatsapp_direct', surface });
const groupWhatsappUrl = buildShareUrl(photoId, { source: 'whatsapp_group', surface });
const directTelegramUrl = buildShareUrl(photoId, { source: 'telegram_direct', surface });
const groupTelegramUrl = buildShareUrl(photoId, { source: 'telegram_group', surface });
const followupCopyUrl = buildShareUrl(photoId, { source: 'copy_followup', surface });
return [
{
id: 'whatsapp_direct',
label: 'WhatsApp direkt',
goal: '3 Kontakte',
description: 'Persönliche DMs liefern fast immer die ersten Stimmen am schnellsten.',
href: buildWhatsappHref(`Kurzer ehrlicher Check? ${summarySentence}`, directWhatsappUrl),
source: 'whatsapp_direct'
},
{
id: 'telegram_direct',
label: 'Telegram direkt',
goal: '2 Kontakte',
description: 'Gut für die zweite Welle, wenn du schnelle Antworten willst.',
href: buildTelegramHref(`Kannst du mir kurz ehrliches Feedback geben? ${summarySentence}`, directTelegramUrl),
source: 'telegram_direct'
},
{
id: 'whatsapp_group',
label: 'WhatsApp Gruppe',
goal: '1 Gruppe',
description: 'Sobald die ersten 2 bis 3 Stimmen da sind, lohnt sich die kleine Gruppe.',
href: buildWhatsappHref('Brauche einen kurzen Profilbild-Check von ein paar Leuten:', groupWhatsappUrl),
source: 'whatsapp_group'
},
{
id: 'telegram_group',
label: 'Telegram Gruppe',
goal: '1 Gruppe',
description: 'Funktioniert gut für ein breiteres, aber immer noch kontrolliertes Feedback.',
href: buildTelegramHref('Kurzer Profilbild-Check. Welche Wirkung hat das Foto auf dich?', groupTelegramUrl),
source: 'telegram_group'
},
{
id: 'copy_followup',
label: 'Reminder kopieren',
goal: 'Follow-up',
description: 'Wenn nach ein paar Stunden noch Stimmen fehlen, sende diese Erinnerung.',
copyText: `${followupText} ${followupCopyUrl}`,
source: 'copy_followup'
}
];
};
export const buildComparisonInvitePlaybook = ({
comparisonId,
title,
leftPercent,
rightPercent,
totalVotes,
surface = 'compare_page'
}) => {
const compareUrlDirect = buildComparisonShareUrl(comparisonId, { source: 'whatsapp_direct', surface });
const compareUrlTelegram = buildComparisonShareUrl(comparisonId, { source: 'telegram_direct', surface });
const compareUrlGroup = buildComparisonShareUrl(comparisonId, { source: 'whatsapp_group', surface });
const compareUrlFollowup = buildComparisonShareUrl(comparisonId, { source: 'copy_followup', surface });
const comparisonSummary = totalVotes > 0
? `Aktuell ${leftPercent}% zu ${rightPercent}% bei ${totalVotes} Stimmen.`
: 'Es gibt noch kein Ergebnis, deshalb ist jede Stimme gerade wertvoll.';
return [
{
id: 'whatsapp_direct',
label: 'WhatsApp direkt',
goal: '3 Kontakte',
description: 'Am stärksten für schnelle A/B-Entscheidungen.',
href: buildWhatsappHref(`${title || 'Welches Profilbild wirkt besser?'} ${comparisonSummary}`, compareUrlDirect),
source: 'whatsapp_direct'
},
{
id: 'telegram_direct',
label: 'Telegram direkt',
goal: '2 Kontakte',
description: 'Die zweite schnelle Welle für weitere Direktstimmen.',
href: buildTelegramHref(`${title || 'Welches Profilbild wirkt besser?'} ${comparisonSummary}`, compareUrlTelegram),
source: 'telegram_direct'
},
{
id: 'whatsapp_group',
label: 'WhatsApp Gruppe',
goal: '1 Gruppe',
description: 'Sobald 4 bis 5 Stimmen da sind, kannst du in eine kleine Gruppe gehen.',
href: buildWhatsappHref('Kurze Entscheidungshilfe: Bild A oder Bild B?', compareUrlGroup),
source: 'whatsapp_group'
},
{
id: 'copy_followup',
label: 'Reminder kopieren',
goal: 'Follow-up',
description: 'Hilft, wenn der Vergleich nach dem ersten Schub stehen bleibt.',
copyText: `Kurzer Reminder: Ich brauche noch ein paar Stimmen für meinen Bildvergleich. ${compareUrlFollowup}`,
source: 'copy_followup'
}
];
};