Skip to content

Commit

Permalink
Finish Implementatinos Refresh Token Authtenticaton
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfariakof committed Apr 21, 2024
1 parent 49c2554 commit 4e66578
Show file tree
Hide file tree
Showing 48 changed files with 298 additions and 242 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions Dockerfile-Development → Dockerfile.Development
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ RUN npm install && mv node_modules ../
COPY . ./
RUN npm run build

# Production Server NGINX
# Development Server NGINX
FROM nginx:stable-alpine

COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.dev.conf /etc/nginx/conf.d/default.conf

# Generate an Install open certifcates ssl
RUN apk add --no-cache openssl
COPY ./certificate/openssl.cnf /etc/nginx/certificate/openssl.cnf
RUN openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout /etc/nginx/certificate/ssl_certificate_key.pem -out /etc/nginx/certificate/ssl_certificate.pem -config /etc/nginx/certificate/openssl.cnf
Expand Down
23 changes: 23 additions & 0 deletions Dockerfile.Local
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:lts-alpine as build
ENV NODE_ENV=development
WORKDIR /app

COPY ["package.json", "package-lock.json*", "./"]
RUN npm install -P react react-dom @types/react-dom
RUN npm install react-scripts
RUN npm install
COPY . ./
RUN npm run build

# Local Development Server NGINX
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Generate an Install open certifcates ssl
#RUN apk add --no-cache openssl
#COPY ./certificate/openssl.cnf /etc/nginx/certificate/openssl.cnf
#RUN openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout /etc/nginx/certificate/ssl_certificate_key.pem -out /etc/nginx/certificate/ssl_certificate.pem -config /etc/nginx/certificate/openssl.cnf

EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]
6 changes: 4 additions & 2 deletions Dockerfile-Production → Dockerfile.Production
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ RUN npm install && mv node_modules ../
COPY . ./
RUN npm run build

EXPOSE 3000
# production env

# Production Server NGINX
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
Expand All @@ -19,4 +19,6 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf
#RUN apk add --no-cache openssl
#COPY ./certificate/openssl.cnf /etc/nginx/certificate/openssl.cnf
#RUN openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout /etc/nginx/certificate/ssl_certificate_key.pem -out /etc/nginx/certificate/ssl_certificate.pem -config /etc/nginx/certificate/openssl.cnf

EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]
File renamed without changes.
4 changes: 2 additions & 2 deletions __tests__/Categoria.service.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ICategoriaVM } from "../src/shared/interfaces";
import { ICategoria } from "../src/shared/interfaces";
import { CategoriasService } from "../src/shared/services/api";

const execTests = false;
Expand Down Expand Up @@ -28,7 +28,7 @@ jest.mock("../__mocks__/axios-config", () => ({
}));

