import moment from 'moment';
import 'react-native-get-random-values';
import {v4 as uuidv4} from 'uuid';

// Function to generate UUID
export const generateUUID = () => {
  return uuidv4();
};

export const capitalize = (str = '') => {
  return str.charAt(0).toUpperCase() + str.slice(1);
};

export const dateConverstion = (
  date: any,
  dateType: string = 'YYYY-MM-DD',
  format: string = 'YYYY-MM-DD',
  addTime: boolean = false,
) => {
  if (addTime) {
    const currentTime = moment().format('hh:mm:ss');
    const customDate = `${date} ${currentTime}`;
    return moment(customDate, dateType).format(format);
  }
  return moment(date, dateType).format(format);
};


export const checkStringTypeOf = (data: any) => {
    if(typeof data === 'string'){
      return data;
    } 
    return JSON.stringify(data);
}

export const getTherapyArea = (userData: any) => {
  return (
    userData?.therapy_area?.toLowerCase() || 'metabolism'
  );
};

export const getDiseaseType = (userData: any) => {
  return (
    userData?.disease?.toLowerCase() || 'Diabetes'
  );
};
