Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3628 | Rev 3635 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3622 stevensc 1
import React from 'react';
2
import { IconButton } from '@mui/material';
3
import { AttachFile, SendRounded } from '@mui/icons-material';
4
 
5
import { Form, FormHiddenInput, FormInput } from '@shared/components';
6
 
7
export const ChatForm = ({ onSubmit }) => {
3634 stevensc 8
  const handleSubmit = (data) => {
9
    if (!data.message && !data.file) return;
10
    const message = {
11
      message: data.message,
12
      file: data.file ? data.file[0] : null
13
    };
14
    onSubmit(message);
15
  };
16
 
3622 stevensc 17
  return (
3628 stevensc 18
    <Form
3634 stevensc 19
      defaultValues={{ message: '', file: null }}
3628 stevensc 20
      reset
3634 stevensc 21
      onSubmit={handleSubmit}
3628 stevensc 22
      style={{ display: 'flex', alignItems: 'center', gap: 1, width: '100%' }}
23
    >
3622 stevensc 24
      <IconButton component='label' role={undefined} variant='contained' tabIndex={-1}>
25
        <AttachFile />
26
        <FormHiddenInput name='file' type='file' />
27
      </IconButton>
28
      <FormInput
29
        name='message'
30
        placeholder='Escribe un mensaje'
31
        autoComplete='off'
32
        endAdornment={
33
          <IconButton type='submit' sx={{ padding: 0.4 }}>
34
            <SendRounded />
35
          </IconButton>
36
        }
37
      />
38
    </Form>
39
  );
40
};