diff --git a/backend/Dockerfile b/backend/Dockerfile
index b5d7038..2b8a7e3 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -9,11 +9,13 @@ WORKDIR /home/viandeendirect
COPY ./backend/pom.xml ./backend/pom.xml
COPY ./backend/gen/pom.xml ./backend/gen/pom.xml
COPY ./backend/app/pom.xml ./backend/app/pom.xml
+COPY ./backend/model/pom.xml ./backend/model/pom.xml
RUN mvn -s /usr/share/maven/ref/settings-docker.xml -f ./backend/pom.xml dependency:go-offline
COPY ./backend/gen/src ./backend/gen/src
COPY ./backend/app/src ./backend/app/src
+COPY ./backend/model/src ./backend/model/src
RUN mvn -s /usr/share/maven/ref/settings-docker.xml -f ./backend/pom.xml clean install
diff --git a/backend/app/src/main/resources/application-dev.properties b/backend/app/src/main/resources/application-dev.properties
index 5698394..b5fc330 100644
--- a/backend/app/src/main/resources/application-dev.properties
+++ b/backend/app/src/main/resources/application-dev.properties
@@ -11,9 +11,6 @@ spring.datasource.password=vndndrct-db-p4ssw0rd
#spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
# database / JPA config
-spring.datasource.driverClassName=org.postgresql.Driver
-spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
-spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
#spring.jpa.hibernate.ddl-auto = create
spring.jpa.hibernate.ddl-auto = update
spring.jpa.show-sql=true
diff --git a/backend/app/src/main/resources/application-oauth.properties b/backend/app/src/main/resources/application-oauth.properties
new file mode 100644
index 0000000..a1c8c62
--- /dev/null
+++ b/backend/app/src/main/resources/application-oauth.properties
@@ -0,0 +1,4 @@
+spring.security.oauth2.client.registration.keycloak.client-id=viandeendirect-frontend
+spring.security.oauth2.client.registration.keycloak.authorization-grant-type=authorization_code
+spring.security.oauth2.client.registration.keycloak.scope=openid
+spring.security.oauth2.client.provider.keycloak.user-name-attribute=preferred_username
diff --git a/backend/app/src/main/resources/application-postgre.properties b/backend/app/src/main/resources/application-postgre.properties
new file mode 100644
index 0000000..974b499
--- /dev/null
+++ b/backend/app/src/main/resources/application-postgre.properties
@@ -0,0 +1,4 @@
+spring.datasource.driverClassName=org.postgresql.Driver
+spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
+spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
+spring.jpa.hibernate.ddl-auto = create
diff --git a/backend/app/src/main/resources/application.properties b/backend/app/src/main/resources/application.properties
index e4f93ae..de3607e 100644
--- a/backend/app/src/main/resources/application.properties
+++ b/backend/app/src/main/resources/application.properties
@@ -1,11 +1,3 @@
server.port=8080
spring.jackson.date-format=eu.viandeendirect.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
-
-# database / JPA config
-spring.jpa.hibernate.ddl-auto = create
-
-spring.security.oauth2.client.registration.keycloak.client-id=viandeendirect-frontend
-spring.security.oauth2.client.registration.keycloak.authorization-grant-type=authorization_code
-spring.security.oauth2.client.registration.keycloak.scope=openid
-spring.security.oauth2.client.provider.keycloak.user-name-attribute=preferred_username
diff --git a/compose.yml b/compose.yml
index 8f68adc..70e6aa7 100644
--- a/compose.yml
+++ b/compose.yml
@@ -38,17 +38,18 @@ services:
- KC_DB_URL=jdbc:postgresql://localhost:${postgres_port:-5432}/identity
- KC_DB_USERNAME=identity
- KC_DB_PASSWORD=${identity_database_password:-dntt-db-p4ssw0rd}
- - KC_HOSTNAME=localhost
- - KC_HTTP_PORT=8180
+ - KC_HOSTNAME_URL=${identity_url:-http://localhost:8180}
+ - KC_HOSTNAME_ADMIN_URL=${identity_url:-http://localhost:8180}
- KC_HEALTH_ENABLED=true
+ - KC_PROXY=edge
healthcheck:
- test: [ "CMD-SHELL", "curl -f http://localhost:8180/health || exit 1" ]
+ test: [ "CMD-SHELL", "curl -f http://localhost:8080/health || exit 1" ]
interval: 5s
timeout: 60s
retries: 5
command: start-dev
ports:
- - ${keycloak_port:-8180}:8180
+ - ${identity_port:-8180}:8080
network_mode: "host"
backend:
@@ -58,11 +59,12 @@ services:
image: benjaminpochat/viandeendirect-backend:${DOCKER_IMAGE_TAG:-latest}
environment:
- SERVER_PORT=8080
- - SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:${postgres_port:-5432}/viandeendirect
+ - SPRING_DATASOURCE_URL=jdbc:postgresql://database:5432/viandeendirect
- SPRING_DATASOURCE_USERNAME=viandeendirect
- SPRING_DATASOURCE_PASSWORD=${backend_database_password:-vndndrct-db-p4ssw0rd}
- - SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_KEYCLOAK_ISSUER_URI=http://localhost:${keycloak_port:-8180}/realms/viandeendirect
- - SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI=http://localhost:${keycloak_port:-8180}/realms/viandeendirect
+ - SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_KEYCLOAK_ISSUER_URI=${identity_url:-http://localhost:8180}/realms/viandeendirect
+ - SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI=${identity_url:-http://localhost:8180}/realms/viandeendirect
+ - SPRING_PROFILES_ACTIVE=oauth,postgre
depends_on:
database:
condition: service_healthy
@@ -76,10 +78,6 @@ services:
build:
context: "."
dockerfile: ./frontend/Dockerfile
- args:
- #REACT_APP_FRONTEND_URL: https://sandbox.viandeendirect.eu
- REACT_APP_BACKEND_URL: https://sandbox.viandeendirect.eu:8080
- #REACT_APP_IDENTITY_URL: https://sandbox.identity.viandeendirect.eu
image: benjaminpochat/viandeendirect-frontend:${DOCKER_IMAGE_TAG:-latest}
volumes:
- ${frontend_config_path:-./frontend-config}:/usr/local/apache2/htdocs/config
diff --git a/frontend/Dockerfile b/frontend/Dockerfile
index ab20e97..5c3fa51 100644
--- a/frontend/Dockerfile
+++ b/frontend/Dockerfile
@@ -9,9 +9,6 @@ COPY ./frontend /frontend
COPY ./openapi /openapi
WORKDIR /frontend/app
-ARG REACT_APP_BACKEND_URL
-ENV REACT_APP_BACKEND_URL=${REACT_APP_BACKEND_URL}
-
RUN npm run generate:api
RUN npm run build:api
RUN npm run install:api
diff --git a/frontend/app/package-lock.json b/frontend/app/package-lock.json
index 0801be7..0b5be82 100644
--- a/frontend/app/package-lock.json
+++ b/frontend/app/package-lock.json
@@ -37,6 +37,7 @@
"@types/node": "^20.9.2",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
+ "dotenv": "^16.3.1",
"typescript": "^5.2.2"
}
},
@@ -5482,9 +5483,9 @@
}
},
"node_modules/acorn": {
- "version": "8.10.0",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz",
- "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==",
+ "version": "8.11.3",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
+ "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
"bin": {
"acorn": "bin/acorn"
},
@@ -7967,11 +7968,15 @@
}
},
"node_modules/dotenv": {
- "version": "10.0.0",
- "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
- "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
+ "version": "16.3.1",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
+ "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
+ "dev": true,
"engines": {
- "node": ">=10"
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/motdotla/dotenv?sponsor=1"
}
},
"node_modules/dotenv-expand": {
@@ -15723,6 +15728,14 @@
}
}
},
+ "node_modules/react-scripts/node_modules/dotenv": {
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
+ "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/react-transition-group": {
"version": "4.4.5",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
diff --git a/frontend/app/package.json b/frontend/app/package.json
index 1912789..e33cd73 100644
--- a/frontend/app/package.json
+++ b/frontend/app/package.json
@@ -64,6 +64,7 @@
"@types/node": "^20.9.2",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
+ "dotenv": "^16.3.1",
"typescript": "^5.2.2"
}
}
diff --git a/frontend/app/public/favicon.ico b/frontend/app/public/favicon.ico
deleted file mode 100644
index a11777c..0000000
Binary files a/frontend/app/public/favicon.ico and /dev/null differ
diff --git a/frontend/app/public/favicon.svg b/frontend/app/public/favicon.svg
new file mode 100644
index 0000000..9001089
--- /dev/null
+++ b/frontend/app/public/favicon.svg
@@ -0,0 +1,9 @@
+
+
diff --git a/frontend/app/public/index.html b/frontend/app/public/index.html
index aa069f2..c33f38b 100644
--- a/frontend/app/public/index.html
+++ b/frontend/app/public/index.html
@@ -2,7 +2,7 @@
-
+
- React App
+ Viande en direct
diff --git a/frontend/app/src/api/AuthenticatedApiBuilder.js b/frontend/app/src/api/AuthenticatedApiBuilder.js
index b45ba73..8cc0bdb 100644
--- a/frontend/app/src/api/AuthenticatedApiBuilder.js
+++ b/frontend/app/src/api/AuthenticatedApiBuilder.js
@@ -3,18 +3,30 @@ import DefaultApi from 'viandeendirect_eu/dist/api/DefaultApi'
import { MockApi } from './mock/MockApi.ts'
export class AuthenticatedApiBuilder {
+
+ backendUrl = undefined
+
+ async getBackendUrl() {
+ if (!this.backendUrl) {
+ let response = await fetch(window.location.origin + '/config/viandeendirect.json')
+ let config = await response.json()
+ this.backendUrl = config.backendUrl
+ }
+ return this.backendUrl
+ }
+
/**
*
* @param {*} keycloak
- * @returns {DefaultApi | MockApi}
+ * @returns {Promise< DefaultApi | MockApi>}
*/
- getAuthenticatedApi(keycloak) {
+ async getAuthenticatedApi(keycloak) {
if(process.env.REACT_APP_MOCK_API) {
return new MockApi()
} else {
let apiClient = ApiClient.instance
apiClient.authentications['oAuth2ForViandeEnDirect'].accessToken = keycloak.token
- apiClient.basePath = 'http://localhost:8080'
+ apiClient.basePath = await this.getBackendUrl()
var api = new DefaultApi(apiClient)
return api
}
diff --git a/frontend/app/src/domains/customer/views/CustomersList.tsx b/frontend/app/src/domains/customer/views/CustomersList.tsx
index 32f7f9e..021488a 100644
--- a/frontend/app/src/domains/customer/views/CustomersList.tsx
+++ b/frontend/app/src/domains/customer/views/CustomersList.tsx
@@ -17,17 +17,18 @@ export default function CustomersList() {
}, [keycloak])
function loadCustomers() {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak)
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getCustomers((error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.getSales called successfully. Returned data: ' + data)
- setCustomers(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getCustomers((error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.getSales called successfully. Returned data: ' + data)
+ setCustomers(data)
+ }
+ })
+ }, keycloak)
+ })
}
const rows: GridRowsProp = customers.map(customer => {
diff --git a/frontend/app/src/domains/production/components/BeefProductionCard.tsx b/frontend/app/src/domains/production/components/BeefProductionCard.tsx
index 62b85ea..2f4e1ce 100644
--- a/frontend/app/src/domains/production/components/BeefProductionCard.tsx
+++ b/frontend/app/src/domains/production/components/BeefProductionCard.tsx
@@ -1,3 +1,4 @@
+import React from 'react';
import { useEffect, useState } from 'react';
import { useKeycloak } from '@react-keycloak/web'
import { Button, Card, CardActions, CardContent, Typography } from "@mui/material"
@@ -14,17 +15,18 @@ export default function BeefProductionCard({
const authenticatedApiBuilder = new AuthenticatedApiBuilder()
useEffect(() => {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak);
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getBeefProduction(production.id, (error, data, response) => {
- if (error) {
- console.error(error);
- } else {
- console.log('api.getBeefProduction called successfully. Returned data: ' + data);
- setBeefProduction(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getBeefProduction(production.id, (error, data, response) => {
+ if (error) {
+ console.error(error);
+ } else {
+ console.log('api.getBeefProduction called successfully. Returned data: ' + data);
+ setBeefProduction(data)
+ }
+ })
+ }, keycloak)
+ })
}, [keycloak])
return (
diff --git a/frontend/app/src/domains/production/views/BeefProductionForm.js b/frontend/app/src/domains/production/views/BeefProductionForm.js
index 2a23c2b..6238242 100644
--- a/frontend/app/src/domains/production/views/BeefProductionForm.js
+++ b/frontend/app/src/domains/production/views/BeefProductionForm.js
@@ -22,7 +22,7 @@ export default function BeefProductionForm({ callback }) {
const { keycloak, initialized } = useKeycloak()
const [ activeStep, setActiveStep ] = useState(SET_PRODUCTION_PROPERTIES_STEP)
const [ beefProduction, setBeefProduction] = useState(new BeefProduction())
- const authenticayedApiBuilder = new AuthenticatedApiBuilder()
+ const authenticatedApiBuilder = new AuthenticatedApiBuilder()
return <>
Nouvel abattage bovin
@@ -93,17 +93,18 @@ export default function BeefProductionForm({ callback }) {
}
function validate() {
- var api = authenticayedApiBuilder.getAuthenticatedApi(keycloak);
- authenticayedApiBuilder.invokeAuthenticatedApi(() => {
- api.createBeefProduction(beefProduction, (error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('API called successfully. Returned data: ' + data)
- callback('PRODUCTIONS_LIST')
- }
- })
- }, keycloak);
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.createBeefProduction(beefProduction, (error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('API called successfully. Returned data: ' + data)
+ callback('PRODUCTIONS_LIST')
+ }
+ })
+ }, keycloak)
+ });
}
function cancel() {
diff --git a/frontend/app/src/domains/production/views/PackageLotsCreator.js b/frontend/app/src/domains/production/views/PackageLotsCreator.js
index 9a88cd5..e034d44 100644
--- a/frontend/app/src/domains/production/views/PackageLotsCreator.js
+++ b/frontend/app/src/domains/production/views/PackageLotsCreator.js
@@ -13,28 +13,29 @@ export default function PackageLotsCreator() {
const authenticatedApiBuilder = new AuthenticatedApiBuilder()
useEffect(() => {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak);
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getPackageTemplates((error, data, response) => {
- if (error) {
- console.error(error);
- } else {
- console.log('api.getPackageTemplates called successfully. Returned data: ' + data);
- const lots = []
- data.map(template => {
- let lot = new PackageLot()
- lot.label = template.label
- lot.description = template.description
- lot.unitPrice = template.unitPrice
- lot.netWeight = template.netWeight
- lot.quantity = 0
- lot.quantitySold = 0
- lots.push(lot)
- })
- setPackageLots(lots)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getPackageTemplates((error, data, response) => {
+ if (error) {
+ console.error(error);
+ } else {
+ console.log('api.getPackageTemplates called successfully. Returned data: ' + data);
+ const lots = []
+ data.map(template => {
+ let lot = new PackageLot()
+ lot.label = template.label
+ lot.description = template.description
+ lot.unitPrice = template.unitPrice
+ lot.netWeight = template.netWeight
+ lot.quantity = 0
+ lot.quantitySold = 0
+ lots.push(lot)
+ })
+ setPackageLots(lots)
+ }
+ })
+ }, keycloak)
+ })
}, [keycloak])
return <>
diff --git a/frontend/app/src/domains/production/views/ProductionsList.tsx b/frontend/app/src/domains/production/views/ProductionsList.tsx
index 54b4dad..8d6eab0 100644
--- a/frontend/app/src/domains/production/views/ProductionsList.tsx
+++ b/frontend/app/src/domains/production/views/ProductionsList.tsx
@@ -19,17 +19,18 @@ export default function ProductionsList({createBeefProductionCallback: createBee
}, [keycloak])
function loadProductions() {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak)
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getProductions({}, (error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.getProductions called successfully. Returned data: ' + data)
- setProductions(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getProductions({}, (error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.getProductions called successfully. Returned data: ' + data)
+ setProductions(data)
+ }
+ })
+ }, keycloak)
+ })
}
return <>
diff --git a/frontend/app/src/domains/sale/components/SaleCardBeefProduction.js b/frontend/app/src/domains/sale/components/SaleCardBeefProduction.js
index 54f548c..155aefe 100644
--- a/frontend/app/src/domains/sale/components/SaleCardBeefProduction.js
+++ b/frontend/app/src/domains/sale/components/SaleCardBeefProduction.js
@@ -17,17 +17,18 @@ export default function SaleCardBeefProduction({production: production}) {
function loadProductionPercentageSold() {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak)
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getProductionPercentageSold(production.id, (error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.getProductionPercentageSold called successfully. Returned data: ' + data)
- setProductionPercentageSold(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getProductionPercentageSold(production.id, (error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.getProductionPercentageSold called successfully. Returned data: ' + data)
+ setProductionPercentageSold(data)
+ }
+ })
+ }, keycloak)
+ })
}
return <>
diff --git a/frontend/app/src/domains/sale/components/SaleProductionSelector.js b/frontend/app/src/domains/sale/components/SaleProductionSelector.js
index 71e959f..b7a378b 100644
--- a/frontend/app/src/domains/sale/components/SaleProductionSelector.js
+++ b/frontend/app/src/domains/sale/components/SaleProductionSelector.js
@@ -14,17 +14,18 @@ export default function SaleProductionSelector({selectProduction: selectProducti
}, [keycloak])
function loadProductionsForSale() {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak)
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getProductions({ 'forSale': true }, (error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.getProductions called successfully. Returned data: ' + data)
- setProductionsForSale(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getProductions({ 'forSale': true }, (error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.getProductions called successfully. Returned data: ' + data)
+ setProductionsForSale(data)
+ }
+ })
+ }, keycloak)
+ })
}
function handleProductSelection(production) {
diff --git a/frontend/app/src/domains/sale/views/OrderForm.tsx b/frontend/app/src/domains/sale/views/OrderForm.tsx
index 63e03b2..9f19947 100644
--- a/frontend/app/src/domains/sale/views/OrderForm.tsx
+++ b/frontend/app/src/domains/sale/views/OrderForm.tsx
@@ -39,31 +39,33 @@ export default function OrderForm({ sale: sale, returnCallback: returnCallback }
}, [keycloak])
function loadProductions() {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak);
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getSaleProductions(sale.id, (error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.getSaleProductions called successfully. Returned data: ' + data)
- setProductions(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getSaleProductions(sale.id, (error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.getSaleProductions called successfully. Returned data: ' + data)
+ setProductions(data)
+ }
+ })
+ }, keycloak)
+ })
}
function loadCustomers() {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak);
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getCustomers((error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.getCustomers called successfully. Returned data: ' + data)
- setCustomers(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getCustomers((error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.getCustomers called successfully. Returned data: ' + data)
+ setCustomers(data)
+ }
+ })
+ }, keycloak)
+ })
}
return <>
@@ -139,29 +141,31 @@ export default function OrderForm({ sale: sale, returnCallback: returnCallback }
}
function createCustomer(customer: Customer){
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak);
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.createCustomer(customer, (error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.createCustomer called successfully. Returned data: ' + data)
- setOrder({...order, customer: data})
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.createCustomer(customer, (error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.createCustomer called successfully. Returned data: ' + data)
+ setOrder({...order, customer: data})
+ }
+ })
+ }, keycloak)
+ })
}
function createOrder(order: Order) {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak);
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.createOrder(order, (error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.createOrder called successfully. Returned data: ' + data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.createOrder(order, (error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.createOrder called successfully. Returned data: ' + data)
+ }
+ })
+ }, keycloak)
+ })
}
}
diff --git a/frontend/app/src/domains/sale/views/OrderView.tsx b/frontend/app/src/domains/sale/views/OrderView.tsx
index e01a9ef..862716d 100644
--- a/frontend/app/src/domains/sale/views/OrderView.tsx
+++ b/frontend/app/src/domains/sale/views/OrderView.tsx
@@ -20,17 +20,18 @@ export default function OrderView({order: rawOrder, sale: sale, returnCallback:
}, [keycloak])
function loadOrder() {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak);
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getOrder(rawOrder.id, (error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.getOrder called successfully. Returned data: ' + data)
- setOrder(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getOrder(rawOrder.id, (error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.getOrder called successfully. Returned data: ' + data)
+ setOrder(data)
+ }
+ })
+ }, keycloak)
+ })
}
return <>
diff --git a/frontend/app/src/domains/sale/views/OrdersList.tsx b/frontend/app/src/domains/sale/views/OrdersList.tsx
index 8d8c790..5e2b122 100644
--- a/frontend/app/src/domains/sale/views/OrdersList.tsx
+++ b/frontend/app/src/domains/sale/views/OrdersList.tsx
@@ -26,17 +26,18 @@ export default function OrdersList({
}, [keycloak])
function loadOrders() {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak);
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getSaleOrders(sale.id, (error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.getSaleOrders called successfully. Returned data: ' + data)
- setOrders(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getSaleOrders(sale.id, (error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.getSaleOrders called successfully. Returned data: ' + data)
+ setOrders(data)
+ }
+ })
+ }, keycloak)
+ })
}
const columns: GridColDef[] = [
diff --git a/frontend/app/src/domains/sale/views/SaleForm.js b/frontend/app/src/domains/sale/views/SaleForm.js
index 6e52990..3395187 100644
--- a/frontend/app/src/domains/sale/views/SaleForm.js
+++ b/frontend/app/src/domains/sale/views/SaleForm.js
@@ -34,17 +34,18 @@ export default function SaleForm({returnCallback: returnCallback}) {
const authenticatedApiBuilder = new AuthenticatedApiBuilder()
useEffect(() => {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak);
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getAddresses((error, data, response) => {
- if (error) {
- console.error(error);
- } else {
- console.log('api.getAddresses called successfully. Returned data: ' + data);
- setAddresses(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getAddresses((error, data, response) => {
+ if (error) {
+ console.error(error);
+ } else {
+ console.log('api.getAddresses called successfully. Returned data: ' + data);
+ setAddresses(data)
+ }
+ })
+ }, keycloak)
+ })
}, [keycloak])
return <>
diff --git a/frontend/app/src/domains/sale/views/SalesList.tsx b/frontend/app/src/domains/sale/views/SalesList.tsx
index 876ee3a..695805d 100644
--- a/frontend/app/src/domains/sale/views/SalesList.tsx
+++ b/frontend/app/src/domains/sale/views/SalesList.tsx
@@ -19,17 +19,18 @@ export default function SalesList({manageSaleOrdersCallback: manageSaleOrdersCal
}, [keycloak])
function loadSales() {
- let api = authenticatedApiBuilder.getAuthenticatedApi(keycloak)
- authenticatedApiBuilder.invokeAuthenticatedApi(() => {
- api.getSales((error, data, response) => {
- if (error) {
- console.error(error)
- } else {
- console.log('api.getSales called successfully. Returned data: ' + data)
- setSales(data)
- }
- })
- }, keycloak)
+ authenticatedApiBuilder.getAuthenticatedApi(keycloak).then(api => {
+ authenticatedApiBuilder.invokeAuthenticatedApi(() => {
+ api.getSales((error, data, response) => {
+ if (error) {
+ console.error(error)
+ } else {
+ console.log('api.getSales called successfully. Returned data: ' + data)
+ setSales(data)
+ }
+ })
+ }, keycloak)
+ })
}
return <>