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

@@ -1,25 +1 @@
**/.classpath node_modules
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

46
GeradoresService/CC.cs Normal file
View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeradoresService
{
internal class CC
{
/*static bool Validate(string CardNumber)
{
int sum = 0;
bool alternate = false;
// Percorre os dígitos do número de trás para frente
for (int i = creditCardNumber.Length - 1; i >= 0; i--)
{
int digit = creditCardNumber[i] - '0';
// Se é um dígito
if (digit >= 0 && digit <= 9)
{
if (alternate)
{
digit *= 2;
if (digit > 9)
digit -= 9;
}
sum += digit;
alternate = !alternate;
}
else
{
// Se não é um dígito, o número é inválido
return false;
}
}
// O número de cartão de crédito é válido se a soma for divisível por 10
return sum % 10 == 0;
}*/
}
}

View File

@@ -20,6 +20,13 @@ app.UseHttpsRedirection();
app.UseAuthorization(); app.UseAuthorization();
app.UseCors(options =>
{
options.AllowAnyOrigin();
options.AllowAnyMethod();
options.AllowAnyHeader();
});
app.MapControllers(); app.MapControllers();
app.Run(); app.Run();

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> <PropertyGroup>
<StartupCommand>set BROWSER=none&amp;&amp;npm start</StartupCommand> <StartupCommand>set BROWSER=none&amp;&amp;npm start</StartupCommand>
<JavaScriptTestRoot>src\</JavaScriptTestRoot> <JavaScriptTestRoot>src\</JavaScriptTestRoot>
<JavaScriptTestFramework>Jest</JavaScriptTestFramework> <JavaScriptTestFramework>Jest</JavaScriptTestFramework>
<!-- Command to run on project build --> <!-- Command to run on project build -->
<BuildCommand></BuildCommand> <BuildCommand>
</BuildCommand>
<!-- Command to create an optimized build of the project that's ready for publishing --> <!-- Command to create an optimized build of the project that's ready for publishing -->
<ProductionBuildCommand>npm run build</ProductionBuildCommand> <ProductionBuildCommand>npm run build</ProductionBuildCommand>
<!-- Folder where production build objects will be placed --> <!-- Folder where production build objects will be placed -->
<BuildOutputFolder>$(MSBuildProjectDirectory)\build</BuildOutputFolder> <BuildOutputFolder>$(MSBuildProjectDirectory)\build</BuildOutputFolder>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="..\.dockerignore">
<DependentUpon>$(DockerDefaultDockerfile)</DependentUpon>
<Link>.dockerignore</Link>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="src\Api\" />
</ItemGroup>
</Project> </Project>

View File

@@ -14,6 +14,7 @@
"@types/node": "^16.18.95", "@types/node": "^16.18.95",
"@types/react": "^18.2.74", "@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24", "@types/react-dom": "^18.2.24",
"axios": "^1.6.8",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-helmet": "^6.1.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 Testimonials from './components/Testimonials';
import FAQ from './components/FAQ'; import FAQ from './components/FAQ';
import Footer from './components/Footer'; import Footer from './components/Footer';
import GeradorCC from './components/GeradorNIF';
@@ -86,8 +87,7 @@ function App() {
</Helmet> </Helmet>
<ThemeProvider theme={showCustomTheme ? LPtheme : defaultTheme}> <ThemeProvider theme={showCustomTheme ? LPtheme : defaultTheme}>
<CssBaseline /> <CssBaseline />
<AppAppBar mode={mode} toggleColorMode={toggleColorMode} /> <GeradorCC />
<Hero />
<Box sx={{ bgcolor: 'background.default' }}> <Box sx={{ bgcolor: 'background.default' }}>
</Box> </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>
);
}