diff --git a/high-green-power/src/App.tsx b/high-green-power/src/App.tsx index 007d26f..8d10d05 100644 --- a/high-green-power/src/App.tsx +++ b/high-green-power/src/App.tsx @@ -7,6 +7,7 @@ import { Box, Container, Grid, Typography, Button, Stepper, Step, StepLabel } fr import { useFormik } from 'formik'; import { useState } from "react"; import { matchIsValidTel } from 'mui-tel-input'; +import axios from "axios"; interface dados { @@ -115,9 +116,35 @@ function App() { ...schemaStep3.fields, }); - const onSubmit = (values: dados) => { - console.log('Dados: ', values); - } + const onSubmit = async (values: dados) => { + // Extract the specific data you want from the form values + const extractedData = { + name: values.empresa, + address: values.morada, + taxNumber: values.nif, + legal: values.representante, + line: values.andar, + zipcode: values.codigoPostal, + location: values.cidade, + country: values.pais, + contacts: [{ + name: values.nomePessoaContacto, + email: values.emailPessoaContacto, + phone: values.telemovelPC, + }] + }; + + try { + // Make a POST request using Axios + const response = await axios.post('https://dev-hgp-sgi.streamline.pt/api/entities', extractedData); + + console.log('Data submitted successfully', response.data); + + } catch (error) { + // Handle errors + console.error('Error submitting data:', error); + } + }; const formik = useFormik ({ validateOnMount: true,