Gerador NIF na APP

This commit is contained in:
SECUNDIS\masantos
2024-04-11 22:21:24 +01:00
parent be60a4df8e
commit ed33d7ec28
10 changed files with 191 additions and 29 deletions

View File

@@ -0,0 +1 @@
node_modules

13
geradoresfe/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM node:20-alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]

View File

@@ -1,13 +1,23 @@
<Project Sdk="Microsoft.VisualStudio.JavaScript.Sdk/0.5.83-alpha">
<Project Sdk="Microsoft.VisualStudio.JavaScript.Sdk/0.5.83-alpha">
<PropertyGroup>
<StartupCommand>set BROWSER=none&amp;&amp;npm start</StartupCommand>
<JavaScriptTestRoot>src\</JavaScriptTestRoot>
<JavaScriptTestFramework>Jest</JavaScriptTestFramework>
<!-- Command to run on project build -->
<BuildCommand></BuildCommand>
<BuildCommand>
</BuildCommand>
<!-- Command to create an optimized build of the project that's ready for publishing -->
<ProductionBuildCommand>npm run build</ProductionBuildCommand>
<!-- Folder where production build objects will be placed -->
<BuildOutputFolder>$(MSBuildProjectDirectory)\build</BuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<None Include="..\.dockerignore">
<DependentUpon>$(DockerDefaultDockerfile)</DependentUpon>
<Link>.dockerignore</Link>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="src\Api\" />
</ItemGroup>
</Project>

View File

@@ -14,6 +14,7 @@
"@types/node": "^16.18.95",
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24",
"axios": "^1.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",

View 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;

View File

@@ -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>

View 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>
);
}