Proyectos de Subversion LeadersLinked - SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3736 stevensc 1
import { useFetch, useApi, useAlert } from '@shared/hooks';
2
import { updateLocationSettings } from '@account-settings/services';
3
 
4
export function useLocationSettings() {
5
  const { showSuccess, showError } = useAlert();
6
  const {
7
    data: locationData,
8
    loading: isLoading,
9
    refetch
10
  } = useFetch('/account-settings/location');
11
 
12
  const { loading: isUpdating, execute: executeUpdate } = useApi(updateLocationSettings, {
13
    onSuccess: (response) => {
14
      if (response.success) {
15
        showSuccess(response.data);
16
        refetch();
17
      } else {
18
        showError(response.data || 'Error al actualizar la ubicación');
19
      }
20
    },
21
    onError: (error) => {
22
      showError(error.message || 'Error al actualizar la ubicación');
23
    }
24
  });
25
 
26
  const updateLocation = async (data) => {
27
    await executeUpdate(data);
28
  };
29
 
30
  return {
31
    locationData,
32
    isLoading,
33
    isUpdating,
34
    updateLocation
35
  };
36
}