'use client';

import Link from 'next/link';
import { InfoTooltip } from '@/components/ui/info-tooltip';
import { BlendingModeIcon, RulerHorizontalIcon } from '@radix-ui/react-icons';
import {
  Activity,
  ChevronRight,
  Clock9,
  Droplets,
  LineChart,
  Pill,
  Scale,
  TrendingUp,
  User,
} from 'lucide-react';

import { Button } from '@kit/ui/button';
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardProps,
} from '@kit/ui/card';
import { Trans } from '@kit/ui/trans';
import { cn } from '@kit/ui/utils';

const dummyCards = [
  {
    title: 'dashboard:gender',
    description: 'dashboard:male',
    icon: <User />,
    iconBg: 'bg-success',
  },
  {
    title: 'dashboard:age',
    description: '43',
    icon: <Clock9 />,
    iconBg: 'bg-success',
  },
  {
    title: 'dashboard:height',
    description: '183',
    icon: <RulerHorizontalIcon className="size-4" />,
    iconBg: 'bg-success',
  },
  {
    title: 'dashboard:weight',
    description: '92kg',
    icon: <Scale />,
    iconBg: 'bg-warning',
  },
  {
    title: 'dashboard:bmi',
    description: '27.5',
    icon: <TrendingUp />,
    iconBg: 'bg-warning',
  },
  {
    title: 'dashboard:bloodPressure',
    description: '160/98',
    icon: <Activity />,
    iconBg: 'bg-warning',
  },
  {
    title: 'dashboard:cholesterol',
    description: '5',
    icon: <BlendingModeIcon className="size-4" />,
    iconBg: 'bg-destructive',
  },
  {
    title: 'dashboard:ldlCholesterol',
    description: '3,6',
    icon: <Pill />,
    iconBg: 'bg-warning',
  },
  {
    title: 'Score 2',
    description: 'Normis',
    icon: <LineChart />,
    iconBg: 'bg-success',
  },
  {
    title: 'dashboard:smoking',
    description: 'dashboard:respondToQuestion',
    descriptionColor: 'text-primary',
    icon: (
      <Button size="icon" variant="outline" className="px-2 text-black">
        <ChevronRight className="size-4 stroke-2" />
      </Button>
    ),
    cardVariant: 'gradient-success' as CardProps['variant'],
  },
];

const dummyRecommendations = [
  {
    icon: <BlendingModeIcon className="size-4" />,
    color: 'bg-cyan/10 text-cyan',
    title: 'Kolesterooli kontroll',
    description: 'HDL-kolestrool',
    tooltipContent: 'Selgitus',
    price: '20,00 €',
    buttonText: 'Telli',
    href: '/home/booking',
  },
  {
    icon: <BlendingModeIcon className="size-4" />,
    color: 'bg-primary/10 text-primary',
    title: 'Kolesterooli kontroll',
    tooltipContent: 'Selgitus',
    description: 'LDL-Kolesterool',
    buttonText: 'Broneeri',
    href: '/home/booking',
  },
  {
    icon: <Droplets />,
    color: 'bg-destructive/10 text-destructive',
    title: 'Vererõhu kontroll',
    tooltipContent: 'Selgitus',
    description: 'Score-Risk 2',
    price: '20,00 €',
    buttonText: 'Telli',
    href: '/home/booking',
  },
];

export default function Dashboard() {
  return (
    <>
      <div className="grid auto-rows-fr grid-cols-5 gap-3">
        {dummyCards.map(
          ({
            title,
            description,
            icon,
            iconBg,
            cardVariant,
            descriptionColor,
          }) => (
            <Card
              key={title}
              variant={cardVariant}
              className="flex flex-col justify-between"
            >
              <CardHeader className="items-end-safe">
                <div
                  className={cn(
                    'flex size-8 items-center-safe justify-center-safe rounded-full text-white',
                    iconBg,
                  )}
                >
                  {icon}
                </div>
              </CardHeader>
              <CardFooter className="flex flex-col items-start">
                <h5>
                  <Trans i18nKey={title} />
                </h5>
                <CardDescription className={descriptionColor}>
                  <Trans i18nKey={description} />
                </CardDescription>
              </CardFooter>
            </Card>
          ),
        )}
      </div>
      <Card>
        <CardHeader className="items-start">
          <h4>
            <Trans i18nKey="dashboard:recommendedForYou" />
          </h4>
        </CardHeader>
        <CardContent className="space-y-6">
          {dummyRecommendations.map(
            (
              {
                icon,
                color,
                title,
                description,
                tooltipContent,
                price,
                buttonText,
                href,
              },
              index,
            ) => {
              return (
                <div className="flex justify-between" key={index}>
                  <div className="flex flex-row items-center gap-4">
                    <div
                      className={cn(
                        'flex size-8 items-center-safe justify-center-safe rounded-full text-white',
                        color,
                      )}
                    >
                      {icon}
                    </div>
                    <div>
                      <div className="inline-flex items-center gap-1 align-baseline text-sm font-medium">
                        {title}
                        <InfoTooltip content={tooltipContent} />
                      </div>
                      <p className="text-muted-foreground text-sm">
                        {description}
                      </p>
                    </div>
                  </div>
                  <div className="grid w-36 auto-rows-fr grid-cols-2 items-center gap-4">
                    <p className="text-sm font-medium"> {price}</p>
                    {href ? (
                      <Link href={href}>
                        <Button size="sm" variant="secondary">
                          {buttonText}
                        </Button>
                      </Link>
                    ) : (
                      <Button size="sm" variant="secondary">
                        {buttonText}
                      </Button>
                    )}
                  </div>
                </div>
              );
            },
          )}
        </CardContent>
      </Card>
    </>
  );
}
