Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3634 | Rev 3638 | 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) => {
3635 stevensc 9
    console.log(data);
3634 stevensc 10
    if (!data.message && !data.file) return;
11
    const message = {
12
      message: data.message,
13
      file: data.file ? data.file[0] : null
14
    };
15
    onSubmit(message);
16
  };
17
 
3622 stevensc 18
  return (
3628 stevensc 19
    <Form
3634 stevensc 20
      defaultValues={{ message: '', file: null }}
3628 stevensc 21
      reset
3634 stevensc 22
      onSubmit={handleSubmit}
3628 stevensc 23
      style={{ display: 'flex', alignItems: 'center', gap: 1, width: '100%' }}
24
    >
3622 stevensc 25
      <IconButton component='label' role={undefined} variant='contained' tabIndex={-1}>
26
        <AttachFile />
27
        <FormHiddenInput name='file' type='file' />
28
      </IconButton>
29
      <FormInput
30
        name='message'
31
        placeholder='Escribe un mensaje'
32
        autoComplete='off'
33
        endAdornment={
34
          <IconButton type='submit' sx={{ padding: 0.4 }}>
35
            <SendRounded />
36
          </IconButton>
37
        }
38
      />
39
    </Form>
40
  );
41
};