Skip to content

Commit

Permalink
[WIP] Add Survey Chart, broken UI for long labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavriil-Tzortzakis committed Nov 30, 2024
1 parent 671a26e commit 7c7d6ee
Show file tree
Hide file tree
Showing 10 changed files with 688 additions and 173 deletions.
20 changes: 20 additions & 0 deletions shared/locales/en/website-responses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"select-survey": "Select survey",
"title": "Survey Responses",
"onboarding": {
"title": "Onboarding Survey",
"description": "Filled out once before recipient is joining the program"
},
"checkin": {
"title": "Check-in Survey",
"description": "Filled out every 6 months while recipient is in the program"
},
"offboarding": {
"title": "Offboarding Survey",
"description": "Filled out once when recipient is finishing the program"
},
"offboarded-checkin": {
"title": "Follow-up Survey",
"description": "Filled out every 6 months after recipient left the program"
}
}
6 changes: 4 additions & 2 deletions shared/locales/en/website-survey.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"questions": {
"yesNoChoices": {
"yes": "Yes",
"no": "No"
"no": "No",
"true": "Yes",
"false": "No"
},
"livingLocationTitleV1": "Where do you live?",
"livingLocationChoices": {
Expand Down Expand Up @@ -98,7 +100,7 @@
"saving": "Saving for the future (saving it in a bank account or on my mobile money account ...)",
"investment": "Investment (fertilizers, tools, diesel for machinery ...)"
},
"spendingRankingTitleV1": "Please rank the selected spending categories from the most important to the least.",
"spendingRankedTitleV1": "Please rank the selected spending categories from the most important to the least.",
"spendingRankingDescV1": "You can drag and drop the categories.",
"plannedAchievementRemainingTitleV1": "What do you hope to achieve within the remaining time in the Social Income program? ",

Expand Down
4 changes: 3 additions & 1 deletion shared/locales/it/website-survey.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"questions": {
"yesNoChoices": {
"yes": "Yes",
"no": "No"
"no": "No",
"true": "Yes",
"false": "No"
},
"livingLocationTitleV1": "Where do you live?",
"livingLocationChoices": {
Expand Down
4 changes: 3 additions & 1 deletion shared/locales/kri/website-survey.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"questions": {
"yesNoChoices": {
"yes": "Yɛs",
"no": ""
"no": "",
"true": "Yɛs",
"false": ""
},
"livingLocationTitleV1": "Usay yu tap?",
"livingLocationChoices": {
Expand Down
271 changes: 271 additions & 0 deletions shared/src/types/question.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
export interface Question {
type: QuestionInputType;
name: string;
choices: any[];
choicesTranslationKey?: string;
translationKey: string;
descriptionTranslationKey?: string;
}

export enum QuestionInputType {
RADIO_GROUP = 'radiogroup',
COMMENT = 'comment',
CHECKBOX = 'checkbox',
RANKING = 'ranking',
}

export const MARITAL_STATUS: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'maritalStatusV1',
choices: ['married', 'widowed', 'divorced', 'separated', 'neverMarried'],
choicesTranslationKey: 'survey.questions.maritalStatusChoices',
translationKey: 'survey.questions.maritalStatusTitleV1',
};

export const LIVING_LOCATION: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'livingLocationV1',
choices: [
'westernAreaUrbanFreetown',
'westernAreaRural',
'easternProvince',
'northernProvince',
'southernProvince',
'northWestProvince',
],
translationKey: 'survey.questions.livingLocationTitleV1',
choicesTranslationKey: 'survey.questions.livingLocationChoices',
};

export const BOOLEAN_CHOICES = { choices: [true, false], choicesTranslationKey: 'survey.questions.yesNoChoices' };

export const HAS_DEPENDENTS: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'hasDependentsV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.hasDependentsTitleV1',
descriptionTranslationKey: 'survey.questions.hasDependentsDescV1',
};

export const NOT_EMPLOYED: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'notEmployedV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.notEmployedTitleV1',
};

export const NUMBER_OF_DEPENDENTS: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'nrDependentsV1',
choices: ['1-2', '3-4', '5-7', '8-10', '10-'],
translationKey: 'survey.questions.nrDependentsTitleV1',
choicesTranslationKey: 'survey.questions.nrDependentsChoices',
};

export const SCHOOL_ATTENDANCE: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'schoolAttendanceV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.attendingSchoolV1',
};

export const EMPLOYMENT_STATUS: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'employmentStatusV1',
choices: ['employed', 'selfEmployed', 'notEmployed', 'retired'],
translationKey: 'survey.questions.employmentStatusTitleV1',
choicesTranslationKey: 'survey.questions.employmentStatusChoices',
};
export const DISABILITY: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'disabilityV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.disabilityTitleV1',
};

export const SKIPPING_MEALS: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'skippingMealsV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.skippingMealsTitleV1',
};

export const SKIPPING_MEALS_LAST_WEEK: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'skippingMealsLastWeekV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.skippingMealsLastWeekTitleV1',
};

export const SKIPPING_MEALS_LAST_WEEK_3_MEALS: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'skippingMealsLastWeek3MealsV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.skippingMealsLastWeek3MealsTitleV1',
};

