From 55326cc367b6587046bd6977a8c13f9c5fdd0873 Mon Sep 17 00:00:00 2001 From: Algusto-RC Date: Wed, 13 Dec 2023 22:02:15 -0300 Subject: [PATCH] =?UTF-8?q?Adicionando=20toast=20na=20importa=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20estudantes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/SendStudents/index.js | 129 +++++++++++++---------- 1 file changed, 72 insertions(+), 57 deletions(-) diff --git a/frontend/src/pages/SendStudents/index.js b/frontend/src/pages/SendStudents/index.js index c9ec2f07..820cc49f 100644 --- a/frontend/src/pages/SendStudents/index.js +++ b/frontend/src/pages/SendStudents/index.js @@ -1,31 +1,46 @@ import React, { useState } from 'react'; import axios from 'axios'; -import { Container, Flex, Box, Text, Button, Input, Center } from "@chakra-ui/react"; +import { Container, Flex, Box, Text, Button, Input, Center, useToast, ChakraProvider } from "@chakra-ui/react"; import Header from "../../components/Header/index.js"; import Footer from "../../components/Footer/index.js"; -import { ChakraProvider } from "@chakra-ui/react"; import { Link } from "react-router-dom"; const SendStudent = () => { - - const [selectedFile, setSelectedFile] = useState(null); + const [selectedFile, setSelectedFile] = useState(null); + const toast = useToast(); - const handleFileChange = (event) => { - setSelectedFile(event.target.files[0]); - } + const handleFileChange = (event) => { + setSelectedFile(event.target.files[0]); + } - const handleUpload = () => { - const formData = new FormData(); - formData.append('arquivo', selectedFile); + const handleUpload = () => { + const formData = new FormData(); + formData.append('arquivo', selectedFile); - axios.post('https://backend-matriculai.vercel.app/send-file/extract-students', formData) - .then(response => { - console.log('Resposta do servidor:', response.data); - }) - .catch(error => { - console.error('Erro ao enviar arquivo:', error); - }) - } + axios.post('http://localhost:3001/send-file/extract-students', formData) + .then(response => { + console.log('Resposta do servidor:', response.data); + // Exibir Toast de confirmação + toast({ + title: "Arquivo enviado com sucesso!", + status: "success", + duration: 3000, + isClosable: true, + position: "top", // Definindo a posição para a parte superior + }); + }) + .catch(error => { + console.error('Erro ao enviar arquivo:', error); + // Exibir Toast de erro, se necessário + toast({ + title: "Erro ao enviar arquivo", + status: "error", + duration: 3000, + isClosable: true, + position: "top", // Definindo a posição para a parte superior + }); + }) + } return ( @@ -33,49 +48,49 @@ const SendStudent = () => {
- - - Importar dados - - - - - +