import { TextField } from "@repo/rdx-ui/components";
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
  FormControl,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
  RadioGroup,
  RadioGroupItem,
} from "@repo/shadcn-ui/components";
import { useTranslation } from "../../i18n";

export function CustomerBasicInfoFields({ control }: { control: any }) {
  const { t } = useTranslation();

  return (
    <Card className='shadow-none'>
      <CardHeader>
        <CardTitle>{t("form_groups.basic_info.title")}</CardTitle>
        <CardDescription>{t("form_groups.basic_info.description")}</CardDescription>
      </CardHeader>
      <CardContent className='grid grid-cols-1 gap-y-8 gap-x-6 @xl:grid-cols-2'>
        <FormField
          control={control}
          name='is_company'
          render={({ field }) => (
            <FormItem className='space-y-3'>
              <FormLabel>{t("form_fields.customer_type.label")}</FormLabel>
              <FormControl>
                <RadioGroup
                  value={field.value ? "1" : "0"}
                  onValueChange={(val) => field.onChange(val === "1")}
                  className='flex gap-6'
                >
                  <FormItem className='flex items-center space-x-2'>
                    <FormControl>
                      <RadioGroupItem value='1' />
                    </FormControl>
                    <FormLabel className='font-normal'>
                      {t("form_fields.customer_type.company")}
                    </FormLabel>
                  </FormItem>
                  <FormItem className='flex items-center space-x-2'>
                    <FormControl>
                      <RadioGroupItem value='0' />
                    </FormControl>
                    <FormLabel className='font-normal'>
                      {t("form_fields.customer_type.individual")}
                    </FormLabel>
                  </FormItem>
                </RadioGroup>
              </FormControl>
              <FormMessage />
            </FormItem>
          )}
        />

        <TextField
          control={control}
          name='name'
          required
          label={t("form_fields.name.label")}
          placeholder={t("form_fields.name.placeholder")}
          description={t("form_fields.name.description")}
        />
        <TextField
          control={control}
          name='trade_name'
          label={t("form_fields.trade_name.label")}
          placeholder={t("form_fields.trade_name.placeholder")}
          description={t("form_fields.trade_name.description")}
        />
        <TextField
          control={control}
          name='reference'
          label={t("form_fields.reference.label")}
          placeholder={t("form_fields.reference.placeholder")}
          description={t("form_fields.reference.description")}
        />
      </CardContent>
    </Card>
  );
}
