Gerador NIF na APP
This commit is contained in:
@@ -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
46
GeradoresService/CC.cs
Normal 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;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
|||||||
1
geradoresfe/.dockerignore
Normal file
1
geradoresfe/.dockerignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
13
geradoresfe/Dockerfile
Normal file
13
geradoresfe/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
FROM node:20-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json .
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["npm", "start"]
|
||||||
@@ -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&&npm start</StartupCommand>
|
<StartupCommand>set BROWSER=none&&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>
|
||||||
@@ -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",
|
||||||
|
|||||||
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 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>
|
||||||
|
|||||||
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