I'm currently working on a project that involves creating a generic Type using enums.
Enum
export enum OverviewSections {
ALL = 'all',
SCORE = 'score_breakdown',
PERFORMANCE = 'performance_over_time',
ENGAGEMENT = 'engagement',
COMPANY = 'company_views_graph',
PEOPLE = 'people_views_graph',
ARTICLES = 'articles_read_graph',
PLATFORM = 'platform_sessions_graph',
EMAILS = 'emails_opened_graph',
}
My goal is to develop a generic type that allows me to structure my data in the following way:
Overview: {
[OverviewSections.ALL]: {
data: IOverview | null,
loading: boolean,
error: boolean
},
[OverviewSections.SCORE]: {
data: IScore | null,
loading: boolean,
error: boolean
},
[OverviewSections.PERFORMANCE]: {
data: IPerformace | null,
loading: boolean,
error: boolean
},
......
},
If anyone has any insights or suggestions on how I can accomplish this, I would greatly appreciate it. Thank you!