export const UNEXPECTED_EXPENSES_COVERED: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'unexpectedExpensesCoveredV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.unexpectedExpensesCoveredTitleV1',
};
export const SAVINGS: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'savingsV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.savingsTitleV1',
};

export const DEPT_PERSONAL: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'debtPersonalV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.debtPersonalTitleV1',
};

export const DEPT_PERSONAL_REPAY: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'debtPersonalRepayV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.debtPersonalRepayTitleV1',
};

export const DEPT_HOUSEHOLD: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'debtHouseholdV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.debtHouseholdTitleV1',
};
export const DEPT_HOUSEHOLD_WHO_REPAYS: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'debtHouseholdWhoRepaysV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.debtHouseholdWhoRepaysTitleV1',
};
export const OTHER_SUPPORT: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'otherSupportV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.otherSupportTitleV1',
};

export const PLANNED_ACHIEVEMENT: Question = {
type: QuestionInputType.COMMENT,
name: 'plannedAchievementV1',
translationKey: 'survey.questions.plannedAchievementTitleV1',
choices: [],
};

export const SPENDING: Question = {
type: QuestionInputType.CHECKBOX,
name: 'spendingV1',
choices: ['education', 'food', 'housing', 'healthCare', 'mobility', 'saving', 'investment'],
translationKey: 'survey.questions.spendingTitleV1',
choicesTranslationKey: 'survey.questions.spendingChoices',
};

export const PLANNED_ACHIEVEMENT_REMAINING: Question = {
type: QuestionInputType.COMMENT,
name: 'plannedAchievementRemainingV1',
translationKey: 'survey.questions.plannedAchievementRemainingTitleV1',
choices: [],
};

export const IMPACT_FINANCIAL_INDEPENDENCE: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'impactFinancialIndependenceV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.financialIndependenceTitleV1',
};

export const IMPACT_LIFE_GENERAL: Question = {
type: QuestionInputType.COMMENT,
name: 'impactLifeGeneralV1',
translationKey: 'survey.questions.impactLifeGeneralTitleV1',
choices: [],
};

export const ACHIEVEMENTS_ACHIEVED: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'achievementsAchievedV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.achievementsAchievedTitleV1',
};

export const ACHIEVEMENTS_NOT_ACHIEVED: Question = {
type: QuestionInputType.COMMENT,
name: 'achievementsNotAchievedCommentV1',
choices: [],
translationKey: 'survey.questions.achievementsNotAchievedCommentTitleV1',
};

export const HAPPIER: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'happierV1',
...BOOLEAN_CHOICES,
translationKey: 'survey.questions.happierTitleV1',
};

export const HAPPIER_COMMENT: Question = {
type: QuestionInputType.COMMENT,
name: 'happierCommentV1',
translationKey: 'survey.questions.happierCommentTitleV1',
choices: [],
};
export const NOT_HAPPIER_COMMENT: Question = {
type: QuestionInputType.COMMENT,
translationKey: 'survey.questions.notHappierCommentTitleV1',
name: 'notHappierCommentV1',
choices: [],
};

export const LONG_ENOUGH: Question = {
type: QuestionInputType.RADIO_GROUP,
name: 'longEnough',
translationKey: 'survey.questions.longEnoughTitleV1',
...BOOLEAN_CHOICES,
};

export const RANKING: Question = {
type: QuestionInputType.RANKING,
name: 'spendingRankedV1',
choices: [],
translationKey: 'survey.questions.spendingRankedV1',
descriptionTranslationKey: 'survey.questions.spendingRankingDescV1',
};

const ALL_QUESTIONS = [
MARITAL_STATUS,
LIVING_LOCATION,
HAS_DEPENDENTS,
NUMBER_OF_DEPENDENTS,
SCHOOL_ATTENDANCE,
EMPLOYMENT_STATUS,
DISABILITY,
SKIPPING_MEALS,
SKIPPING_MEALS_LAST_WEEK,
SKIPPING_MEALS_LAST_WEEK_3_MEALS,
UNEXPECTED_EXPENSES_COVERED,
SAVINGS,
DEPT_PERSONAL,
DEPT_PERSONAL_REPAY,
DEPT_HOUSEHOLD,
DEPT_HOUSEHOLD_WHO_REPAYS,
OTHER_SUPPORT,
PLANNED_ACHIEVEMENT,
SPENDING,
PLANNED_ACHIEVEMENT_REMAINING,
IMPACT_FINANCIAL_INDEPENDENCE,
IMPACT_LIFE_GENERAL,
ACHIEVEMENTS_ACHIEVED,
ACHIEVEMENTS_NOT_ACHIEVED,
HAPPIER,
HAPPIER_COMMENT,
NOT_HAPPIER_COMMENT,
LONG_ENOUGH,
RANKING,
NOT_EMPLOYED,
];

export const QUESTIONS_DICTIONARY: Map<String, Question> = new Map(ALL_QUESTIONS.map((obj) => [obj.name, obj]));
Loading

0 comments on commit 7c7d6ee

Please sign in to comment.