54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
|
export interface QuestionData {
|
||
|
questionId: number;
|
||
|
title: string;
|
||
|
content: string;
|
||
|
userName: string;
|
||
|
created: Date;
|
||
|
answers: AnswerData[];
|
||
|
}
|
||
|
|
||
|
export interface AnswerData {
|
||
|
answertId: number;
|
||
|
content: string;
|
||
|
userName: string;
|
||
|
created: Date;
|
||
|
}
|
||
|
|
||
|
const questions: QuestionData[] = [
|
||
|
{
|
||
|
questionId: 1,
|
||
|
title: 'Why should I learn TypeScript?',
|
||
|
content:
|
||
|
'TypeScript seems to be getting popular so I wonder whether it is worth my time learning it? What benefits does it give over JavaScript?',
|
||
|
userName: 'Bob',
|
||
|
created: new Date(),
|
||
|
answers: [
|
||
|
{
|
||
|
answertId: 1,
|
||
|
content: 'To catch problems earlier speeding up your development',
|
||
|
userName: 'Jane',
|
||
|
created: new Date(),
|
||
|
},
|
||
|
{
|
||
|
answertId: 2,
|
||
|
content: 'So, that you can use the JS features of tomorrow, today',
|
||
|
userName: 'Fred',
|
||
|
created: new Date(),
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
questionId: 2,
|
||
|
title: 'Which state management tool should I use?',
|
||
|
content:
|
||
|
'There seem to be a fair few state management tools around for React - React, Unstated, ... Which one should I use?',
|
||
|
userName: 'Bob',
|
||
|
created: new Date(),
|
||
|
answers: [],
|
||
|
},
|
||
|
];
|
||
|
|
||
|
export const getUnansweredQuestions = (): QuestionData[] => {
|
||
|
return questions.filter((q) => q.answers.length === 0);
|
||
|
};
|