Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3638 Rev 3639
Línea 1... Línea 1...
1
import React from 'react';
1
import React, { useState } from 'react';
2
import { IconButton } from '@mui/material';
2
import { IconButton } from '@mui/material';
3
import { AttachFile, SendRounded } from '@mui/icons-material';
3
import { AttachFile, SendRounded } from '@mui/icons-material';
Línea 4... Línea 4...
4
 
4
 
5
import { FileModal, Form, FormInput } from '@shared/components';
5
import { FileModal, Form, FormInput } from '@shared/components';
Línea 6... Línea 6...
6
import { useModal } from '@shared/hooks';
6
import { useModal } from '@shared/hooks';
-
 
7
 
7
 
8
export const ChatForm = ({ onSubmit }) => {
Línea -... Línea 9...
-
 
9
  const [files, setFiles] = useState([]);
-
 
10
  const { showModal, closeModal } = useModal();
-
 
11
 
-
 
12
  const handleSubmit = (data) => {
-
 
13
    console.log(data);
-
 
14
    console.log(files);
8
export const ChatForm = ({ onSubmit }) => {
15
    onSubmit({ ...data, file: files[0] });
9
  const { showModal, closeModal } = useModal();
16
  };
10
 
17
 
11
  const attachFile = () => {
18
  const attachFile = () => {
12
    showModal(
19
    showModal(
13
      'Elegir archivo',
20
      'Elegir archivo',
14
      <FileModal
21
      <FileModal
15
        onSubmit={(data) => {
22
        onSubmit={(data) => {
16
          onSubmit(data);
23
          setFiles(data);
17
          closeModal();
24
          closeModal();
18
        }}
25
        }}
19
      />
26
      />
20
    );
27
    );
21
  };
28
  };
22
  return (
29
  return (
23
    <Form
30
    <Form
24
      defaultValues={{ message: '' }}
31
      defaultValues={{ message: '' }}
25
      reset
32
      reset
26
      onSubmit={onSubmit}
33
      onSubmit={handleSubmit}
27
      style={{ display: 'flex', alignItems: 'center', gap: 1, width: '100%' }}
34
      style={{ display: 'flex', alignItems: 'center', gap: 1, width: '100%' }}
28
    >
35
    >
29
      <IconButton onClick={attachFile}>
36
      <IconButton onClick={attachFile}>
30
        <AttachFile />
37
        <AttachFile />
31
      </IconButton>
38
      </IconButton>
32
      <FormInput
39
      <FormInput
-
 
40
        name='message'
33
        name='message'
41
        placeholder='Escribe un mensaje'
34
        placeholder='Escribe un mensaje'
42
        autoComplete='off'
35
        autoComplete='off'
43
        rules={{ required: true }}
36
        endAdornment={
44
        endAdornment={
37
          <IconButton type='submit' sx={{ padding: 0.4 }}>
45
          <IconButton type='submit' sx={{ padding: 0.4 }}>