describe("CategoriasService", () => {
const mockCategoria: ICategoriaVM = {
const mockCategoria: ICategoria = {
id: 1,
descricao: "Categoria 1",
idTipoCategoria: 1,
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
image: despesas-frontend-react-debug-img
build:
context: .
dockerfile: ./Dockerfile-Debug
dockerfile: ./Dockerfile.Debug
environment:
NODE_ENV: development
NODE_OPTIONS: "--inspect=0.0.0.0:9229"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
working_dir: /usr/share/nginx/html
build:
context: .
dockerfile: ./Dockerfile-Development
dockerfile: ./Dockerfile.Development
ports:
- 3001:80
- 443:443
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.4'

services:
despesas-frontend-react:
container_name: local
image: alexfariakof/despesas-pessoais-react-local-img
working_dir: /usr/share/nginx/html
build:
context: .
dockerfile: ./Dockerfile.Local
ports:
- 3000:3000
restart: always
environment:
NODE_ENV: development
DOMAINS: http://alexfariakof.dev.com
STAGE: development
2 changes: 1 addition & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
working_dir: /usr/share/nginx/html
build:
context: .
dockerfile: ./Dockerfile-Production
dockerfile: ./Dockerfile.Production
ports:
- 3000:3000
restart: always
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
image: alexfariakof/despesas-pessoais-frontend-react-prototipo-img
build:
context: .
dockerfile: ./Dockerfile-Prototipo
dockerfile: ./Dockerfile.Prototipo
environment:
NODE_ENV: production
ports:
Expand Down
2 changes: 1 addition & 1 deletion nginx.dev.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
listen 80;
listen 80 default_server;
server_name _;

location / {
Expand Down
15 changes: 12 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"react-chartjs-2": "^4.3.1",
"react-dom": "^18.2.0",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1"
"react-scripts": "5.0.1",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@babel/core": "^7.8.4",
Expand Down
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Login, MenuLateral } from "./shared/components";
import { AuthProvider, AppThemeProvider, DrawerProvider } from "./shared/contexts";

export const App = () => {

return (
<AuthProvider>
<AppThemeProvider >
Expand Down
29 changes: 6 additions & 23 deletions src/pages/Categorias.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import {
Box,
FormControl,
InputLabel,
MenuItem,
Paper,
Select,
SelectChangeEvent,
TextField,
IconButton,
} from "@mui/material";
import {
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
} from "@mui/material";
import { Box, FormControl, InputLabel, MenuItem, Paper, Select, SelectChangeEvent, TextField, IconButton } from "@mui/material";
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material";
import { BarraFerramentas } from "../shared/components";
import { LayoutMasterPage } from "../shared/layouts";
import { CategoriasService } from "../shared/services/api";
import { Delete, Edit } from "@mui/icons-material";
import { ICategoriaVM } from "../shared/interfaces";
import { Categoria } from "../shared/models";
interface State {
id: number;
descricao: string;
Expand All @@ -33,7 +16,7 @@ interface State {
export const Categorias: React.FC = () => {
const navigate = useNavigate();
const [height, setHeight] = useState(0);
const [rows, setRows] = useState<ICategoriaVM[]>([]);
const [rows, setRows] = useState<Categoria[]>([]);
const [values, setValues] = useState<State>({
id: 0,
descricao: "",
Expand All @@ -50,7 +33,7 @@ export const Categorias: React.FC = () => {
};

const handleSave = () => {
let dados: ICategoriaVM;
let dados: Categoria;
dados = {
id: values.id,
descricao: values.descricao,
Expand Down Expand Up @@ -143,7 +126,7 @@ export const Categorias: React.FC = () => {
return () => {
window.removeEventListener("resize", handleResize);
};
});
}, []);

const initializeCategorias = (): void => {
if (values.idTipoCategoria === 0) {
Expand Down
8 changes: 1 addition & 7 deletions src/pages/Configuracoes.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { useState, MouseEvent, ChangeEvent, useEffect } from "react";
import { useAppThemeContext } from "../shared/contexts";
import {
Box,
Typography,
Paper,
ToggleButtonGroup,
ToggleButton,
} from "@mui/material";
import { Box, Typography, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
import { LayoutMasterPage } from "../shared/layouts";
import ChangePassword from "../shared/components/Configuracoes/ChangePassword";
import ChangeAvatar from "../shared/components/Configuracoes/ChangeAvatar";
Expand Down
24 changes: 8 additions & 16 deletions src/pages/Despesas.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { useEffect, useState } from "react";
import { useNavigate, useParams } from "react-router-dom";
import {
Box,
FormControl,
InputAdornment,
InputLabel,
OutlinedInput,
Paper,
TextField,
} from "@mui/material";
import { Box, FormControl, InputAdornment, InputLabel, OutlinedInput, Paper, TextField } from "@mui/material";
import Select, { SelectChangeEvent } from "@mui/material/Select";
import MenuItem from "@mui/material/MenuItem";
import Stack from "@mui/material/Stack";
Expand All @@ -20,11 +12,11 @@ import { BarraFerramentas } from "../shared/components";
import { LayoutMasterPage } from "../shared/layouts";
import { CategoriasService, DespesasService } from "../shared/services/api";
import { useDebounce } from "../shared/hooks";
import { ICategoriaVM, IDespesaVM } from "../shared/interfaces";
import { Categoria, Despesa } from "../shared/models";

interface State {
id: number;
categoria: ICategoriaVM | undefined | null;
categoria: Categoria | undefined | null;
data: Dayjs | null;
descricao: string;
dtVencimento: Dayjs | null;
Expand All @@ -36,7 +28,7 @@ export const Despesas: React.FC = () => {
const { debounce } = useDebounce(true, true);
const [height, setHeight] = useState(0);
const { id = 0 } = useParams<"id">();
const [categorias, setCategorias] = useState<Omit<ICategoriaVM, "">[]>([]);
const [categorias, setCategorias] = useState<Omit<Categoria, "">[]>([]);
const [values, setValues] = useState<State>({
id: 0,
valor: 0,
Expand Down Expand Up @@ -72,10 +64,10 @@ export const Despesas: React.FC = () => {
};

const handleSave = () => {
let dados: IDespesaVM;
let dados: Despesa;
dados = {
id: Number(id),
categoria: values.categoria as ICategoriaVM,
categoria: values.categoria as Categoria,
data: values.data,
descricao: values.descricao,
valor: values.valor,
Expand Down Expand Up @@ -123,9 +115,9 @@ export const Despesas: React.FC = () => {
}
};

const handleEdit = async (desp: IDespesaVM) => {
const handleEdit = async (desp: Despesa) => {
await CategoriasService.getByTipoCategoria(1).then(
(result: ICategoriaVM[]) => {
(result: Categoria[]) => {
setCategorias(result);
const categoriaDespesa = result.find(
(categoria) => categoria.id === desp.categoria.id
Expand Down
22 changes: 4 additions & 18 deletions src/pages/Lancamentos.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,21 @@
import { useEffect, useState } from "react";
import {
Box,
IconButton,
Paper,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
} from "@mui/material";
import { Box, IconButton, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material";
import { LayoutMasterPage } from "../shared/layouts";
import { BarraFerramentas } from "../shared/components";
import {
LancamentosService,
DespesasService,
ReceitasService,
} from "../shared/services/api";
import { LancamentosService, DespesasService, ReceitasService } from "../shared/services/api";
import { useDebounce } from "../shared/hooks";
import DeleteIcon from "@mui/icons-material/Delete";
import EditIcon from "@mui/icons-material/Edit";
import { useNavigate } from "react-router-dom";
import dayjs, { Dayjs } from "dayjs";
import { ILancamentoVM } from "../shared/interfaces";
import { Lancamento } from "../shared/models";

export const Lancamentos = () => {
const navigate = useNavigate();
const { debounce } = useDebounce(true, false);
const [height, setHeight] = useState(0);
const [lancamentoMesAno, setLancamentoMesAno] = useState<Dayjs>(dayjs());
const [rows, setRows] = useState<Omit<ILancamentoVM, "id">[]>([]);
const [rows, setRows] = useState<Omit<Lancamento, "id">[]>([]);
const handleAtualizarLancamento = (valorMesAno: Dayjs) => {
setLancamentoMesAno(valorMesAno);
LancamentosService.getByMesAnoByIdUsuario(valorMesAno).then((result) => {
Expand Down
Loading

0 comments on commit 4e66578

Please sign in to comment.