const handleMultipleSelect = (
  newSelection: string | SelectOptionObject,
  isPlaceHolder: boolean,
  currentValue: string[],
  setSelection: (val: string[]) => void,
) => {
  if (isPlaceHolder) {
    setSelection([]);
  } else {
    const parseSelection = (): string[] => {
      const selectedValue = newSelection.toString ? newSelection.toString() : newSelection as string;
      if (currentValue.indexOf(selectedValue) != -1) {
        return currentValue.filter((s) => s !== selectedValue);
      }
      return [selectedValue, ...currentValue];
    };
    setSelection(parseSelection());
  }
};