Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
web-et-numerique
LLLE_Project
Ecolyo
Commits
5f2d0535
Commit
5f2d0535
authored
May 18, 2022
by
Guilhem CARRON
Browse files
fix(ecogestures): Update ecogesture profile and profiletype properly
parent
eca5ef46
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/components/EcogestureForm/EcogestureFormEquipment.tsx
View file @
5f2d0535
...
...
@@ -7,7 +7,10 @@ import { ProfileEcogesture } from 'models/profileEcogesture.model'
import
{
EquipmentType
}
from
'
enum/ecogesture.enum
'
import
EquipmentIcon
from
'
./EquipmentIcon
'
import
'
./ecogestureFormEquipment.scss
'
import
{
newProfileEcogestureEntry
}
from
'
store/profileEcogesture/profileEcogesture.actions
'
import
{
newProfileEcogestureEntry
,
updateProfileEcogesture
,
}
from
'
store/profileEcogesture/profileEcogesture.actions
'
import
{
useDispatch
,
useSelector
}
from
'
react-redux
'
import
{
updateProfile
}
from
'
store/profile/profile.actions
'
import
{
useHistory
}
from
'
react-router-dom
'
...
...
@@ -43,11 +46,12 @@ const EcogestureFormEquipment: React.FC<EcogestureFormEquipmentProps> = ({
const
handleNext
=
useCallback
(()
=>
{
profileEcogesture
.
equipments
=
answer
as
EquipmentType
[]
dispatch
(
newProfileEcogestureEntry
(
profileEcogesture
))
// Check if gestureForm is used from Big profile or small profile
if
(
setNextStep
)
{
setNextStep
()
dispatch
(
updateProfileEcogesture
(
profileEcogesture
))
}
else
{
dispatch
(
newProfileEcogestureEntry
(
profileEcogesture
))
dispatch
(
updateProfile
({
isProfileEcogestureCompleted
:
true
}))
history
.
push
(
'
/ecogesture-selection
'
)
}
...
...
src/components/EcogestureForm/EcogestureFormView.tsx
View file @
5f2d0535
...
...
@@ -20,11 +20,10 @@ import ProfileEcogestureFormService from 'services/profileEcogestureForm.service
import
StyledSpinner
from
'
components/CommonKit/Spinner/StyledSpinner
'
import
{
FluidType
}
from
'
enum/fluid.enum
'
import
'
./ecogestureFormView.scss
'
import
{
useHistory
,
useLocation
}
from
'
react-router-dom
'
import
{
useLocation
}
from
'
react-router-dom
'
import
ProfileTypeView
from
'
components/ProfileType/ProfileTypeView
'
const
EcogestureFormView
:
React
.
FC
=
()
=>
{
const
history
=
useHistory
()
const
[
headerHeight
,
setHeaderHeight
]
=
useState
<
number
>
(
0
)
const
defineHeaderHeight
=
(
height
:
number
)
=>
{
setHeaderHeight
(
height
)
...
...
@@ -111,9 +110,7 @@ const EcogestureFormView: React.FC = () => {
></
Header
>
<
Content
height
=
{
headerHeight
}
>
{
isProfileTypeCompleted
?
(
<
ProfileTypeView
handleEnd
=
{
()
=>
history
.
push
(
'
/ecogesture-selection
'
)
}
/>
<
ProfileTypeView
/>
)
:
(
<>
{
step
===
EcogestureStepForm
.
EQUIPMENTS
&&
(
...
...
src/components/ProfileType/ProfileTypeFinished.spec.tsx
View file @
5f2d0535
...
...
@@ -7,7 +7,21 @@ import {
}
from
'
../../../tests/__mocks__/store
'
import
ProfileTypeFinished
from
'
./ProfileTypeFinished
'
import
{
mockProfileType
}
from
'
../../../tests/__mocks__/profileType.mock
'
import
{
Button
}
from
'
@material-ui/core
'
const
mockHistoryGoBack
=
jest
.
fn
()
const
mockHistoryPush
=
jest
.
fn
()
jest
.
mock
(
'
react-router-dom
'
,
()
=>
({
...
jest
.
requireActual
(
'
react-router-dom
'
),
useLocation
:
()
=>
({
pathname
:
'
/ecogesture-form
'
,
}),
useHistory
:
()
=>
({
goBack
:
mockHistoryGoBack
,
push
:
mockHistoryPush
,
}),
}))
jest
.
mock
(
'
cozy-ui/transpiled/react/I18n
'
,
()
=>
{
return
{
useI18n
:
jest
.
fn
(()
=>
{
...
...
@@ -18,14 +32,18 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => {
}
})
describe
(
'
ProfileType
View
component
'
,
()
=>
{
describe
(
'
ProfileType
Finished
component
'
,
()
=>
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let
store
:
any
beforeEach
(()
=>
{
jest
.
clearAllMocks
()
store
=
createMockStore
(
mockInitialEcolyoState
)
})
afterEach
(()
=>
{
jest
.
clearAllMocks
()
})
it
(
'
should be rendered correctly
'
,
()
=>
{
it
(
'
should be rendered correctly
'
,
async
()
=>
{
const
wrapper
=
mount
(
<
Provider
store
=
{
store
}
>
<
ProfileTypeFinished
profileType
=
{
mockProfileType
}
/>
...
...
@@ -33,4 +51,16 @@ describe('ProfileTypeView component', () => {
)
expect
(
wrapper
.
find
(
'
profile-type-finished-card
'
)).
toBeTruthy
()
})
it
(
'
should go to ecogesture selection
'
,
()
=>
{
const
wrapper
=
mount
(
<
Provider
store
=
{
store
}
>
<
ProfileTypeFinished
profileType
=
{
mockProfileType
}
/>
</
Provider
>
)
wrapper
.
find
(
Button
)
.
first
()
.
simulate
(
'
click
'
)
expect
(
mockHistoryPush
).
toHaveBeenCalledWith
(
'
/ecogesture-selection
'
)
})
})
src/components/ProfileType/ProfileTypeFinished.tsx
View file @
5f2d0535
...
...
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
import
'
components/ProfileType/profileTypeFinished.scss
'
import
{
useI18n
}
from
'
cozy-ui/transpiled/react/I18n
'
import
{
useDispatch
,
useSelector
}
from
'
react-redux
'
import
{
useHistory
}
from
'
react-router-dom
'
import
{
useHistory
,
useLocation
}
from
'
react-router-dom
'
import
{
updateProfile
}
from
'
store/profile/profile.actions
'
import
{
newProfileTypeEntry
}
from
'
store/profileType/profileType.actions
'
import
{
ProfileType
}
from
'
models/profileType.model
'
...
...
@@ -28,6 +28,7 @@ const ProfileTypeFinished: React.FC<ProfileTypeFinishedProps> = ({
profileType
,
}:
ProfileTypeFinishedProps
)
=>
{
const
{
t
}
=
useI18n
()
const
location
=
useLocation
()
const
dispatch
=
useDispatch
()
const
history
=
useHistory
()
const
client
=
useClient
()
...
...
@@ -35,7 +36,11 @@ const ProfileTypeFinished: React.FC<ProfileTypeFinishedProps> = ({
(
state
:
AppStore
)
=>
state
.
ecolyo
.
challenge
)
const
handleClick
=
()
=>
{
history
.
goBack
()
if
(
location
&&
location
.
pathname
===
'
/ecogesture-form
'
)
{
history
.
push
(
'
/ecogesture-selection
'
)
}
else
{
history
.
goBack
()
}
}
const
[
isSaved
,
setIsSaved
]
=
useState
<
boolean
>
(
false
)
...
...
src/components/ProfileType/ProfileTypeView.tsx
View file @
5f2d0535
...
...
@@ -32,13 +32,7 @@ import ProfileTypeFormDateSelection from './ProfileTypeFormDateSelection'
import
EcogestureFormEquipment
from
'
components/EcogestureForm/EcogestureFormEquipment
'
import
{
ProfileEcogesture
}
from
'
models/profileEcogesture.model
'
interface
ProfileTypeViewProps
{
handleEnd
:
Function
}
const
ProfileTypeView
:
React
.
FC
<
ProfileTypeViewProps
>
=
({
handleEnd
,
}:
ProfileTypeViewProps
)
=>
{
const
ProfileTypeView
:
React
.
FC
=
()
=>
{
const
profile
=
useSelector
((
state
:
AppStore
)
=>
state
.
ecolyo
.
profile
)
const
curProfileType
=
useSelector
(
(
state
:
AppStore
)
=>
state
.
ecolyo
.
profileType
...
...
@@ -107,9 +101,6 @@ const ProfileTypeView: React.FC<ProfileTypeViewProps> = ({
step
,
!
profile
.
isProfileTypeCompleted
)
if
(
nextStep
===
ProfileTypeStepForm
.
END
&&
handleEnd
)
{
handleEnd
()
}
setIsLoading
(
true
)
if
(
nextStep
>
viewedStep
)
{
setViewedStep
(
nextStep
)
...
...
@@ -118,7 +109,6 @@ const ProfileTypeView: React.FC<ProfileTypeViewProps> = ({
},
[
curProfileEcogesture
,
handleEnd
,
profile
.
isProfileTypeCompleted
,
profileType
,
step
,
...
...
src/styles/index.css
View file @
5f2d0535
...
...
@@ -6,6 +6,7 @@
/** BLACK **/
/** RED **/
/** YELLOW **/
/** ORANGE **/
/** BLUE **/
/** GREEN **/
/** WHITE **/
...
...
@@ -172,6 +173,7 @@ body {
/** BLACK **/
/** RED **/
/** YELLOW **/
/** ORANGE **/
/** BLUE **/
/** GREEN **/
/** WHITE **/
...
...
@@ -182,6 +184,7 @@ body {
/** BLACK **/
/** RED **/
/** YELLOW **/
/** ORANGE **/
/** BLUE **/
/** GREEN **/
/** WHITE **/
...
...
@@ -651,6 +654,7 @@ p {
/** BLACK **/
/** RED **/
/** YELLOW **/
/** ORANGE **/
/** BLUE **/
/** GREEN **/
/** WHITE **/
...
...
@@ -941,6 +945,7 @@ p {
/** BLACK **/
/** RED **/
/** YELLOW **/
/** ORANGE **/
/** BLUE **/
/** GREEN **/
/** WHITE **/
...
...
@@ -1160,6 +1165,7 @@ button.btn-profile-back {
/** BLACK **/
/** RED **/
/** YELLOW **/
/** ORANGE **/
/** BLUE **/
/** GREEN **/
/** WHITE **/
...
...
@@ -1185,6 +1191,7 @@ button.btn-profile-back {
/** BLACK **/
/** RED **/
/** YELLOW **/
/** ORANGE **/
/** BLUE **/
/** GREEN **/
/** WHITE **/
...
...
@@ -1260,6 +1267,7 @@ div.modal-paper-full-screen {
/** BLACK **/
/** RED **/
/** YELLOW **/
/** ORANGE **/
/** BLUE **/
/** GREEN **/
/** WHITE **/
...
...
@@ -1324,6 +1332,7 @@ div.expansion-panel-details {
/** BLACK **/
/** RED **/
/** YELLOW **/
/** ORANGE **/
/** BLUE **/
/** GREEN **/
/** WHITE **/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment