import client from './client';

// --- Types ---

export interface LanguageInfo {
  code: string;
  name: string;
  is_active: boolean;
}

export interface UpdateLanguageRequest {
  is_active: boolean;
  name?: string;
}

// --- API Functions ---

export async function listLanguages(): Promise<LanguageInfo[]> {
  const { data } = await client.get<{ success: boolean; data: LanguageInfo[] }>(
    '/config/languages',
  );
  return data.data;
}

export async function updateLanguage(
  code: string,
  req: UpdateLanguageRequest,
): Promise<LanguageInfo> {
  const { data } = await client.put<{ success: boolean; data: LanguageInfo }>(
    `/config/languages/${code}`,
    req,
  );
  return data.data;
}
