in src/app/dashboard/dashboard.component.ts [220:289]
async populateMissingReminders(frequency) {
// code here to populate the user's customer's reminder for the month
const eligibleCustomer = await this.api.ListCustomers({
user: {
eq: this.appcomponent.user.attributes.email
}
});
// for all the avalable customer assigned to the user, populate reminders for month selected
//console.log('customer', eligibleCustomer.items);
eligibleCustomer.items.forEach(async (customervalue, index) => {
// for all the customers add the reminder items
const reminderMetaData = await this.api.ListReminderMetaDatas({
type: {
eq: frequency
}
});
//console.log('populating reminders', reminderMetaData);
//const reminderuuid = uuidv4();
reminderMetaData.items.forEach(async (remindervalue, index) => {
console.log('Creting reminders for customer', customervalue, remindervalue);
// todo : create reminder here
const reminderuuid = uuidv4();
await this.api.CreateReminder({
id: reminderuuid,
customer: customervalue.customername,
additionalAttribute: 'Not Used',
user: customervalue.user,
start: new Date().toISOString(),
type: remindervalue.type,
week: this.week,
month: this.month,
year: this.year
});
// reminder create ends here
remindervalue.tasks.items.forEach(async (taskvalue, index) => {
//console.log('Creating task for reminder', taskvalue, remindervalue);
const taskid = uuidv4();
// todo : Create tasks here and attach to the reminders
await this.api.CreateTask({
description: taskvalue.description,
status: false,
id: taskid,
taskReminderId: reminderuuid,
title: taskvalue.title
});
// task create ends here
// for each task , check if there are any mandatory comments
//console.log('Need to add if there are any mandatory comment',taskvalue);
taskvalue.mandatorycomments.items.forEach(async (mandatorycommentvalue, index) => {
const mandatorycommentid = uuidv4();
console.log('create mandatory comments for ', mandatorycommentid);
await this.api.CreateMandatoryComment({
mandatoryCommentTaskId: taskid,
title: mandatorycommentvalue.title,
id: mandatorycommentid,
addedon: new Date().toISOString()
});
});
// end code to add mandatory comments
});
});
});
}