feat: real Brevo API verifier, auto-reset if campaign missing, and update existing campaign support
This commit is contained in:
1 parent
2b4d3643cb
commit
99dd0f272e
4 files changed
+250
-27
No files matched your search
@@ -2,11 +2,18 @@ import { NextRequest, NextResponse } from 'next/server';
|
|||||||
|
|
||||||
export async function POST(req: NextRequest) {
|
export async function POST(req: NextRequest) {
|
||||||
try {
|
try {
|
||||||
const { campaignName, subject, htmlContent, scheduledAt } = await req.json();
|
const {
|
||||||
|
campaignName,
|
||||||
|
subject,
|
||||||
|
htmlContent,
|
||||||
|
scheduledAt,
|
||||||
|
updateExisting = false,
|
||||||
|
existingCampaignId
|
||||||
|
} = await req.json();
|
||||||
|
|
||||||
if (!campaignName || !subject || !htmlContent) {
|
if (!htmlContent) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Chýbajú povinné polia (campaignName, subject, htmlContent).' },
|
{ error: 'Chýba povinné pole htmlContent.' },
|
||||||
{ status: 400 }
|
{ status: 400 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -22,10 +29,54 @@ export async function POST(req: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Volanie Brevo API v3
|
// 1. Ak je zadané updateExisting a máme existujúce ID, skúsime aktualizovať existujúcu kampaň
|
||||||
const payload: any = {
|
if (updateExisting && existingCampaignId) {
|
||||||
name: campaignName,
|
const updatePayload: any = {
|
||||||
subject: subject,
|
name: campaignName,
|
||||||
|
subject: subject,
|
||||||
|
sender: {
|
||||||
|
name: senderName,
|
||||||
|
email: senderEmail
|
||||||
|
},
|
||||||
|
htmlContent: htmlContent
|
||||||
|
};
|
||||||
|
|
||||||
|
if (scheduledAt) {
|
||||||
|
updatePayload.scheduledAt = scheduledAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateRes = await fetch(
|
||||||
|
`https://api.brevo.com/v3/emailCampaigns/${encodeURIComponent(existingCampaignId)}`,
|
||||||
|
{
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {
|
||||||
|
'accept': 'application/json',
|
||||||
|
'content-type': 'application/json',
|
||||||
|
'api-key': apiKey
|
||||||
|
},
|
||||||
|
body: JSON.stringify(updatePayload)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (updateRes.ok || updateRes.status === 204) {
|
||||||
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
updated: true,
|
||||||
|
campaignId: Number(existingCampaignId),
|
||||||
|
brevoUrl: `https://app.brevo.com/campaigns/email/edit/${existingCampaignId}`,
|
||||||
|
brevoListingUrl: 'https://app.brevo.com/campaigns/listing',
|
||||||
|
message: 'Kampaň bola úspešne aktualizovaná v Brevo!'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ak aktualizácia zlyhala (napr. kampaň už bola odoslaná alebo neexistuje), vytvoríme novú
|
||||||
|
console.warn(`Update failed on campaign ${existingCampaignId}, creating a new one instead.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Vytvorenie novej kampane v Brevo
|
||||||
|
const createPayload: any = {
|
||||||
|
name: campaignName || 'COOP Jednota Newsletter',
|
||||||
|
subject: subject || 'COOP Jednota Newsletter',
|
||||||
sender: {
|
sender: {
|
||||||
name: senderName,
|
name: senderName,
|
||||||
email: senderEmail
|
email: senderEmail
|
||||||
@@ -35,7 +86,7 @@ export async function POST(req: NextRequest) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (scheduledAt) {
|
if (scheduledAt) {
|
||||||
payload.scheduledAt = scheduledAt;
|
createPayload.scheduledAt = scheduledAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
const brevoRes = await fetch('https://api.brevo.com/v3/emailCampaigns', {
|
const brevoRes = await fetch('https://api.brevo.com/v3/emailCampaigns', {
|
||||||
@@ -45,7 +96,7 @@ export async function POST(req: NextRequest) {
|
|||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
'api-key': apiKey
|
'api-key': apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(createPayload)
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await brevoRes.json();
|
const data = await brevoRes.json();
|
||||||
@@ -58,9 +109,9 @@ export async function POST(req: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Úspech - vrátime campaignId a priame URL na editáciu a prehľad kampaní v novom Brevo dashboarde
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
|
updated: false,
|
||||||
campaignId: data.id,
|
campaignId: data.id,
|
||||||
brevoUrl: `https://app.brevo.com/campaigns/email/edit/${data.id}`,
|
brevoUrl: `https://app.brevo.com/campaigns/email/edit/${data.id}`,
|
||||||
brevoListingUrl: 'https://app.brevo.com/campaigns/listing',
|
brevoListingUrl: 'https://app.brevo.com/campaigns/listing',
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
export async function GET(req: NextRequest) {
|
||||||
|
try {
|
||||||
|
const { searchParams } = new URL(req.url);
|
||||||
|
const campaignId = searchParams.get('campaignId');
|
||||||
|
|
||||||
|
if (!campaignId) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ exists: false, error: 'Chýba parameter campaignId' },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const apiKey = process.env.BREVO_API_KEY;
|
||||||
|
if (!apiKey) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ exists: false, error: 'BREVO_API_KEY nie je nakonfigurovaný' },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await fetch(`https://api.brevo.com/v3/emailCampaigns/${encodeURIComponent(campaignId)}`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'accept': 'application/json',
|
||||||
|
'api-key': apiKey
|
||||||
|
},
|
||||||
|
cache: 'no-store'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.status === 404) {
|
||||||
|
return NextResponse.json({
|
||||||
|
exists: false,
|
||||||
|
message: 'Kampaň s týmto ID v Brevo neexistuje alebo bola vymazaná.'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
const errData = await res.json().catch(() => ({}));
|
||||||
|
return NextResponse.json({
|
||||||
|
exists: false,
|
||||||
|
error: errData.message || `Brevo API vrátilo status ${res.status}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
return NextResponse.json({
|
||||||
|
exists: true,
|
||||||
|
campaignId: data.id,
|
||||||
|
name: data.name,
|
||||||
|
status: data.status,
|
||||||
|
subject: data.subject,
|
||||||
|
brevoUrl: `https://app.brevo.com/campaigns/email/edit/${data.id}`,
|
||||||
|
brevoListingUrl: 'https://app.brevo.com/campaigns/listing'
|
||||||
|
});
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('Brevo verify error:', err);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ exists: false, error: err.message || 'Chyba spojenia s Brevo' },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
-3
@@ -370,7 +370,7 @@ export default function Home() {
|
|||||||
saveAs(blob, `coop-newsletter-${new Date().toISOString().split('T')[0]}.zip`);
|
saveAs(blob, `coop-newsletter-${new Date().toISOString().split('T')[0]}.zip`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExportBrevo = async () => {
|
const handleExportBrevo = async (updateExisting = false) => {
|
||||||
setIsExportingBrevo(true);
|
setIsExportingBrevo(true);
|
||||||
try {
|
try {
|
||||||
const rawHtml = renderEmailHtml(campaign);
|
const rawHtml = renderEmailHtml(campaign);
|
||||||
@@ -391,14 +391,22 @@ export default function Home() {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
campaignName: `${campaign.title} - ${new Date().toLocaleDateString('sk-SK')}`,
|
campaignName: `${campaign.title} - ${new Date().toLocaleDateString('sk-SK')}`,
|
||||||
subject: campaign.title,
|
subject: campaign.title,
|
||||||
htmlContent: finalHtml
|
htmlContent: finalHtml,
|
||||||
|
updateExisting: updateExisting,
|
||||||
|
existingCampaignId: campaign.brevoCampaignId
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const resData = await response.json();
|
const resData = await response.json();
|
||||||
|
|
||||||
if (resData.success && resData.campaignId) {
|
if (resData.success && resData.campaignId) {
|
||||||
|
setCampaign((prev) => ({
|
||||||
|
...prev,
|
||||||
|
brevoCampaignId: resData.campaignId,
|
||||||
|
status: 'exported'
|
||||||
|
}));
|
||||||
setBrevoUrl(resData.brevoUrl);
|
setBrevoUrl(resData.brevoUrl);
|
||||||
|
|
||||||
if (campaign.id) {
|
if (campaign.id) {
|
||||||
await supabase
|
await supabase
|
||||||
.from('templates')
|
.from('templates')
|
||||||
@@ -408,7 +416,12 @@ export default function Home() {
|
|||||||
})
|
})
|
||||||
.eq('id', campaign.id);
|
.eq('id', campaign.id);
|
||||||
}
|
}
|
||||||
alert('Kampaň bola úspešne odoslaná do Brevo!');
|
alert(
|
||||||
|
resData.message ||
|
||||||
|
(updateExisting
|
||||||
|
? 'Kampaň bola v Brevo úspešne aktualizovaná!'
|
||||||
|
: 'Kampaň bola úspešne odoslaná do Brevo!')
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
alert(`Chyba pri exporte do Brevo: ${resData.error || 'Neznáma chyba'}`);
|
alert(`Chyba pri exporte do Brevo: ${resData.error || 'Neznáma chyba'}`);
|
||||||
}
|
}
|
||||||
@@ -419,6 +432,17 @@ export default function Home() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClearBrevoId = async () => {
|
||||||
|
setCampaign((prev) => ({ ...prev, brevoCampaignId: undefined }));
|
||||||
|
setBrevoUrl(null);
|
||||||
|
if (campaign.id) {
|
||||||
|
await supabase
|
||||||
|
.from('templates')
|
||||||
|
.update({ brevo_campaign_id: null })
|
||||||
|
.eq('id', campaign.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Vybraný produkt pre editor cenoviek
|
// Vybraný produkt pre editor cenoviek
|
||||||
let targetProduct: ProductItem | null = null;
|
let targetProduct: ProductItem | null = null;
|
||||||
if (targetProductIdForBadge && selectedModule?.data?.products) {
|
if (targetProductIdForBadge && selectedModule?.data?.products) {
|
||||||
@@ -465,6 +489,7 @@ export default function Home() {
|
|||||||
isExportingBrevo={isExportingBrevo}
|
isExportingBrevo={isExportingBrevo}
|
||||||
brevoCampaignUrl={brevoUrl}
|
brevoCampaignUrl={brevoUrl}
|
||||||
brevoListingUrl="https://app.brevo.com/campaigns/listing"
|
brevoListingUrl="https://app.brevo.com/campaigns/listing"
|
||||||
|
onClearBrevoId={handleClearBrevoId}
|
||||||
onAddModule={handleAddModule}
|
onAddModule={handleAddModule}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
Download,
|
Download,
|
||||||
Send,
|
Send,
|
||||||
@@ -10,7 +10,10 @@ import {
|
|||||||
FolderOpen,
|
FolderOpen,
|
||||||
Save,
|
Save,
|
||||||
Copy,
|
Copy,
|
||||||
Edit2
|
Edit2,
|
||||||
|
RefreshCw,
|
||||||
|
UploadCloud,
|
||||||
|
Check
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { NewsletterCampaign } from '@/types/newsletter';
|
import { NewsletterCampaign } from '@/types/newsletter';
|
||||||
|
|
||||||
@@ -22,10 +25,11 @@ interface TopBarProps {
|
|||||||
onOpenSavedCampaigns: () => void;
|
onOpenSavedCampaigns: () => void;
|
||||||
onDuplicateCampaign: () => void;
|
onDuplicateCampaign: () => void;
|
||||||
onExportZip: () => void;
|
onExportZip: () => void;
|
||||||
onExportBrevo: () => void;
|
onExportBrevo: (updateExisting?: boolean) => void;
|
||||||
isExportingBrevo: boolean;
|
isExportingBrevo: boolean;
|
||||||
brevoCampaignUrl?: string | null;
|
brevoCampaignUrl?: string | null;
|
||||||
brevoListingUrl?: string | null;
|
brevoListingUrl?: string | null;
|
||||||
|
onClearBrevoId?: () => void;
|
||||||
onAddModule: (type: any) => void;
|
onAddModule: (type: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,9 +45,55 @@ export const TopBar: React.FC<TopBarProps> = ({
|
|||||||
isExportingBrevo,
|
isExportingBrevo,
|
||||||
brevoCampaignUrl,
|
brevoCampaignUrl,
|
||||||
brevoListingUrl = 'https://app.brevo.com/campaigns/listing',
|
brevoListingUrl = 'https://app.brevo.com/campaigns/listing',
|
||||||
|
onClearBrevoId,
|
||||||
onAddModule
|
onAddModule
|
||||||
}) => {
|
}) => {
|
||||||
const [isEditingTitle, setIsEditingTitle] = useState(false);
|
const [isEditingTitle, setIsEditingTitle] = useState(false);
|
||||||
|
const [isVerifyingBrevo, setIsVerifyingBrevo] = useState(false);
|
||||||
|
const [isVerifiedInBrevo, setIsVerifiedInBrevo] = useState(false);
|
||||||
|
const [brevoCampaignStatus, setBrevoCampaignStatus] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// Funkcia na reálne overenie existencie kampane priamo cez Brevo API
|
||||||
|
const verifyCampaignInBrevo = async (campaignId?: number) => {
|
||||||
|
const idToCheck = campaignId || campaign.brevoCampaignId;
|
||||||
|
if (!idToCheck) {
|
||||||
|
setIsVerifiedInBrevo(false);
|
||||||
|
setBrevoCampaignStatus(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsVerifyingBrevo(true);
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/brevo/verify?campaignId=${encodeURIComponent(idToCheck)}`);
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
if (data.exists) {
|
||||||
|
setIsVerifiedInBrevo(true);
|
||||||
|
setBrevoCampaignStatus(data.status || 'draft');
|
||||||
|
} else {
|
||||||
|
// Kampaň v Brevo reálne neexistuje (vymazaná alebo prenos zlyhal)
|
||||||
|
setIsVerifiedInBrevo(false);
|
||||||
|
setBrevoCampaignStatus(null);
|
||||||
|
if (onClearBrevoId) {
|
||||||
|
onClearBrevoId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('Chyba pri overovaní Brevo kampane:', err);
|
||||||
|
} finally {
|
||||||
|
setIsVerifyingBrevo(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Pri zmene brevoCampaignId automaticky overíme stav v Brevo
|
||||||
|
useEffect(() => {
|
||||||
|
if (campaign.brevoCampaignId) {
|
||||||
|
verifyCampaignInBrevo(campaign.brevoCampaignId);
|
||||||
|
} else {
|
||||||
|
setIsVerifiedInBrevo(false);
|
||||||
|
setBrevoCampaignStatus(null);
|
||||||
|
}
|
||||||
|
}, [campaign.brevoCampaignId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="h-16 bg-white border-b border-gray-200 px-4 md:px-6 flex items-center justify-between sticky top-0 z-30 shadow-xs">
|
<header className="h-16 bg-white border-b border-gray-200 px-4 md:px-6 flex items-center justify-between sticky top-0 z-30 shadow-xs">
|
||||||
@@ -85,7 +135,7 @@ export const TopBar: React.FC<TopBarProps> = ({
|
|||||||
className="group flex items-center gap-1.5 cursor-pointer"
|
className="group flex items-center gap-1.5 cursor-pointer"
|
||||||
title="Kliknite pre úpravu názvu"
|
title="Kliknite pre úpravu názvu"
|
||||||
>
|
>
|
||||||
<h1 className="text-xs md:text-sm font-bold text-gray-900 leading-tight max-w-[200px] md:max-w-xs truncate group-hover:text-blue-600">
|
<h1 className="text-xs md:text-sm font-bold text-gray-900 leading-tight max-w-[180px] md:max-w-xs truncate group-hover:text-blue-600">
|
||||||
{campaign.title || 'COOP Jednota Newsletter'}
|
{campaign.title || 'COOP Jednota Newsletter'}
|
||||||
</h1>
|
</h1>
|
||||||
<Edit2 className="w-3 h-3 text-gray-400 opacity-0 group-hover:opacity-100 transition-opacity" />
|
<Edit2 className="w-3 h-3 text-gray-400 opacity-0 group-hover:opacity-100 transition-opacity" />
|
||||||
@@ -122,7 +172,7 @@ export const TopBar: React.FC<TopBarProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Pravá časť: Uložiť, Duplikovať, Export do ZIP a Brevo */}
|
{/* Pravá časť: Uložiť, Duplikovať, Export do ZIP a Inteligentné Brevo akcie */}
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{/* Tlačidlo manuálneho uloženia */}
|
{/* Tlačidlo manuálneho uloženia */}
|
||||||
<button
|
<button
|
||||||
@@ -153,36 +203,69 @@ export const TopBar: React.FC<TopBarProps> = ({
|
|||||||
<span className="hidden sm:inline">Export ZIP</span>
|
<span className="hidden sm:inline">Export ZIP</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{brevoCampaignUrl ? (
|
{/* BREVO SEKČNÉ OVLÁDANIE S REÁLNYM OVERENÍM */}
|
||||||
<div className="flex items-center gap-1.5">
|
{isVerifyingBrevo ? (
|
||||||
|
<div className="flex items-center gap-1.5 text-xs font-bold text-gray-500 bg-gray-100 border border-gray-200 px-3.5 py-1.5 rounded-xl">
|
||||||
|
<RefreshCw className="w-3.5 h-3.5 animate-spin text-gray-500" />
|
||||||
|
<span>Overujem v Brevo...</span>
|
||||||
|
</div>
|
||||||
|
) : isVerifiedInBrevo && campaign.brevoCampaignId ? (
|
||||||
|
/* Kampaň je overená priamo v Brevo: Ponúkame úpravu, aktualizáciu alebo odoslanie ako novú */
|
||||||
|
<div className="flex items-center gap-1.5 bg-emerald-50 border border-emerald-200 p-1 rounded-xl">
|
||||||
|
{/* Odkaz na úpravu v Brevo */}
|
||||||
<a
|
<a
|
||||||
href={brevoCampaignUrl}
|
href={`https://app.brevo.com/campaigns/email/edit/${campaign.brevoCampaignId}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
className="flex items-center gap-1.5 text-xs font-bold text-white bg-emerald-600 hover:bg-emerald-700 px-3.5 py-1.5 rounded-xl transition-all shadow-xs"
|
className="flex items-center gap-1 text-xs font-bold text-white bg-emerald-600 hover:bg-emerald-700 px-3 py-1.2 rounded-lg transition-all shadow-xs"
|
||||||
title="Upraviť a odoslať kampaň priamo v Brevo"
|
title={`Kampaň #${campaign.brevoCampaignId} existuje v Brevo (${brevoCampaignStatus || 'draft'}). Kliknutím ju otvoríte v editore Brevo.`}
|
||||||
>
|
>
|
||||||
<ExternalLink className="w-3.5 h-3.5" />
|
<ExternalLink className="w-3.5 h-3.5" />
|
||||||
<span>Upraviť v Brevo</span>
|
<span>Upraviť v Brevo</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
{/* Tlačidlo na aktualizáciu existujúcej kampane */}
|
||||||
|
<button
|
||||||
|
onClick={() => onExportBrevo(true)}
|
||||||
|
disabled={isExportingBrevo}
|
||||||
|
className="flex items-center gap-1 text-xs font-bold text-emerald-800 hover:bg-emerald-100 px-2.5 py-1.2 rounded-lg transition-all"
|
||||||
|
title="Aktualizovať HTML tejto existujúcej kampane v Brevo s najnovšími zmenami"
|
||||||
|
>
|
||||||
|
<UploadCloud className="w-3.5 h-3.5 text-emerald-700" />
|
||||||
|
<span className="hidden xl:inline">{isExportingBrevo ? 'Ukladám...' : 'Aktualizovať'}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{/* Tlačidlo na overenie stavu */}
|
||||||
|
<button
|
||||||
|
onClick={() => verifyCampaignInBrevo()}
|
||||||
|
disabled={isVerifyingBrevo}
|
||||||
|
className="p-1 hover:bg-emerald-200/60 text-emerald-700 rounded-lg transition-colors"
|
||||||
|
title="Znovu overiť stav kampane v Brevo API"
|
||||||
|
>
|
||||||
|
<RefreshCw className="w-3 h-3" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{/* Odkaz na celkový zoznam kampaní */}
|
||||||
<a
|
<a
|
||||||
href={brevoListingUrl || 'https://app.brevo.com/campaigns/listing'}
|
href={brevoListingUrl || 'https://app.brevo.com/campaigns/listing'}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
className="hidden lg:flex items-center gap-1 text-[11px] font-bold text-emerald-800 bg-emerald-100 hover:bg-emerald-200 px-2.5 py-1.5 rounded-xl transition-all"
|
className="text-[10px] font-bold text-emerald-700 hover:underline px-1.5 hidden md:inline"
|
||||||
title="Prehľad všetkých e-mailových kampaní v Brevo"
|
title="Prehľad všetkých kampaní v Brevo"
|
||||||
>
|
>
|
||||||
Zoznam
|
Zoznam
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
/* Kampaň v Brevo nie je overená / neexistuje: Zobrazujeme tlačidlo na prvotné odoslanie */
|
||||||
<button
|
<button
|
||||||
onClick={onExportBrevo}
|
onClick={() => onExportBrevo(false)}
|
||||||
disabled={isExportingBrevo}
|
disabled={isExportingBrevo}
|
||||||
className="flex items-center gap-1.5 text-xs font-bold text-white bg-[#003399] hover:bg-blue-800 disabled:opacity-50 px-3.5 py-1.5 rounded-xl transition-all shadow-xs"
|
className="flex items-center gap-1.5 text-xs font-bold text-white bg-[#003399] hover:bg-blue-800 disabled:opacity-50 px-3.5 py-1.5 rounded-xl transition-all shadow-xs"
|
||||||
|
title="Vytvoriť a odoslať túto kampaň do Brevo"
|
||||||
>
|
>
|
||||||
<Send className="w-3.5 h-3.5" />
|
<Send className="w-3.5 h-3.5" />
|
||||||
<span>{isExportingBrevo ? 'Odosielam...' : 'Odoslať do Brevo'}</span>
|
<span>{isExportingBrevo ? 'Odosielam do Brevo...' : 'Odoslať do Brevo'}</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user