Files
doneit-web/src/app/services/task.service.ts
T

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-04-12 09:01:03 +01:00
import { Injectable } from '@angular/core';
import { momentG } from 'src/plugin/momentG';
@Injectable({
providedIn: 'root'
})
export class TaskService {
constructor() { }
deadlineIsToday(isoDateString:string) {
2023-04-13 12:51:38 +01:00
if(!isoDateString) {
return false
}
2023-04-12 09:01:03 +01:00
return momentG(new Date(), 'dd MMMM yyyy') == momentG(new Date(isoDateString), 'dd MMMM yyyy')
}
lessThen24Hours(isoDateString:string) {
2023-04-13 12:51:38 +01:00
if(!isoDateString) {
console.log('no created date')
return true
}
2023-04-12 09:01:03 +01:00
const creationDate = new Date(isoDateString)
const creationDatePlus24h = new Date(creationDate)
creationDatePlus24h.setHours((creationDate.getHours() + 24))
const currentDate = new Date()
return creationDatePlus24h.getTime() > currentDate.getTime()
}
2023-04-12 14:39:26 +01:00
filter(item, attribute) {
if(attribute == 'Para hoje') {
return this.deadlineIsToday(item.TaskStartDate)
} else if (attribute == 'Novos') {
return this.lessThen24Hours(item.TaskStartDate)
} else if (attribute == 'Lidos') {
return item.TaskStatus == 'open'
} else if (attribute == 'Não lidos') {
return item.TaskStatus != 'open'
}
return true
}
2023-04-12 09:01:03 +01:00
}