Newer
Older
import { Button } from '@material-ui/core'
import defaultIcon from 'assets/icons/visu/ecogesture/default.svg'
import ActionModal from 'components/Action/ActionModal/ActionModal'
import StyledIcon from 'components/CommonKit/Icon/StyledIcon'
import StarsContainer from 'components/CommonKit/StarsContainer/StarsContainer'
import { Client, useClient } from 'cozy-client'
import { Ecogesture, UserChallenge } from 'models'
import React, { useCallback, useEffect, useState } from 'react'
import { useAppSelector } from 'store/hooks'
import { importIconById } from 'utils/utils'
import './actionBegin.scss'
action?: Ecogesture
setShowList: React.Dispatch<React.SetStateAction<boolean>>
const {
global: { fluidTypes },
profile: { isProfileTypeCompleted },
const [currentAction, setCurrentAction] = useState<Ecogesture>()
const [actionIcon, setActionIcon] = useState<string>('')
const [openLaunchModal, setOpenLaunchModal] = useState<boolean>(false)
const toggleLaunchModal = useCallback(() => {
setOpenLaunchModal(prev => !prev)
}, [])
const getAction = async () => {
if (action) {
if (subscribed) setCurrentAction(action)
} else {
const actionService = new ActionService(client)
let actions: Ecogesture[] = []
if (isProfileTypeCompleted) {
actions = await actionService.getCustomActions(fluidTypes)
} else {
actions = await actionService.getDefaultActions()
}
}, [client, isProfileTypeCompleted, fluidTypes, action, currentAction])

Hugo SUBTIL
committed
async function handleEcogestureIcon() {
if (currentAction) {
const icon = await importIconById(currentAction.id, 'ecogesture')

Hugo SUBTIL
committed
}

Hugo SUBTIL
committed
handleEcogestureIcon()
<div className="action-container">
<div className="action-begin-container">
<div className="icon-container">
<StyledIcon
className="action-icon"
icon={actionIcon}
size={100}
/>
</div>
result={userChallenge.progress.actionProgress}
isQuizBegin={true}
/>
<div className="action-title text-20-bold">
</div>
<div className="action-duration text-18">
{t('action.duration', {
smartCount: currentAction.actionDuration,
})}
</div>
<div className="action-text text-18-bold">
</div>
<div className="action-buttons">
<Button
classes={{
root: 'btn-secondary-negative',
label: 'text-16-normal',
}}
>
{t('action.apply')}
</Button>
<Button
classes={{
root: 'btn-secondary-negative',
label: 'text-16-normal',
}}
>
{t('action.other')}
</Button>
</div>
</div>
<ActionModal
open={openLaunchModal}
action={currentAction}
handleCloseClick={toggleLaunchModal}
userChallenge={userChallenge}
/>