Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3374 | Rev 3432 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3374 Rev 3416
Línea 1... Línea 1...
1
import React from 'react'
1
import React from "react";
2
import { useParams } from 'react-router-dom'
2
import { useParams } from "react-router-dom";
3
import { useDispatch } from 'react-redux'
3
import { useDispatch } from "react-redux";
4
 
4
 
5
import { useFetch, useHabitProgress } from '@hooks'
5
import { useFetch, useHabitProgress } from "@hooks";
6
import { updateProgress } from '@services/habits/habits'
6
import { updateProgress } from "@services/habits/habits";
7
import { addNotification } from '@store/notification/notification.actions'
7
import { addNotification } from "@store/notification/notification.actions";
8
 
8
 
9
import PageHeader from '@components/common/page-header'
9
import PageHeader from "@components/common/page-header";
10
import LoadingWrapper from '@components/common/loading-wrapper'
10
import LoadingWrapper from "@components/common/loading-wrapper";
11
import ProgressForm from '@components/habits/progress/progress-form'
11
import ProgressForm from "@components/habits/progress/progress-form";
Línea 12... Línea 12...
12
 
12
 
13
export default function EditHabitProgress() {
13
export default function EditHabitProgress() {
14
  const { id } = useParams()
14
  const { id } = useParams();
Línea 15... Línea 15...
15
  const dispatch = useDispatch()
15
  const dispatch = useDispatch();
16
 
16
 
Línea 17... Línea 17...
17
  const { getItemById, loading, editItem } = useHabitProgress()
17
  const { getItemById, loading, editItem } = useHabitProgress();
18
  const currentRegister = getItemById(id)
18
  const currentRegister = getItemById(id);
19
 
19
 
Línea 20... Línea 20...
20
  const { data: registerValues, isLoading } = useFetch(
20
  const { data: registerValues, loading: loadingValues } = useFetch(
21
    currentRegister?.actions.link_edit
21
    currentRegister?.actions.link_edit
22
  )
22
  );
23
 
23
 
24
  const onSubmit = async (progress) => {
24
  const onSubmit = async (progress) => {
25
    try {
25
    try {
26
      const response = await updateProgress(
26
      const response = await updateProgress(
27
        currentRegister?.actions.link_edit,
27
        currentRegister?.actions.link_edit,
28
        progress
28
        progress
29
      )
29
      );
30
      editItem(response.data)
30
      editItem(response.data);
31
      dispatch(addNotification({ style: 'success', msg: response.message }))
31
      dispatch(addNotification({ style: "success", msg: response.message }));
Línea 32... Línea 32...
32
    } catch (error) {
32
    } catch (error) {
33
      dispatch(addNotification({ style: 'danger', msg: error.message }))
33
      dispatch(addNotification({ style: "danger", msg: error.message }));
34
    }
34
    }
35
  }
35
  };
36
 
36
 
37
  return (
37
  return (
38
    <>
38
    <>
39
      <PageHeader title='Editar progreso' goBack />
39
      <PageHeader title="Editar progreso" goBack />
40
      <LoadingWrapper loading={loading || isLoading}>
40
      <LoadingWrapper loading={loading || loadingValues}>