'use client' import { useState, useEffect } from 'react' import { Input, Button, Select, toast, Spinner } from '@ciphera-net/ui' import { Copy, CheckCircle } from '@phosphor-icons/react' import { useSite } from '@/lib/swr/dashboard' import { updateSite } from '@/lib/api/sites' const TIMEZONES = [ { value: 'UTC', label: 'UTC' }, { value: 'Europe/London', label: 'Europe/London (GMT)' }, { value: 'Europe/Brussels', label: 'Europe/Brussels (CET)' }, { value: 'Europe/Berlin', label: 'Europe/Berlin (CET)' }, { value: 'Europe/Paris', label: 'Europe/Paris (CET)' }, { value: 'Europe/Amsterdam', label: 'Europe/Amsterdam (CET)' }, { value: 'America/New_York', label: 'America/New York (EST)' }, { value: 'America/Chicago', label: 'America/Chicago (CST)' }, { value: 'America/Denver', label: 'America/Denver (MST)' }, { value: 'America/Los_Angeles', label: 'America/Los Angeles (PST)' }, { value: 'Asia/Tokyo', label: 'Asia/Tokyo (JST)' }, { value: 'Asia/Shanghai', label: 'Asia/Shanghai (CST)' }, { value: 'Asia/Kolkata', label: 'Asia/Kolkata (IST)' }, { value: 'Australia/Sydney', label: 'Australia/Sydney (AEST)' }, ] const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8082' const APP_URL = process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3003' export default function SiteGeneralTab({ siteId }: { siteId: string }) { const { data: site, mutate } = useSite(siteId) const [name, setName] = useState('') const [timezone, setTimezone] = useState('UTC') const [saving, setSaving] = useState(false) const [copied, setCopied] = useState(false) useEffect(() => { if (site) { setName(site.name || '') setTimezone(site.timezone || 'UTC') } }, [site]) const handleSave = async () => { if (!site) return setSaving(true) try { await updateSite(siteId, { name, timezone }) await mutate() toast.success('Site updated') } catch { toast.error('Failed to save') } finally { setSaving(false) } } const trackingScript = `` const frustrationScript = `` const copyScript = () => { navigator.clipboard.writeText(trackingScript + '\n' + frustrationScript) setCopied(true) toast.success('Copied to clipboard') setTimeout(() => setCopied(false), 2000) } if (!site) { return (
) } return (
{/* Site details */}

General Configuration

Update your site details and tracking script.

setName(e.target.value)} placeholder="My Website" />

Domain cannot be changed after creation.

{/* Tracking Script */}

Tracking Script

Add this to your website to start tracking visitors.

            {trackingScript}{'\n'}{frustrationScript}
          
{/* Save */}
) }