Skip to content
Snippets Groups Projects
Commit aa708af8 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

chore(types): fix types error

parent 6e643db6
Branches
Tags
2 merge requests!11623.0 Release,!1134chore(types): fix types error
Showing with 76 additions and 74 deletions
......@@ -35,6 +35,7 @@ const ElecHalfHourMonthlyAnalysis = ({
const { t } = useI18n()
const client = useClient()
const { analysisMonth } = useAppSelector(state => state.ecolyo.analysis)
const [isWeekend, setIsWeekend] = useState<boolean>(true)
const [isHalfHourActivated, setIsHalfHourActivated] = useState<boolean>(true)
const [isLoading, setIsLoading] = useState<boolean>(true)
......@@ -51,19 +52,21 @@ const ElecHalfHourMonthlyAnalysis = ({
setIsWeekend(prev => !prev)
}, [])
const toggleOpenModal = useCallback(() => {
const toggleInfoModal = useCallback(() => {
setOpenInfoModal(prev => !prev)
}, [])
const isDataFullyComplete = useCallback(monthDataloads => {
if (
const isDataFullyComplete = useCallback(
(monthDataloads: AggregatedEnedisMonthlyDataloads | undefined) => {
return (
monthDataloads?.weekend &&
monthDataloads.week &&
monthDataloads.weekend[0]?.value !== null &&
monthDataloads.week[0]?.value !== null
) {
return true
} else return false
}, [])
)
},
[]
)
const getPowerChart = useCallback((): JSX.Element => {
if (monthDataloads && isDataFullyComplete(monthDataloads)) {
......@@ -73,9 +76,8 @@ const ElecHalfHourMonthlyAnalysis = ({
isWeekend={isWeekend}
/>
)
} else {
return <p className="text-20-bold no_data">{t('analysis.no_data')}</p>
}
return <p className="text-20-bold no_data">{t('analysis.no_data')}</p>
}, [isDataFullyComplete, isWeekend, monthDataloads, t])
useEffect(() => {
......@@ -279,7 +281,7 @@ const ElecHalfHourMonthlyAnalysis = ({
</div>
</div>
<Button className="btnText" onClick={toggleOpenModal}>
<Button className="btnText" onClick={toggleInfoModal}>
{t('special_elec.showModal')}
</Button>
</div>
......@@ -291,7 +293,7 @@ const ElecHalfHourMonthlyAnalysis = ({
<ElecInfoModal
open={openInfoModal}
offPeakHours={offPeakHours}
handleCloseClick={toggleOpenModal}
handleCloseClick={toggleInfoModal}
/>
</div>
)
......
......@@ -45,12 +45,12 @@ const SingleEcogestureView = () => {
const [, setValidExploration] = useExploration()
const updateEcogesture = useCallback(
async (objective, doing) => {
async (objective: boolean, doing: boolean) => {
if (ecogesture) {
const updates: Ecogesture = {
...ecogesture,
objective: objective,
doing: doing,
objective,
doing,
}
const result = await ecogestureService.updateEcogesture(updates)
if (result) {
......
import { OutlinedInput } from '@material-ui/core'
import StyledSwitch from 'components/CommonKit/Switch/StyledSwitch'
import { useClient } from 'cozy-client'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
......@@ -9,7 +10,6 @@ import ConsumptionDataManager from 'services/consumption.service'
import { useAppDispatch, useAppSelector } from 'store/hooks'
import { updateProfile } from 'store/profile/profile.slice'
import './reportOptions.scss'
import { TextField } from '@material-ui/core'
const ReportOptions = () => {
const { t } = useI18n()
......@@ -37,7 +37,9 @@ const ReportOptions = () => {
fluidStatus[FluidType.WATER].status !== FluidState.KONNECTOR_NOT_FOUND &&
fluidStatus[FluidType.WATER].status !== FluidState.ERROR_LOGIN_FAILED
const setWaterLimit = (e: React.ChangeEvent<HTMLInputElement>) => {
const setWaterLimit = (
e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement, Element>
) => {
if (e.target.value !== null && parseInt(e.target.value) > 0) {
dispatch(
updateProfile({
......@@ -134,8 +136,7 @@ const ReportOptions = () => {
{t('profile.report.input_label_alert')}
</div>
<div className="switch-container-alert">
<TextField
variant="outlined"
<OutlinedInput
className="inputNumber text-18"
type="number"
defaultValue={
......@@ -144,7 +145,12 @@ const ReportOptions = () => {
: profile.waterDailyConsumptionLimit
}
onBlur={setWaterLimit}
label={t('profile.accessibility.input_water_alert_report')}
inputProps={{
min: 0,
}}
aria-label={t(
'profile.accessibility.input_water_alert_report'
)}
inputMode="numeric"
/>
<span className="switch-label text-16-normal">L</span>
......
......@@ -53,7 +53,7 @@ const ProfileTypeFinished = ({ profileType }: { profileType: ProfileType }) => {
}),
}
const profileTypeEntityService = new ProfileTypeEntityService(client)
const myProfileTypes: ProfileType[] | null =
const myProfileTypes =
await profileTypeEntityService.getAllProfileTypes(chosenPeriod)
if (myProfileTypes !== null) {
const destroyPT =
......
......@@ -12,7 +12,6 @@
"coldWater": "individual",
"hotWater": "individual",
"individualInsulationWork": ["window_replacement"],
"facilitiesInstallation": "none",
"hotWaterEquipment": "solar",
"hasInstalledVentilation": "unknown",
"hasReplacedHeater": "unknown",
......
/* eslint-disable camelcase */
export interface AccountAttributes {
account_type: string
auth?: AccountEGLData | AccountSgeData | AccountGRDFData
identifier?: string
state?: string | null
name?: string
data?: SgeAccountData
}
export interface Account extends AccountAttributes {
_id: string
id?: string
......@@ -12,17 +20,6 @@ export interface SgeAccountData {
offPeakHours?: string
}
export interface AccountAttributes {
account_type: string
auth?: AccountEGLData | AccountSgeData | AccountGRDFData
identifier?: string
state?: string | null
name?: string
data?: SgeAccountData
// TODO remove this ?
oauth_callback_results?: Record<string, any>
}
export interface AccountEGLData {
login: string
credentials_encrypted?: string
......
......@@ -533,11 +533,10 @@ describe('ProfileType service', () => {
DateTime.fromISO('2021-01-01T00:00:00.000Z', { zone: 'utc' })
)
const expectedResult = {
const expectedResult: ProfileType = {
...mockProfile,
warmingFluid: null,
individualInsulationWork: [],
facilitiesInstallation: [],
hotWaterFluid: null,
hotWaterEquipment: HotWaterEquipment.OTHER,
}
......
......@@ -479,7 +479,6 @@ export default class ProfileTypeService {
if (profileType.heating === IndividualOrCollective.COLLECTIVE) {
profileType.warmingFluid = null
profileType.individualInsulationWork = []
profileType.facilitiesInstallation = []
}
if (profileType.hotWater === IndividualOrCollective.COLLECTIVE) {
profileType.hotWaterFluid = null
......
......@@ -7,23 +7,24 @@ export const accountsData: Account[] = [
_rev: '1-88e68b8450cee09fe2f077610901094d',
account_type: 'enedissgegrandlyon',
name: '',
oauth: {
access_token: 'MY_ACCESS_TOKEN',
expires_at: '2020-10-09T08:00:00.285910671+02:00',
refresh_token: '',
token_type: 'Bearer',
},
oauth_callback_results: {
issued_at: '1592232569642',
refresh_token_issued_at: '1592232569642',
scope: '/my_enedis_scope',
usage_points_id: '',
},
cozyMetadata: {
createdAt: '2020-11-10T16:42:11.132Z',
metadataVersion: 1,
updatedAt: '2020-11-10T16:42:11.132Z',
},
auth: {
address: '6 Rue Vaillant Couturier',
city: 'Vénissieux',
firstname: 'Jane',
lastname: 'Doe',
pointId: '19170766804121',
postalCode: '69200',
},
data: {
consentId: 43,
expirationDate: '2023-09-26',
offPeakHours: '22H00-6H00',
},
},
{
_id: '90e68b8450cee09fe2f077610901094d',
......@@ -51,16 +52,13 @@ export const accountsData: Account[] = [
_rev: '1-89e68b8450cee09fe2f077610901094d',
account_type: 'grdfgrandlyon',
name: '',
oauth: {
access_token: 'MY_ACCESS_TOKEN',
expires_at: '2020-10-09T08:00:00.285910671+02:00',
refresh_token: '',
token_type: 'Bearer',
},
oauth_callback_results: {
id_token: 'MY_ID_TOKEN',
pce: '12345678987654',
scope: '/my_grdf_scope',
identifier: 'email',
auth: {
email: 'jane@grandlyon.com',
firstname: 'Jane',
lastname: 'Doe',
pce: '12345678901234',
postalCode: '69003',
},
cozyMetadata: {
createdAt: '2020-11-10T16:42:11.132Z',
......
......@@ -13,6 +13,7 @@ export const mockEnedisMonthlyAnalysis: EnedisMonthlyAnalysisData = {
year: 2021,
minimumLoad: 3,
maxPower: 2,
offPeakHoursRatio: null,
}
export const mockEnedisMonthlyAnalysisArray: EnedisMonthlyAnalysisData[] = [
......@@ -23,6 +24,7 @@ export const mockEnedisMonthlyAnalysisArray: EnedisMonthlyAnalysisData[] = [
year: 2021,
minimumLoad: 3,
maxPower: 2,
offPeakHoursRatio: null,
},
{
weekDaysHalfHourAverageValues: [0.35, 0.34, 0.33, 0.32, 0.31, 0.3],
......@@ -31,6 +33,7 @@ export const mockEnedisMonthlyAnalysisArray: EnedisMonthlyAnalysisData[] = [
year: 2021,
minimumLoad: 3,
maxPower: 2,
offPeakHoursRatio: null,
},
{
weekDaysHalfHourAverageValues: [0.35, 0.34, 0.33, 0.32, 0.31, 0.3],
......@@ -39,6 +42,7 @@ export const mockEnedisMonthlyAnalysisArray: EnedisMonthlyAnalysisData[] = [
year: 2021,
minimumLoad: 3,
maxPower: 2,
offPeakHoursRatio: null,
},
{
weekDaysHalfHourAverageValues: [0.35, 0.34, 0.33, 0.32, 0.31, 0.3],
......@@ -47,6 +51,7 @@ export const mockEnedisMonthlyAnalysisArray: EnedisMonthlyAnalysisData[] = [
year: 2021,
minimumLoad: 3,
maxPower: 2,
offPeakHoursRatio: null,
},
]
......
......@@ -7,6 +7,7 @@ export const fluidPrices: FluidPrice[] = [
fluidType: 0,
price: 0.1429,
startDate: '2020-08-01T00:00:00.000Z',
UpdatedAt: '',
},
{
_id: '03045ea1afecc7a86e5443a52e00b07d',
......@@ -14,6 +15,7 @@ export const fluidPrices: FluidPrice[] = [
fluidType: 0,
price: 0.1529,
startDate: '2021-01-01T00:00:00.000Z',
UpdatedAt: '',
},
{
_id: '03045ea1afecc7a86e5443a52e00b07d',
......@@ -21,6 +23,7 @@ export const fluidPrices: FluidPrice[] = [
fluidType: 0,
price: 0.1329,
startDate: '2021-10-10T00:00:00.000Z',
UpdatedAt: '',
},
{
_id: '03045ea1afecc7a86e5443a52e00b07d',
......@@ -28,6 +31,7 @@ export const fluidPrices: FluidPrice[] = [
fluidType: 1,
price: 0.0039,
startDate: '2013-08-01T00:00:00.000Z',
UpdatedAt: '',
},
{
_id: '03045ea1afecc7a86e5443a52e00b07d',
......@@ -35,6 +39,7 @@ export const fluidPrices: FluidPrice[] = [
fluidType: 2,
price: 1.029,
startDate: '2013-08-01T00:00:00.000Z',
UpdatedAt: '',
},
{
_id: '03045ea1afecc7a86e5443a52e00b07d',
......@@ -42,6 +47,7 @@ export const fluidPrices: FluidPrice[] = [
fluidType: 2,
price: 1.029,
startDate: '2014-11-01T00:00:00.000Z',
UpdatedAt: '',
},
]
......@@ -52,6 +58,7 @@ export const allLastFluidPrices: FluidPrice[] = [
fluidType: 0,
price: 0.1329,
startDate: '2021-10-10T00:00:00.000Z',
UpdatedAt: '',
},
{
_id: '03045ea1afecc7a86e5443a52e00b07d',
......@@ -59,6 +66,7 @@ export const allLastFluidPrices: FluidPrice[] = [
fluidType: 1,
price: 0.0039,
startDate: '2013-08-01T00:00:00.000Z',
UpdatedAt: '',
},
{
_id: '03045ea1afecc7a86e5443a52e00b07d',
......@@ -66,5 +74,6 @@ export const allLastFluidPrices: FluidPrice[] = [
fluidType: 2,
price: 1.029,
startDate: '2014-11-01T00:00:00.000Z',
UpdatedAt: '',
},
]
......@@ -194,18 +194,6 @@ export const SgeStatusWithAccount: FluidStatus = {
_rev: '1-88e68b8450cee09fe2f077610901094d',
account_type: 'enedissgegrandlyon',
name: '',
oauth: {
access_token: 'MY_ACCESS_TOKEN',
expires_at: '2020-10-09T08:00:00.285910671+02:00',
refresh_token: '',
token_type: 'Bearer',
},
oauth_callback_results: {
issued_at: '1592232569642',
refresh_token_issued_at: '1592232569642',
scope: '/my_enedis_scope',
usage_points_id: '',
},
cozyMetadata: {
createdAt: '2020-11-10T16:42:11.132Z',
metadataVersion: 1,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment