| 3736 |
stevensc |
1 |
import React from 'react';
|
|
|
2 |
|
|
|
3 |
import { useAlert, useApi } from '@shared/hooks';
|
|
|
4 |
import { saveGroupImage } from '@groups/services';
|
|
|
5 |
|
|
|
6 |
import { Form, FormButton, FormFilePicker } from '@shared/components';
|
|
|
7 |
|
|
|
8 |
export const GroupImageForm = ({ sizes, uuid, onSubmit }) => {
|
|
|
9 |
const { showSuccess, showError } = useAlert();
|
|
|
10 |
|
|
|
11 |
const { execute } = useApi(saveGroupImage, {
|
|
|
12 |
onSuccess: (data) => {
|
|
|
13 |
onSubmit(data);
|
|
|
14 |
showSuccess('Imagen subida correctamente');
|
|
|
15 |
},
|
|
|
16 |
onError: (error) => {
|
|
|
17 |
showError(error.message);
|
|
|
18 |
}
|
|
|
19 |
});
|
|
|
20 |
|
|
|
21 |
const handleSubmit = (data) => {
|
|
|
22 |
execute(uuid, data);
|
|
|
23 |
};
|
|
|
24 |
|
|
|
25 |
return (
|
|
|
26 |
<Form onSubmit={handleSubmit}>
|
|
|
27 |
<FormFilePicker
|
|
|
28 |
name='image'
|
|
|
29 |
type='image'
|
|
|
30 |
description={`Arrastra la imagen aqui, o haga click para seleccionar. Tamaño recomendado: ${sizes}`}
|
|
|
31 |
/>
|
|
|
32 |
<FormButton type='submit'>Guardar</FormButton>
|
|
|
33 |
</Form>
|
|
|
34 |
);
|
|
|
35 |
};
|