Skip to content
Snippets Groups Projects
Commit 5482b317 authored by Yoan VALLET's avatar Yoan VALLET
Browse files

feat: check if report is enable in user profil

parent ed50dd3c
No related branches found
No related tags found
3 merge requests!103Support,!102Dev,!83Features/113 bilan mensuel
......@@ -142,7 +142,7 @@ export class UserProfile {
ecogestureHash: string
haveSeenWelcomeModal: boolean
notificationEcogesture: string[]
report: string
report: boolean
constructor(
id: string,
......@@ -151,7 +151,7 @@ export class UserProfile {
ecogestureHash: string,
haveSeenWelcomeModal: boolean,
notificationEcogesture: string[],
report: string
report: boolean
) {
this.id = id
this.level = level
......
......@@ -3,6 +3,8 @@ import { runService } from './service'
import { Client } from 'cozy-client'
import { createEmail } from './createEmail'
import UserProfileManager from 'services/userProfileDataManagerService'
const log = logger.namespace('report')
interface MonthlyReportProps {
......@@ -10,10 +12,22 @@ interface MonthlyReportProps {
}
const monthlyReport = async ({ client }: MonthlyReportProps) => {
log('info', 'Fetching data for mail...')
log('info', 'Fetching user profile...')
const upm = new UserProfileManager(client)
const userProfil = await upm.getUserProfile()
if (!userProfil || !userProfil.report) {
log('info', 'End of process - Report disabled in user profile')
return
}
const username = ''
const url = ''
const period = ''
const monthlyPerformance = '--%'
log('info', 'Fetching data for mail...')
log('info', 'Creation of mail...')
const mailContent = createEmail('John Doe', "Mois d'aout 2020", '-5%')
const mailContent = createEmail(username, url, period, monthlyPerformance)
const mailData = {
mode: 'noreply',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment