import type { Metadata } from "next"
import Link from "next/link"
import { notFound } from "next/navigation"
import { CAREERS } from "@/lib/careers-data"

interface Props {
  params: Promise<{ slug: string }>
}

export async function generateStaticParams() {
  return CAREERS.map((career) => ({ slug: career.slug }))
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { slug } = await params
  const career = CAREERS.find((c) => c.slug === slug)
  if (!career) return { title: "Position Not Found" }
  return {
    title: career.title,
    description: career.description,
    openGraph: {
      title: `${career.title} - DalCode Careers`,
      description: career.description,
    },
  }
}

export default async function CareerDetailPage({ params }: Props) {
  const { slug } = await params
  const career = CAREERS.find((c) => c.slug === slug)
  if (!career) notFound()

  return (
    <main>
      <section className="section-small top overflow-hidden">
        <div className="w-layout-blockcontainer container-default w-container">
          <div className="inner-container _650px center">
            <div className="text-center">
              <div className="blog-details-wrapper" style={{ justifyContent: "center" }}>
                <div className="item-details">{career.department}</div>
                <div className="item-details-divider">&middot;</div>
                <div className="item-details">{career.location}</div>
                <div className="item-details-divider">&middot;</div>
                <div className="item-details">{career.type}</div>
              </div>
              <div className="mg-top-4x-extra-small">
                <h1>{career.title}</h1>
              </div>
              <div className="mg-top-4x-extra-small">
                <p>{career.description}</p>
              </div>
            </div>
          </div>
          <div className="mg-top-regular">
            <div className="inner-container _650px center">
              <div className="blog-post-rich-text w-richtext">
                <h2>About the role</h2>
                <p>We are looking for a {career.title} to join our {career.department} team. In this role, you will work alongside world-class engineers and researchers to push the boundaries of what&apos;s possible with AI.</p>
                <h2>Responsibilities</h2>
                <ul role="list">
                  <li>Collaborate with cross-functional teams to design, develop, and deploy AI solutions</li>
                  <li>Contribute to research and development of novel AI architectures and algorithms</li>
                  <li>Write clean, maintainable, and well-tested code</li>
                  <li>Participate in code reviews and contribute to engineering best practices</li>
                  <li>Stay up-to-date with the latest developments in AI and machine learning</li>
                </ul>
                <h2>Requirements</h2>
                <ul role="list">
                  <li>Strong background in computer science, mathematics, or a related field</li>
                  <li>Experience with modern AI/ML frameworks and tools</li>
                  <li>Excellent problem-solving and communication skills</li>
                  <li>Ability to work independently and as part of a team</li>
                </ul>
                <h2>What we offer</h2>
                <ul role="list">
                  <li>Competitive salary and equity package</li>
                  <li>Comprehensive health, dental, and vision insurance</li>
                  <li>Flexible work arrangements</li>
                  <li>Learning and development budget</li>
                  <li>Regular team events and offsites</li>
                </ul>
              </div>
            </div>
          </div>
          <div className="mg-top-regular">
            <div className="inner-container _650px center text-center">
              <Link href="/careers" className="primary-button w-inline-block">
                <div className="button-content">
                  <div>Back to all positions</div>
                  <div className="button-icon-wrapper primary">
                    <svg xmlns="http://www.w3.org/2000/svg" width="100%" viewBox="0 0 17 17" fill="none" className="squared-icon">
                      <path d="M6.25391 3.45312L10.7458 8.01563L6.25391 12.5781" stroke="currentColor" strokeWidth="1.5" strokeLinecap="square" />
                    </svg>
                    <div className="button-icon-bg" />
                    <div className="button-icon-bg-inside" />
                  </div>
                </div>
              </Link>
            </div>
          </div>
        </div>
      </section>
    </main>
  )
}
