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 : "", }, }; } } export const getFiiledConditions = (condition) => { let crown = Object.keys(condition.crown) .map((key) => ({ value: condition.crown[key], type: "crown", part: key, })) .filter((el) => el.value.length); let root = Object.keys(condition.root) .map((key) => ({ value: condition.root[key], type: "root", part: key, })) .filter((el) => el.value.length); return [...crown, ...root]; };