Skip to content
Snippets Groups Projects
Commit 5bd0f1cf authored by Guilhem CARRON's avatar Guilhem CARRON
Browse files

Add action events + fix css alignement

parent c9394c84
No related branches found
No related tags found
1 merge request!348Features/create aggregation usage service
...@@ -7,6 +7,11 @@ import './actionList.scss' ...@@ -7,6 +7,11 @@ import './actionList.scss'
import { Button } from '@material-ui/core' import { Button } from '@material-ui/core'
import EcogestureModal from 'components/Ecogesture/EcogestureModal' import EcogestureModal from 'components/Ecogesture/EcogestureModal'
import defaultIcon from 'assets/icons/visu/ecogesture/default.svg' import defaultIcon from 'assets/icons/visu/ecogesture/default.svg'
import UsageEventService from 'services/usageEvent.service'
import { useClient } from 'cozy-client'
import { UsageEventType } from 'enum/usageEvent.enum'
import { useSelector } from 'react-redux'
import { AppStore } from 'store'
interface ActionCardProps { interface ActionCardProps {
action: Ecogesture action: Ecogesture
...@@ -21,7 +26,10 @@ const ActionCard: React.FC<ActionCardProps> = ({ ...@@ -21,7 +26,10 @@ const ActionCard: React.FC<ActionCardProps> = ({
}: ActionCardProps) => { }: ActionCardProps) => {
const [actionIcon, setActionIcon] = useState<string>('') const [actionIcon, setActionIcon] = useState<string>('')
const [openEcogestureModal, setOpenEcogestureModal] = useState<boolean>(false) const [openEcogestureModal, setOpenEcogestureModal] = useState<boolean>(false)
const client = useClient()
const { currentChallenge } = useSelector(
(state: AppStore) => state.ecolyo.challenge
)
const toggleModal = useCallback(() => { const toggleModal = useCallback(() => {
setOpenEcogestureModal(prev => !prev) setOpenEcogestureModal(prev => !prev)
}, []) }, [])
...@@ -29,8 +37,20 @@ const ActionCard: React.FC<ActionCardProps> = ({ ...@@ -29,8 +37,20 @@ const ActionCard: React.FC<ActionCardProps> = ({
const selectEcogesture = useCallback(() => { const selectEcogesture = useCallback(() => {
setSelectedAction(action) setSelectedAction(action)
setShowList(false) setShowList(false)
UsageEventService.addEvent(client, {
type: UsageEventType.ACTION_CHANGE_EVENT,
target: action.id,
context: currentChallenge ? currentChallenge.id : '',
})
toggleModal() toggleModal()
}, [setSelectedAction, setShowList, action, toggleModal]) }, [
setSelectedAction,
setShowList,
action,
toggleModal,
currentChallenge,
client,
])
useEffect(() => { useEffect(() => {
importIconbyId(action.id, 'ecogesture').then(icon => { importIconbyId(action.id, 'ecogesture').then(icon => {
......
...@@ -12,6 +12,8 @@ import StyledIcon from 'components/CommonKit/Icon/StyledIcon' ...@@ -12,6 +12,8 @@ import StyledIcon from 'components/CommonKit/Icon/StyledIcon'
import starFilled from 'assets/icons/visu/challenge/starFilled.svg' import starFilled from 'assets/icons/visu/challenge/starFilled.svg'
import './actionDone.scss' import './actionDone.scss'
import { toggleChallengeActionNotification } from 'store/global/global.actions' import { toggleChallengeActionNotification } from 'store/global/global.actions'
import { UsageEventType } from 'enum/usageEvent.enum'
import UsageEventService from 'services/usageEvent.service'
interface ActionDoneProps { interface ActionDoneProps {
currentChallenge: UserChallenge currentChallenge: UserChallenge
} }
...@@ -29,6 +31,13 @@ const ActionDone: React.FC<ActionDoneProps> = ({ ...@@ -29,6 +31,13 @@ const ActionDone: React.FC<ActionDoneProps> = ({
currentChallenge, currentChallenge,
UserChallengeUpdateFlag.ACTION_DONE UserChallengeUpdateFlag.ACTION_DONE
) )
await UsageEventService.addEvent(client, {
type: UsageEventType.ACTION_END_EVENT,
target: currentChallenge.action.ecogesture
? currentChallenge.action.ecogesture.id
: '',
context: currentChallenge.id,
})
dispatch(toggleChallengeActionNotification(false)) dispatch(toggleChallengeActionNotification(false))
dispatch(updateUserChallengeList(updatedChallenge)) dispatch(updateUserChallengeList(updatedChallenge))
history.goBack() history.goBack()
......
...@@ -12,6 +12,8 @@ import Button from '@material-ui/core/Button' ...@@ -12,6 +12,8 @@ import Button from '@material-ui/core/Button'
import Dialog from '@material-ui/core/Dialog' import Dialog from '@material-ui/core/Dialog'
import { updateUserChallengeList } from 'store/challenge/challenge.actions' import { updateUserChallengeList } from 'store/challenge/challenge.actions'
import chronoMini from 'assets/icons/visu/action/chrono-mini.svg' import chronoMini from 'assets/icons/visu/action/chrono-mini.svg'
import { UsageEventType } from 'enum/usageEvent.enum'
import UsageEventService from 'services/usageEvent.service'
interface ActionModalProps { interface ActionModalProps {
open: boolean open: boolean
...@@ -38,6 +40,11 @@ const ActionModal: React.FC<ActionModalProps> = ({ ...@@ -38,6 +40,11 @@ const ActionModal: React.FC<ActionModalProps> = ({
undefined, undefined,
action action
) )
await UsageEventService.addEvent(client, {
type: UsageEventType.ACTION_LAUNCH_EVENT,
target: action.id,
context: userChallenge.id,
})
dispatch(updateUserChallengeList(updatedChallenge)) dispatch(updateUserChallengeList(updatedChallenge))
}, [action, client, dispatch, userChallenge]) }, [action, client, dispatch, userChallenge])
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
flex-direction: column; flex-direction: column;
align-self: center; align-self: center;
justify-content: space-between; justify-content: space-between;
align-items: flex-start;
span { span {
margin-bottom: 0.3em; margin-bottom: 0.3em;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment