import { businessConfig } from "@/lib/seo-config"
import { Card, CardContent } from "@/components/ui/card"

interface AuthorBioProps {
  className?: string
  showSchema?: boolean
}

/**
 * Author Bio Component
 * Displays business expertise and credentials for E-E-A-T signals
 * Includes Person schema for author information
 */
export function AuthorBio({ className = "", showSchema = true }: AuthorBioProps) {
  // Years in business calculation
  const foundingYear = new Date(businessConfig.openingDate).getFullYear()
  const currentYear = new Date().getFullYear()
  const yearsInBusiness = currentYear - foundingYear

  // Person schema for author/owner
  const personSchema = showSchema
    ? {
        "@context": "https://schema.org",
        "@type": "Person",
        name: businessConfig.name,
        jobTitle: "Vending Machine Supplier & Service Provider",
        worksFor: {
          "@type": "Organization",
          name: businessConfig.name,
        },
        knowsAbout: [
          "Vending Machine Installation",
          "Vending Machine Repair",
          "Vending Machine Sales",
          "Vending Machine Service",
          "Local Business Solutions",
        ],
      }
    : null

  return (
    <>
      {showSchema && personSchema && (
        <script
          type="application/ld+json"
          dangerouslySetInnerHTML={{ __html: JSON.stringify(personSchema) }}
        />
      )}
      <Card className={`bg-card/50 border-border ${className}`}>
        <CardContent className="p-6">
          <h3 className="text-xl font-semibold mb-2">About Rocky Mountain Vending</h3>
          <div className="space-y-3 text-muted-foreground">
            <p>
              Rocky Mountain Vending has been serving Utah businesses and schools since {foundingYear}, 
              providing quality vending machine solutions for over {yearsInBusiness} years.
            </p>
            <p>
              We specialize in vending machine installation, repair, and service across Salt Lake City, 
              Ogden, Provo, and surrounding areas. Our team brings extensive experience in vending 
              machine operations, inventory management, and customer service.
            </p>
            <div className="pt-2">
              <p className="font-medium text-foreground mb-2">Our Expertise:</p>
              <ul className="list-disc list-inside space-y-1 text-sm">
                <li>Vending machine installation and setup</li>
                <li>Real-time inventory monitoring and management</li>
                <li>Vending machine repairs and maintenance</li>
                <li>Healthy and traditional snack/beverage options</li>
                <li>Custom product selection for businesses</li>
              </ul>
            </div>
          </div>
        </CardContent>
      </Card>
    </>
  )
}



