export function switchCase<T extends Record<string, any>, K extends keyof T>(
  data: T | null | undefined,
  select?: K,
): T[K] | string {
  if (!data) {
    return 'Tidak ada data'
  }

  const key: K | 'default' = select !== undefined ? select : ('default' as K) // Type assertion needed here

  if (key in data) {
    return data[key]
  } else if ('default' in data) {
    return data['default']
  } else {
    return 'Data tidak ditemukan'
  }
}
