import { ConfigurationResponse } from "../../../types/ConnectWiseTypes";

export type ProcessedConfiguration = ReturnType<
  typeof processConfigurationResponse
>;

export const processConfigurationResponse = (c: ConfigurationResponse) => {
  return c.map((item) => ({
    id: item.id,
    name: item.name,
    active: item.activeFlag,
    serialNumber: item.serialNumber,
    type: item.type,
    notes: item.notes,
    status: {
      id: item.status.id,
      name: item.status.name,
    },
    questions: !item.questions
      ? null
      : item.questions.map((q) => ({
          id: q.questionId,
          question: q.question,
          answer: q.answer,
          fieldType: q.fieldType,
        })),
    info: item._info,
  }));
};
