import { useTranslation } from "react-i18next";

import { FormFieldProps } from "./field";
import { OrderFormValues } from "./types";
import { isValidCarNumber } from "./car-number";
import { isValidPhoneNumber } from "./phone";

export const defaultValues: Partial<OrderFormValues> = {
  phone: '',
  carNumber: '',
  carColor: '',
  availableDatetimeBegin: '',
  availableDatetimeEnd: '',
};

export const useGetValidationRules = () => {
  const { t } = useTranslation('~', {
    keyPrefix: 'dry-wash.order-create.form',
  });

  return {
    isValidPhoneNumber: {
      validate: (value: string) => isValidPhoneNumber(value) || t('phone-field.invalid')
    },
    isValidCarNumber: {
      validate: (value: string) => isValidCarNumber(value) || t('car-number-field.invalid')
    },
  } satisfies Record<string, FormFieldProps['rules']>;
};