export function getImageUrl(localValue: unknown, type: string): string {
  if (type === 'fileImageLink') {
    return (localValue as string) ?? '';
  }
  return (localValue as { url?: string })?.url ?? '';
}

export function haveImageValue(localValue: unknown, type: string): boolean {
  if (type === 'fileImageLink') {
    return !!localValue;
  }
  return !!(localValue as { url?: string })?.url;
}

export function clearImageValue(type: string): string | Record<string, never> {
  if (type === 'fileImageLink') {
    return '';
  }
  return {};
}

export function mapImageUploadValue(json: { url?: string }, type: string) {
  if (type === 'fileImageLink') {
    return json.url ?? '';
  }
  return json;
}
