import React, { useState, useEffect } from 'react';
import Image from 'next/image';
import Link from "next/link";
import { Modal, Button } from '../../../../../UI';
import { RadioButton } from './index';
import classNames from 'classnames';

type Props = {
  id: string | string[];
 };
const title='dddd',
feature='feature',
description='description',
sum=33, types=[0,1], sizes=[30,40, 50];

const typeNames = ['традиционное тесто','тонкое тесто'];

const addBasket = () => {
  console.log('add');
}

export const PizzaCard: React.FC<Props> = ({id}) => {
  const [activeType, setActiveType] = useState(0);
  const [activeSize, setActiveSize] = useState(0);
  return (
    <Modal styles={'modal_product'} position={'position_product'}>
      <div className='modal_body_left'>
        <div className='modal_img'>
          {id}
          <Image
            src={'/assets/img/'+id+'.pmg'}
            alt={'pizza'}
            width={336}
            height={336}
            />
        </div>
      </div>
      <div className='modal_body_right'>
        <div className="modal_header">
          <h3 className="modal_title">{title}</h3>
          <p className="modal_feature">{feature}</p>
          <p className="modal_description">{description}</p>
          <div className="pizza-block__selector">
            <ul>
              {types.map((typeId) => (
                <li
                  key={typeId}
                  onClick={() => setActiveType(typeId)}
                  className={activeType === typeId ? classNames('active type') : classNames('type')}>
                  {typeNames[typeId]}
                </li>
              ))}
            </ul>
            <ul>
              {sizes.map((size, i) => (
                <li
                  key={size}
                  onClick={() => setActiveSize(i)}
                  className={activeSize === i ? classNames('active size') : classNames('size')}>
                  {size} см
                </li>
              ))}
            </ul>
          </div>
          <div className='modal_footer'>
            <Button styles={'yellow button_size_48'} align={'button_align_center'}
              onClick={addBasket}>В корзину за {sum} р</Button>
            <Link href={"/"} as={"/"} scroll={false}>
              <button className={classNames('yelow button_size_32')}>Закрыть </button>
            </Link>
          </div>
        </div>
      </div>
    </Modal>
  );
};