You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 rivejä
1.3 KiB

  1. import { Grid, Button, TextField } from '@mui/material';
  2. import { useState } from 'react';
  3. import axios from 'axios';
  4. const TestMailPage = () => {
  5. const [host, setHost] = useState(apiPath+'/test');
  6. const [mail, setMail] = useState('');
  7. const hostChange = (event) => {
  8. setHost(event.target.value);
  9. };
  10. const mailChange = (event) => {
  11. setMail(event.target.value);
  12. };
  13. const doMailTest = () => {
  14. axios.post(host, {
  15. email: mail
  16. })
  17. .then((response) => {
  18. console.log(response.data);
  19. // Handle data
  20. })
  21. .catch((error) => {
  22. console.log(error);
  23. })
  24. };
  25. return (
  26. <Grid
  27. container
  28. alignItems='center'
  29. sx={{
  30. maxWidth: { xs: 1, lg: 1000 },
  31. margin: { xs: 2.5, md: 3 },
  32. '& > *': {
  33. flexGrow: 1,
  34. flexBasis: '100%'
  35. }
  36. }}
  37. spacing={3}>
  38. <Grid item xs={12}><TextField id='hostField' label='Outlined' variant='filled' onChange={hostChange} value={host} fullWidth /></Grid>
  39. <Grid item xs={12}><TextField id='mailField' label='Outlined' variant='filled' onChange={mailChange} value={mail} fullWidth /></Grid>
  40. <Grid item xs={12}><Button variant='contained' onClick={doMailTest}>Test</Button></Grid>
  41. </Grid>
  42. );
  43. };
  44. export default TestMailPage;