export function getConfidantObject(data) {
  if (!data) {
    return {
      networks: [],
      email: {
        value: null,
      },
      phone: {
        value: null,
      },
      first_name: {
        value: null,
      },
      last_name: {
        value: null,
      },
      patronymic: {
        value: null,
      },
      note: {
        value: null,
      },
    };
  } else {
    const phone = data.contacts.find((el) => el.kind === "PHONE");
    const email = data.contacts.find((el) => el.kind === "EMAIL");
    const networks = data.contacts.filter(
      (el) => el.kind !== "PHONE" && el.kind !== "EMAIL"
    );
    return {
      id: data.id,
      first_name: {
        value: data?.first_name,
      },
      last_name: {
        value: data?.last_name,
      },
      patronymic: {
        value: data?.patronymic,
      },
      phone: {
        value: phone?.username,
        id: phone?.id,
      },
      email: {
        value: email?.username,
        id: email?.id,
      },
      networks,
      note: {
        id: data?.note[0]?.id,
        value: data?.note.length ? data?.note[0].description : "",
      },
    };
  }
}
