import { ChevronLeft, Headphones, MessageCircle } from "lucide-react"

import Link from "@/components/common/versioned-link"

/** Two kinds of help, so learners pick the right door: lesson questions go to the coach, app and payment issues to support. */
export default function HomeCoachHelp({ hasCourses }: { hasCourses: boolean }) {
  return (
    <section aria-labelledby="home-help-title">
      <h2 id="home-help-title" className="text-caption font-bold text-ink-soft mb-2 px-1">کمک لازم داری؟</h2>
      <div className="flex flex-col border border-line rounded-card bg-canvas overflow-hidden divide-y divide-line">
        {hasCourses && (
          <HelpRow
            href="/chats"
            tone="bg-ultra-soft text-ultra"
            icon={<MessageCircle className="w-5 h-5" />}
            title="سؤال درسی؟ از مربی‌ات بپرس"
            subtitle="درباره‌ی درس‌ها و تمرین‌های دوره‌هایی که داری"
          />
        )}
        <HelpRow
          href="/ticket"
          tone="bg-paper-2 text-ink"
          icon={<Headphones className="w-5 h-5" />}
          title="پشتیبانی رنگوک"
          subtitle="خرید و پرداخت، ورود به حساب، مشکل در برنامه"
        />
      </div>
    </section>
  )
}

function HelpRow({ href, tone, icon, title, subtitle }: { href: string; tone: string; icon: React.ReactNode; title: string; subtitle: string }) {
  return (
    <Link href={href} className="flex items-center p-3 active:bg-paper-2 transition">
      <span className={`w-10 h-10 rounded-xl grid place-items-center shrink-0 ${tone}`} aria-hidden="true">{icon}</span>
      <span className="flex-1 min-w-0 mr-3">
        <span className="block text-body-sm font-bold text-ink">{title}</span>
        <span className="block text-micro text-ink-soft truncate">{subtitle}</span>
      </span>
      <ChevronLeft className="w-4 h-4 text-ink-soft shrink-0" aria-hidden="true" />
    </Link>
  )
}
