diff --git a/manifest.webapp b/manifest.webapp index 06e58b9f889162e5f300fcf2df02dd3aa8a82646..30a522b20cb83f9aa103882f1081dfcb4fb3b9a5 100644 --- a/manifest.webapp +++ b/manifest.webapp @@ -22,9 +22,9 @@ } }, "services": { - "monthlyReport": { + "monthlyReportNotification": { "type": "node", - "file": "services/monthlyReport/ecolyo.js", + "file": "services/monthlyReportNotification/ecolyo.js", "trigger": "@cron 0 0 * * * *" } }, diff --git a/src/atoms/userProfile.state.ts b/src/atoms/userProfile.state.ts index 848cb6127f05a896ca994b08c5003016f8614c70..ef16b1834eb0b1df0188e9c5e94beff87f02f597 100644 --- a/src/atoms/userProfile.state.ts +++ b/src/atoms/userProfile.state.ts @@ -11,6 +11,6 @@ export const userProfileState = atom<UserProfile>({ haveSeenWelcomeModal: false, haveSeenOldFluidModal: false, notificationEcogesture: [], - report: false, + sendReportNotification: false, }, }) diff --git a/src/components/Options/ReportOptions.tsx b/src/components/Options/ReportOptions.tsx index 4ba49f8528cfa5886b6ae2c15c96ed373c81d841..493bb50c1fe0dbb8acf0b302f2eba6fe6890e55b 100644 --- a/src/components/Options/ReportOptions.tsx +++ b/src/components/Options/ReportOptions.tsx @@ -17,7 +17,7 @@ const ReportOptions: React.FC = () => { async (value: boolean) => { const userProfileService = new UserProfileService(client) await userProfileService - .updateUserProfile({ report: value }) + .updateUserProfile({ sendReportNotification: value }) .then(updatedUserProfile => { updatedUserProfile && setUserProfile(updatedUserProfile) }) @@ -46,7 +46,9 @@ const ReportOptions: React.FC = () => { value="true" onChange={handleChange} checked={ - userProfile && userProfile.report === true ? true : false + userProfile && userProfile.sendReportNotification === true + ? true + : false } ></input> <label htmlFor="monthly"> {t('PROFILE.REPORT.MONTHLY')}</label> @@ -59,7 +61,9 @@ const ReportOptions: React.FC = () => { value="false" onChange={handleChange} checked={ - userProfile && userProfile.report === false ? true : false + userProfile && userProfile.sendReportNotification === false + ? true + : false } ></input> <label htmlFor="never"> {t('PROFILE.REPORT.NEVER')}</label> diff --git a/src/db/userProfileData.json b/src/db/userProfileData.json index 6c7cc86923bf222058321f83c0c8e46d979dfc85..d1699a2202ac55b2804deaabba6b6b24a7d26568 100644 --- a/src/db/userProfileData.json +++ b/src/db/userProfileData.json @@ -6,6 +6,6 @@ "haveSeenWelcomeModal": false, "haveSeenOldFluidModal": false, "notificationEcogesture": ["0085", "0092"], - "report": false + "sendReportNotification": false } ] diff --git a/src/models/userProfile.model.ts b/src/models/userProfile.model.ts index be4994ed1f2b04d2f426ec7f56e6807ca48b5cb0..69660d77d0e5185df72ea707c0c7407e9c918ecc 100644 --- a/src/models/userProfile.model.ts +++ b/src/models/userProfile.model.ts @@ -8,5 +8,5 @@ export interface UserProfile { haveSeenWelcomeModal: boolean haveSeenOldFluidModal: DateTime | false notificationEcogesture: string[] - report: boolean + sendReportNotification: boolean } diff --git a/src/targets/services/monthlyReport.ts b/src/targets/services/monthlyReportNotification.ts similarity index 91% rename from src/targets/services/monthlyReport.ts rename to src/targets/services/monthlyReportNotification.ts index adadaf71ffeb7f841c9f0dcc2bdf136ce4f9b4ec..97e72e5f2a6359d6d70662ae2c57e5529ffb6a04 100644 --- a/src/targets/services/monthlyReport.ts +++ b/src/targets/services/monthlyReportNotification.ts @@ -11,16 +11,18 @@ import PerformanceIndicatorService from 'services/performanceIndicator.service' const log = logger.namespace('report') -interface MonthlyReportProps { +interface MonthlyReportNotificationProps { client: Client } -const monthlyReport = async ({ client }: MonthlyReportProps) => { +const monthlyReportNotification = async ({ + client, +}: MonthlyReportNotificationProps) => { log('info', 'Fetching user profile...') const upm = new UserProfileService(client) const userProfil = await upm.getUserProfile() - if (!userProfil || !userProfil.report) { - log('info', 'End of process - Report disabled in user profile') + if (!userProfil || !userProfil.sendReportNotification) { + log('info', 'End of process - Report Notification disabled in user profile') return } @@ -132,4 +134,4 @@ const monthlyReport = async ({ client }: MonthlyReportProps) => { } } -runService(monthlyReport) +runService(monthlyReportNotification)