import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { SettingsGrid } from "@/components/settings-layout" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Switch } from "@/components/ui/switch" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { BarChart3, Tag, Share2, Flame, Eye, Megaphone, Linkedin, Music, Pin, Camera } from "lucide-react" import { IntegrationSettings, CookieCategory } from "../../types" interface IntegrationsTabProps { settings: IntegrationSettings categories: CookieCategory[] updateSettings: (key: K, value: IntegrationSettings[K]) => void } function IntegrationCard({ icon: Icon, title, description, enabled, onToggle, toggleId, toggleLabel, idLabel, idValue, idPlaceholder, idHint, onIdChange, category, categories, onCategoryChange, }: { icon: React.ComponentType<{ className?: string }> title: string description: string enabled: boolean onToggle: (checked: boolean) => void toggleId: string toggleLabel: string idLabel: string idValue: string idPlaceholder: string idHint: string onIdChange: (value: string) => void category: string categories: CookieCategory[] onCategoryChange: (value: string) => void }) { return ( {title} {description}
{enabled && (
onIdChange(e.target.value)} placeholder={idPlaceholder} />

{idHint}

Which consent category is required

)}
) } export function IntegrationsTab({ settings, categories, updateSettings }: IntegrationsTabProps) { const createUpdater = (key: K) => { return (field: keyof IntegrationSettings[K], value: any) => { updateSettings(key, { ...settings[key], [field]: value }) } } const gaUpdate = createUpdater('googleAnalytics') const gtmUpdate = createUpdater('googleTagManager') const fbUpdate = createUpdater('facebookPixel') const hotjarUpdate = createUpdater('hotjar') const clarityUpdate = createUpdater('microsoftClarity') const gadsUpdate = createUpdater('googleAds') const linkedinUpdate = createUpdater('linkedinInsightTag') const tiktokUpdate = createUpdater('tiktokPixel') const pinterestUpdate = createUpdater('pinterestTag') const snapchatUpdate = createUpdater('snapchatPixel') return ( {/* Google Analytics */} gaUpdate('enabled', checked)} toggleId="gaEnabled" toggleLabel="Enable Google Analytics integration" idLabel="Measurement ID" idValue={settings.googleAnalytics.trackingId} idPlaceholder="G-XXXXXXXXXX" idHint="Your GA4 Measurement ID" onIdChange={(v) => gaUpdate('trackingId', v)} category={settings.googleAnalytics.category} categories={categories} onCategoryChange={(v) => gaUpdate('category', v)} /> {/* Google Tag Manager */} gtmUpdate('enabled', checked)} toggleId="gtmEnabled" toggleLabel="Enable Google Tag Manager integration" idLabel="Container ID" idValue={settings.googleTagManager.containerId} idPlaceholder="GTM-XXXXXXX" idHint="Your GTM Container ID" onIdChange={(v) => gtmUpdate('containerId', v)} category={settings.googleTagManager.category} categories={categories} onCategoryChange={(v) => gtmUpdate('category', v)} /> {/* Facebook Pixel */} fbUpdate('enabled', checked)} toggleId="fbEnabled" toggleLabel="Enable Facebook Pixel integration" idLabel="Pixel ID" idValue={settings.facebookPixel.pixelId} idPlaceholder="XXXXXXXXXXXXXXXX" idHint="Your Meta Pixel ID" onIdChange={(v) => fbUpdate('pixelId', v)} category={settings.facebookPixel.category} categories={categories} onCategoryChange={(v) => fbUpdate('category', v)} /> {/* Hotjar */} hotjarUpdate('enabled', checked)} toggleId="hotjarEnabled" toggleLabel="Enable Hotjar integration" idLabel="Site ID" idValue={settings.hotjar.siteId} idPlaceholder="XXXXXXX" idHint="Your Hotjar Site ID (found in tracking code)" onIdChange={(v) => hotjarUpdate('siteId', v)} category={settings.hotjar.category} categories={categories} onCategoryChange={(v) => hotjarUpdate('category', v)} /> {/* Microsoft Clarity */} clarityUpdate('enabled', checked)} toggleId="clarityEnabled" toggleLabel="Enable Microsoft Clarity integration" idLabel="Project ID" idValue={settings.microsoftClarity.projectId} idPlaceholder="XXXXXXXXXX" idHint="Your Clarity Project ID" onIdChange={(v) => clarityUpdate('projectId', v)} category={settings.microsoftClarity.category} categories={categories} onCategoryChange={(v) => clarityUpdate('category', v)} /> {/* Google Ads */} gadsUpdate('enabled', checked)} toggleId="gadsEnabled" toggleLabel="Enable Google Ads integration" idLabel="Conversion ID" idValue={settings.googleAds.conversionId} idPlaceholder="AW-XXXXXXXXX" idHint="Your Google Ads Conversion ID" onIdChange={(v) => gadsUpdate('conversionId', v)} category={settings.googleAds.category} categories={categories} onCategoryChange={(v) => gadsUpdate('category', v)} /> {/* LinkedIn Insight Tag */} linkedinUpdate('enabled', checked)} toggleId="linkedinEnabled" toggleLabel="Enable LinkedIn Insight Tag integration" idLabel="Partner ID" idValue={settings.linkedinInsightTag.partnerId} idPlaceholder="XXXXXXX" idHint="Your LinkedIn Partner ID" onIdChange={(v) => linkedinUpdate('partnerId', v)} category={settings.linkedinInsightTag.category} categories={categories} onCategoryChange={(v) => linkedinUpdate('category', v)} /> {/* TikTok Pixel */} tiktokUpdate('enabled', checked)} toggleId="tiktokEnabled" toggleLabel="Enable TikTok Pixel integration" idLabel="Pixel ID" idValue={settings.tiktokPixel.pixelId} idPlaceholder="XXXXXXXXXXXXXXXXXXXXX" idHint="Your TikTok Pixel ID" onIdChange={(v) => tiktokUpdate('pixelId', v)} category={settings.tiktokPixel.category} categories={categories} onCategoryChange={(v) => tiktokUpdate('category', v)} /> {/* Pinterest Tag */} pinterestUpdate('enabled', checked)} toggleId="pinterestEnabled" toggleLabel="Enable Pinterest Tag integration" idLabel="Tag ID" idValue={settings.pinterestTag.tagId} idPlaceholder="XXXXXXXXXXXXXXXXXXXXX" idHint="Your Pinterest Tag ID" onIdChange={(v) => pinterestUpdate('tagId', v)} category={settings.pinterestTag.category} categories={categories} onCategoryChange={(v) => pinterestUpdate('category', v)} /> {/* Snapchat Pixel */} snapchatUpdate('enabled', checked)} toggleId="snapchatEnabled" toggleLabel="Enable Snapchat Pixel integration" idLabel="Pixel ID" idValue={settings.snapchatPixel.pixelId} idPlaceholder="XXXXXXXXXXXXXXXXXXXXXXXXXXXX" idHint="Your Snapchat Pixel ID" onIdChange={(v) => snapchatUpdate('pixelId', v)} category={settings.snapchatPixel.category} categories={categories} onCategoryChange={(v) => snapchatUpdate('category', v)} /> ) }