UNPKG

@planet-a/affinity-node

Version:
27 lines (26 loc) 841 B
/** * @hidden */ export function transformInteractionDateResponseRaw(entityWithInteractions) { const { interaction_dates, interactions, ...rest } = entityWithInteractions; const dates = {}; if (interaction_dates) { dates.interaction_dates = Object.fromEntries(Object.entries(interaction_dates).map(([key, value]) => [ key, value ? new Date(value) : null, ])); } if (interactions) { dates.interactions = Object.fromEntries(Object.entries(interactions).map(([key, value]) => [ key, value ? { ...value, date: new Date(value.date), } : null, ])); } // TODO(@joscha): fix the types so we don't need to cast here return { ...rest, ...dates }; }