Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3684 Rev 3688
Línea 1... Línea 1...
1
import React from 'react';
1
import React from 'react';
Línea 2... Línea 2...
2
 
2
 
3
import { useAlert, useApi } from '@shared/hooks';
3
import { useApi } from '@shared/hooks';
4
import { parseHelperToSelect } from '@shared/utils';
4
import { parseHelperToSelect } from '@shared/utils';
Línea 5... Línea 5...
5
import { getGroupTypes, getIndustries, saveGroup } from '@groups/services';
5
import { getGroupTypes, getIndustries } from '@groups/services';
Línea 6... Línea 6...
6
 
6
 
7
import { Form, FormButton, FormInput, FormSelect, Spinner } from '@shared/components';
7
import { Form, FormButton, FormInput, FormSelect, Spinner } from '@shared/components';
Línea 12... Línea 12...
12
  });
12
  });
13
  const { data: industries, loading: loadingIndustries } = useApi(getIndustries, {
13
  const { data: industries, loading: loadingIndustries } = useApi(getIndustries, {
14
    autoFetch: true
14
    autoFetch: true
15
  });
15
  });
Línea 16... Línea -...
16
 
-
 
17
  const { showError, showSuccess } = useAlert();
-
 
18
 
-
 
19
  const { execute } = useApi(saveGroup, {
-
 
20
    onSuccess: (message) => {
-
 
21
      showSuccess(message);
-
 
22
      onSubmit();
-
 
23
    },
-
 
24
    onError: (error) => {
-
 
25
      showError(error.message);
-
 
26
    }
-
 
27
  });
-
 
28
 
16
 
Línea 29... Línea 17...
29
  if (loadingGroupTypes || loadingIndustries || !groupTypes || !industries) return <Spinner />;
17
  if (loadingGroupTypes || loadingIndustries || !groupTypes || !industries) return <Spinner />;
30
 
18
 
31
  return (
19
  return (
32
    <Form onSubmit={execute} defaultValues={{ name: '', type_id: '', industry_id: '' }} reset>
20
    <Form onSubmit={onSubmit} defaultValues={{ name: '', type_id: '', industry_id: '' }} reset>
33
      <FormInput
21
      <FormInput
34
        name='name'
22
        name='name'
35
        label='Nombre'
23
        label='Nombre'