| 3313 |
stevensc |
1 |
import React from 'react'
|
|
|
2 |
import { useParams, useNavigate } from 'react-router-dom'
|
|
|
3 |
import { Button } from '@mui/material'
|
|
|
4 |
|
|
|
5 |
import { useFetch, useMyProgress } from '@hooks'
|
|
|
6 |
|
|
|
7 |
import List from '@components/common/list'
|
|
|
8 |
import PageHeader from '@components/common/page-header'
|
|
|
9 |
import LoadingWrapper from '@components/common/loading-wrapper'
|
|
|
10 |
|
|
|
11 |
export default function HabitProgressPage() {
|
|
|
12 |
const navigate = useNavigate()
|
|
|
13 |
const { id } = useParams()
|
|
|
14 |
const { getHabitById } = useMyProgress()
|
|
|
15 |
|
|
|
16 |
const currentHabit = getHabitById(id)
|
|
|
17 |
const { data, isLoading } = useFetch(currentHabit.link)
|
|
|
18 |
|
|
|
19 |
return (
|
|
|
20 |
<>
|
|
|
21 |
<PageHeader
|
|
|
22 |
title={currentHabit.name}
|
|
|
23 |
action={() => <Button onClick={() => navigate('add')}>Agregar</Button>}
|
|
|
24 |
/>
|
|
|
25 |
<LoadingWrapper loading={isLoading}>
|
|
|
26 |
<List
|
|
|
27 |
items={data.items}
|
|
|
28 |
renderItem={(progress) => JSON.stringify(progress)}
|
|
|
29 |
emptyMessage='No hay registros'
|
|
|
30 |
/>
|
|
|
31 |
</LoadingWrapper>
|
|
|
32 |
</>
|
|
|
33 |
)
|
|
|
34 |
}
|