In the backend, I have an interface structured like this:
export interface DailyGoal extends Base {
date: Date;
percentage: number;
}
Now, I am attempting to reference that in my component.ts file
import { DailyGoal } from '../../interfaces';
dailyGoal: DailyGoal[] = [];
However, I am unsure of how to assign values to the 'date' and 'percentage' properties. I have created a function to generate a list of selectable days for the user (Still working on implementing the 'percentage')
getDays(startDate: Date, endDate: Date) {
const dates = [];
const percentage = [];
const currentDate = startDate;
while (currentDate < endDate) {
dates.push(new Date(currentDate));
currentDate.setDate(currentDate.getDate() + 1);
}
// for (let date of dates) {
// if (date.getDay() <= 5) {
// percentage.push(100);
//
// } else date.getDay() > 5;
// percentage.push(0);
if (startDate && endDate) dates.push(endDate);
return dates;
}
How can I assign my 'date' variable to the interface? Your assistance would be greatly appreciated. Thank you.