import { type Locale } from '@/i18n/config';

interface ServiceJsonLdProps {
  name: string;
  description: string;
  url: string;
  locale: Locale;
  areaServed?: string[];
}

export function ServiceJsonLd({
  name,
  description,
  url,
  locale,
  areaServed = ['Köln', 'Düsseldorf', 'Frankfurt', 'Deutschland'],
}: ServiceJsonLdProps) {
  const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://damjan-savic.com';

  const schema = {
    '@context': 'https://schema.org',
    '@type': 'Service',
    name: name,
    description: description,
    url: url.startsWith('http') ? url : `${baseUrl}${url}`,
    inLanguage: locale === 'de' ? 'de-DE' : locale === 'sr' ? 'sr-RS' : 'en-US',
    availableLanguage: ['de-DE', 'en-US', 'sr-RS'],
    provider: {
      '@id': `${baseUrl}/#business`,
    },
    areaServed: areaServed.map((area) => ({
      '@type': 'City',
      name: area,
    })),
    serviceType: name,
  };

  return (
    <script
      type="application/ld+json"
      dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
    />
  );
}
