import { resolveOptionLabels } from './option-display-resolver';

export type BranchDisplayRecord = {
  id: string;
  code: string;
  name: string;
  value: string | null;
};

export async function resolveBranchDisplays(input: {
  organizationId: string;
  branchIds: Array<string | null | undefined>;
}) {
  const optionMap = await resolveOptionLabels({
    organizationId: input.organizationId,
    category: 'crm_branch',
    optionIds: input.branchIds
  });

  return new Map(
    [...optionMap.entries()].map(([id, row]) => [
      id,
      {
        id,
        code: row.code,
        name: row.label,
        value: row.value
      }
    ])
  );
}
