import { toast } from "react-toastify";

// Function to validate variable items
export function isvalidation(variableItems: any[], t: any) {
    const validationResults: boolean[] = [];
    variableItems.slice(1).forEach((item: any, index: any) => {
      if (item && Object.keys(item).length > 0) { // Check if item is defined and not empty
        if (!item?.name_ar || !item?.name_en || !item?.name_de) {
          toast.error(t('required_name') + ` ${index + 1}`);
          validationResults.push(false);
        } else if (!item?.description_ar || !item?.description_en || !item?.description_de) {
          toast.error(t('required_description') + ` ${index + 1}`);
          validationResults.push(false);
        } else if (item.main_photo === null || !item?.main_photo) {
          toast.error(t('required_main_photo') + ` ${index + 1}`);
          validationResults.push(false);
        } else if (item.price === null || !item?.price) {
          toast.error(t('required_price') + ` ${index + 1}`);
          validationResults.push(false);
        } else {
          validationResults.push(true);
        }
      }
    });
    return validationResults;
  }
  