diff --git a/src/components/ContainerComponents/ViewContainer/ProfileViewContainer.tsx b/src/components/ContainerComponents/ViewContainer/ProfileViewContainer.tsx index 040d30589dca999ad904e120d0dcfed80aea3939..e6aceefc3b9ecf92703e81be59505f0084eb3382 100644 --- a/src/components/ContainerComponents/ViewContainer/ProfileViewContainer.tsx +++ b/src/components/ContainerComponents/ViewContainer/ProfileViewContainer.tsx @@ -3,7 +3,7 @@ import CozyBar from 'components/ContainerComponents/CozyBar/CozyBar' import Header from 'components/ContainerComponents/Header/Header' import Content from 'components/ContainerComponents/Content/Content' import KonnectorViewerContainer from 'components/ContainerComponents/KonnectorViewerContainer/KonnectorViewerContainer' -import EnergyRecap from 'components/ContentComponents/EnergyRecap/EnergyRecap' +import Report from 'components/ContentComponents/Report/Report' const ProfileViewContainer: React.FC = () => { const [headerHeight, setHeaderHeight] = useState<number>(0) @@ -18,7 +18,7 @@ const ProfileViewContainer: React.FC = () => { desktopTitleKey={'COMMON.APP_PARAMETERS_TITLE'} ></Header> <Content height={headerHeight}> - <EnergyRecap /> + <Report /> <KonnectorViewerContainer isParam={true} /> </Content> </> diff --git a/src/components/ContainerComponents/ViewContainer/ViewContainer.tsx b/src/components/ContainerComponents/ViewContainer/ViewContainer.tsx index 9ddce6b16d0b543ba90d86b57c050c283a466a69..cf4ac4cc891b2b966dd6d9f1656b28ae203e9ad3 100644 --- a/src/components/ContainerComponents/ViewContainer/ViewContainer.tsx +++ b/src/components/ContainerComponents/ViewContainer/ViewContainer.tsx @@ -119,18 +119,7 @@ export const ViewContainer = () => { </> )} /> - <Route - path="/profile" - render={({ match: { url } }) => ( - <> - <Route - path={`${url}/`} - component={ProfileViewContainer} - exact - /> - </> - )} - /> + <Route path="/profile" component={ProfileViewContainer} /> <Route path="/splash" component={SplashContainer} /> <Redirect from="/" to="/consumption" /> <Redirect from="*" to="/consumption" /> diff --git a/src/components/ContentComponents/EnergyRecap/EnergyRecap.tsx b/src/components/ContentComponents/Report/Report.tsx similarity index 67% rename from src/components/ContentComponents/EnergyRecap/EnergyRecap.tsx rename to src/components/ContentComponents/Report/Report.tsx index c20f14694bcd84b654d6261fc2d6c6bf77726a06..838085ffe28825164b780427c35822f884b366ae 100644 --- a/src/components/ContentComponents/EnergyRecap/EnergyRecap.tsx +++ b/src/components/ContentComponents/Report/Report.tsx @@ -4,75 +4,71 @@ import { AppContext } from 'components/Contexts/AppContextProvider' import UserProfileManager from 'services/userProfileDataManagerService' import { Client, withClient } from 'cozy-client' -interface EnergyRecapProps { +interface ReportProps { t: Function client: Client } -const EnergyRecap: React.FC<EnergyRecapProps> = ({ - t, - client, -}: EnergyRecapProps) => { +const Report: React.FC<ReportProps> = ({ t, client }: ReportProps) => { const [state, setstate] = useState<string>('') const { userProfile } = useContext(AppContext) const upm = new UserProfileManager(client) const updatedUserProfile = async (value: string) => { - return await upm.updateUserProfile({ energyBilanRecap: value }) + return await upm.updateUserProfile({ report: value }) } useEffect(() => { - if (userProfile && userProfile.energyBilanRecap) - setstate(userProfile.energyBilanRecap) + if (userProfile && userProfile.report) setstate(userProfile.report) }, []) - const handleChange = (e: any) => { + const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { updatedUserProfile(e.target.value).then(data => { - if (data) setstate(data.energyBilanRecap) + if (data) setstate(data.report) }) } return ( <div className="energy-recap-container"> <div className="head text-14-normal-uppercase"> - Réception du bilan énergétique + {t('PROFILE.REPORT.TITLE')} </div> <form action="" className="radios"> <div className="input"> <input id="weekly" - name="energyBilanRecap" + name="report" type="radio" value="weekly" onChange={handleChange} checked={state === 'weekly'} ></input> - <label htmlFor="weekly">Hebdomadaire</label> + <label htmlFor="weekly"> {t('PROFILE.REPORT.WEEKLY')}</label> </div> <div className="input"> <input id="monthly" - name="energyBilanRecap" + name="report" type="radio" value="monthly" onChange={handleChange} checked={state === 'monthly'} ></input> - <label htmlFor="monthly">Mensuel</label> + <label htmlFor="monthly"> {t('PROFILE.REPORT.MONTHLY')}</label> </div> <div className="input"> <input id="never" - name="energyBilanRecap" + name="report" type="radio" value="never" onChange={handleChange} checked={state === 'never'} ></input> - <label htmlFor="never">Jamais</label> + <label htmlFor="never"> {t('PROFILE.REPORT.NEVER')}</label> </div> </form> </div> ) } -export default translate()(withClient(EnergyRecap)) +export default translate()(withClient(Report)) diff --git a/src/locales/fr.json b/src/locales/fr.json index c6e5712025f45851e3d8e837d52c54395d69416c..e063790cb983bf298ab633c70a9a00389e79096a 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -110,6 +110,14 @@ "DISPLAY_DETAIL": "Voir le détail", "DISPLAY_LAST_DATA": "Voir mes dernières consos" }, + "PROFILE": { + "REPORT": { + "TITLE": "Réception du bilan énergétique", + "WEEKLY": "Hebdomadaire", + "MONTHLY": "Mensuel", + "NEVER": "Jamais" + } + }, "KONNECTORCONFIG": { "TITLE_CONNECTION": "Connexion aux distributeurs", "TITLE_KONNECTEURS": "connecteurs", diff --git a/src/services/dataChallengeContracts.ts b/src/services/dataChallengeContracts.ts index 3c6471adc19dfd5d90daf4ff9936a88d5e9c2eeb..61b0ee344d54edd2a14ffaadb313d5fef18876aa 100644 --- a/src/services/dataChallengeContracts.ts +++ b/src/services/dataChallengeContracts.ts @@ -141,7 +141,7 @@ export class UserProfile { challengeTypeHash: string ecogestureHash: string haveSeenWelcomeModal: boolean - energyBilanRecap: string + report: string constructor( id: string, @@ -149,14 +149,14 @@ export class UserProfile { challengeTypeHash: string, ecogestureHash: string, haveSeenWelcomeModal: boolean, - energyBilanRecap: string + report: string ) { this.id = id this.level = level this.challengeTypeHash = challengeTypeHash this.ecogestureHash = ecogestureHash this.haveSeenWelcomeModal = haveSeenWelcomeModal - this.energyBilanRecap = energyBilanRecap + this.report = report } }