import { createPerson, listPersons } from "@/services/dictionaryService";
import type { PersonFormValues, PersonItem } from "./types";

export async function fetchPersonList(): Promise<PersonItem[]> {
  return listPersons();
}

export async function savePerson(values: PersonFormValues): Promise<PersonItem> {
  return createPerson({
    firstName: values.firstName.trim() || null,
    lastName: values.lastName.trim() || null,
    emailAddress: values.emailAddress.trim() || null,
    phoneNumber: values.phoneNumber.trim() || null,
    instituteName: values.instituteName.trim() || null,
  });
}
