Gerador NIF na APP
This commit is contained in:
33
geradoresfe/src/Api/GeradorApi.tsx
Normal file
33
geradoresfe/src/Api/GeradorApi.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
|
||||
const API_URL = 'http://localhost:32769/';
|
||||
|
||||
class GeradorService {
|
||||
static async GenerateNIF(type: string | null): Promise<any[]> {
|
||||
try {
|
||||
const response: AxiosResponse = await axios.get(API_URL + 'Generate/GenerateNIF',
|
||||
{
|
||||
params: {
|
||||
type: type
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching NIF:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
static async GenerateNISS(): Promise<any[]> {
|
||||
try {
|
||||
|
||||
const response: AxiosResponse = await axios.get(API_URL + 'Generate/GenerateNISS');
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching NIF:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default GeradorService;
|
||||
@@ -19,6 +19,7 @@ import Features from './components/Features';
|
||||
import Testimonials from './components/Testimonials';
|
||||
import FAQ from './components/FAQ';
|
||||
import Footer from './components/Footer';
|
||||
import GeradorCC from './components/GeradorNIF';
|
||||
|
||||
|
||||
|
||||
@@ -86,8 +87,7 @@ function App() {
|
||||
</Helmet>
|
||||
<ThemeProvider theme={showCustomTheme ? LPtheme : defaultTheme}>
|
||||
<CssBaseline />
|
||||
<AppAppBar mode={mode} toggleColorMode={toggleColorMode} />
|
||||
<Hero />
|
||||
<GeradorCC />
|
||||
<Box sx={{ bgcolor: 'background.default' }}>
|
||||
|
||||
</Box>
|
||||
|
||||
75
geradoresfe/src/components/GeradorNIF.tsx
Normal file
75
geradoresfe/src/components/GeradorNIF.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
import * as React from 'react';
|
||||
import Box from '@mui/material/Box';
|
||||
import Button from '@mui/material/Button';
|
||||
import Container from '@mui/material/Container';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import Typography from '@mui/material/Typography';
|
||||
|
||||
import Card from '@mui/material/Card';
|
||||
import CardContent from '@mui/material/CardContent';
|
||||
import CardActions from '@mui/material/CardActions/CardActions';
|
||||
import GeradorService from '../Api/GeradorApi';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
|
||||
|
||||
export default function GeradorNIF() {
|
||||
const [nif, setNIF] = useState<any[]>([]);
|
||||
|
||||
const fetchNif = async () => {
|
||||
const nif = await GeradorService.GenerateNIF(null);
|
||||
setNIF(nif);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetchNif();
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Box
|
||||
id="GeradorNIF"
|
||||
sx={(theme) => ({
|
||||
width: '100%',
|
||||
backgroundImage:
|
||||
theme.palette.mode === 'light'
|
||||
? 'radial-gradient(ellipse 80% 50% at 50% -20%, hsl(210, 100%, 90%), transparent)'
|
||||
: 'radial-gradient(ellipse 80% 50% at 50% -20%, hsl(210, 100%, 16%), transparent)',
|
||||
backgroundRepeat: 'no-repeat',
|
||||
})}
|
||||
>
|
||||
<Container
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
pt: { xs: 14, sm: 20 },
|
||||
pb: { xs: 8, sm: 12 },
|
||||
}}
|
||||
>
|
||||
<Stack
|
||||
spacing={2}
|
||||
alignItems="center"
|
||||
useFlexGap
|
||||
sx={{ width: { xs: '100%', sm: '70%' } }}
|
||||
>
|
||||
<Card sx={{ minWidth: 275 }}>
|
||||
<CardContent>
|
||||
<Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom>
|
||||
NIFC
|
||||
</Typography>
|
||||
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
||||
{nif}
|
||||
</Typography>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
<Button size="small" onClick={fetchNif}>Gerar</Button>
|
||||
</CardActions>
|
||||
</Card>
|
||||
);
|
||||
</Stack>
|
||||
</Container>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user