mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-10-24 23:49:06 +08:00
feat(api): submit survey endpoint (#53934)
Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
/* This module's job is to parse the database output and prepare it for
|
||||
serialization */
|
||||
import { ProfileUI, CompletedChallenge, ExamResults } from '@prisma/client';
|
||||
import {
|
||||
ProfileUI,
|
||||
CompletedChallenge,
|
||||
ExamResults,
|
||||
type Survey
|
||||
} from '@prisma/client';
|
||||
import _ from 'lodash';
|
||||
|
||||
type NullToUndefined<T> = T extends null ? undefined : T;
|
||||
@@ -106,3 +111,26 @@ export const normalizeChallenges = (
|
||||
|
||||
return noNullPath;
|
||||
};
|
||||
|
||||
type NormalizedSurvey = {
|
||||
title: string;
|
||||
responses: {
|
||||
question: string;
|
||||
response: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the extra properties from the SurveyResults array.
|
||||
*
|
||||
* @param surveyResults The SurveyResults array.
|
||||
* @returns The input without the id and userid.
|
||||
*/
|
||||
export const normalizeSurveys = (
|
||||
surveyResults: Survey[]
|
||||
): NormalizedSurvey[] => {
|
||||
return surveyResults.map(survey => {
|
||||
const { title, responses } = survey;
|
||||
return { title, responses };
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user