From fb3b0a16918ca1cc63d6543d37606250df3e384d Mon Sep 17 00:00:00 2001 From: Benjamin POCHAT Date: Mon, 19 Feb 2024 12:32:36 +0000 Subject: [PATCH] first version for package lot edition --- frontend/app/src/App.css | 4 +- .../production/ProductionController.js | 23 -------- .../components/PackageLotConfigurator.js | 56 ------------------- .../production/views/PackageLotsCreator.js | 4 +- .../BeefProductionCreator.tsx | 6 +- .../layouts/producer/AuthenticatedLayout.tsx | 2 +- 6 files changed, 9 insertions(+), 86 deletions(-) delete mode 100644 frontend/app/src/domains/production/ProductionController.js delete mode 100644 frontend/app/src/domains/production/components/PackageLotConfigurator.js diff --git a/frontend/app/src/App.css b/frontend/app/src/App.css index 5a9fc46..bec71f7 100644 --- a/frontend/app/src/App.css +++ b/frontend/app/src/App.css @@ -34,9 +34,11 @@ .lot__package__name { grid-area: name; + display: flex; + justify-content: space-between; } -.lot__package:hover { +.lot__package__edit:hover { cursor: pointer; background-color: whitesmoke; } diff --git a/frontend/app/src/domains/production/ProductionController.js b/frontend/app/src/domains/production/ProductionController.js deleted file mode 100644 index 7f48ff6..0000000 --- a/frontend/app/src/domains/production/ProductionController.js +++ /dev/null @@ -1,23 +0,0 @@ -import { useState } from 'react' -import BeefProductionCreator from './views/beefProductionCreator/BeefProductionCreator.tsx' -import PackageLotsCreator from './views/PackageLotsCreator' -import ProductionsList from './views/ProductionsList.tsx' - -export default function ProductionController() { - - const BEEF_PRODUCTION_CREATION = 'BEEF_PRODUCTION_CREATION' - const BEEF_PRODUCTION_PACKAGE_MODIFICATION = 'BEEF_PRODUCTION_PACKAGE_MODIFICATION' - const PRODUCTIONS_LIST = 'PRODUCTIONS_LIST' - - const [currentAction, setCurrentAction] = useState(PRODUCTIONS_LIST) - - return <>{getContent()} - - function getContent() { - switch (currentAction) { - case PRODUCTIONS_LIST: return setCurrentAction(BEEF_PRODUCTION_CREATION)}> - case BEEF_PRODUCTION_CREATION: return {setCurrentAction(action)}} /> - case BEEF_PRODUCTION_PACKAGE_MODIFICATION: return - } - } -} \ No newline at end of file diff --git a/frontend/app/src/domains/production/components/PackageLotConfigurator.js b/frontend/app/src/domains/production/components/PackageLotConfigurator.js deleted file mode 100644 index f36525b..0000000 --- a/frontend/app/src/domains/production/components/PackageLotConfigurator.js +++ /dev/null @@ -1,56 +0,0 @@ -import { useState } from "react" -import PackageLot from "viandeendirect_eu/dist/model/PackageLot" -import { Button } from "@mui/material" - -/** - * - * @param {PackageLot} lot - * @returns - */ -export default function PackageLotsConfigurator({packageLot: packageLot, changeCallback: changeCallback}) { - const [quantity, setQuantity] = useState(packageLot.quantity) - - return
-
-
-
{packageLot.label}
-
{packageLot.description}
-
{packageLot.netWeight} kg
-
{packageLot.unitPrice} € TTC/kg
-
-
- - -
-
-
{quantity}
-
colis mis en vente
-
{quantity * packageLot.netWeight} kg
-
{quantity * packageLot.netWeight * packageLot.unitPrice} € TTC
-
-
- - -
-
-
- - /** - * @param {number} quantity - */ - function addPackages(quantity) { - packageLot.quantity += quantity - setQuantity(packageLot.quantity) - changeCallback(packageLot) - } - - /** - * @param {number} quantity - */ - function removePackages(quantity) { - packageLot.quantity -= Math.min(quantity, packageLot.quantity) - setQuantity(packageLot.quantity) - changeCallback(packageLot) - } - -} \ No newline at end of file diff --git a/frontend/app/src/domains/production/views/PackageLotsCreator.js b/frontend/app/src/domains/production/views/PackageLotsCreator.js index 3b41be7..c9c8c98 100644 --- a/frontend/app/src/domains/production/views/PackageLotsCreator.js +++ b/frontend/app/src/domains/production/views/PackageLotsCreator.js @@ -3,7 +3,7 @@ import { useEffect, useState } from "react" import { useKeycloak } from '@react-keycloak/web' import { ApiBuilder } from '../../../api/ApiBuilder.ts' import PackageLot from "viandeendirect_eu/dist/model/PackageLot" -import PackageLotsConfigurator from "../components/PackageLotConfigurator" +import PackageLotConfigurator from "../components/PackageLotConfigurator.tsx" export default function PackageLotsCreator({ production: production, changeProductionCallback: changeProductionCallback }) { @@ -40,7 +40,7 @@ export default function PackageLotsCreator({ production: production, changeProdu }, [keycloak]) return <> - {production.lots?.map(lot => )} + {production.lots?.map(lot => )} function changeLotConfiguration(lot) { diff --git a/frontend/app/src/domains/production/views/beefProductionCreator/BeefProductionCreator.tsx b/frontend/app/src/domains/production/views/beefProductionCreator/BeefProductionCreator.tsx index 94a2228..dbc7247 100644 --- a/frontend/app/src/domains/production/views/beefProductionCreator/BeefProductionCreator.tsx +++ b/frontend/app/src/domains/production/views/beefProductionCreator/BeefProductionCreator.tsx @@ -1,8 +1,7 @@ import React from "react" import { useState } from "react" -import { Button, ButtonGroup, Typography, Stepper, Step, StepLabel, StepContent, Slider, StepButton, Alert } from "@mui/material" -import { DatePickerElement, FormContainer, SelectElement, TextFieldElement, SliderElement, useForm } from 'react-hook-form-mui' +import { Button, ButtonGroup, Typography, Stepper, Step, StepContent, StepButton, Alert } from "@mui/material" import 'dayjs/locale/fr' @@ -25,7 +24,8 @@ export default function BeefProductionCreator({ callback }) { const PRODUCTS_STEP = 3 const { keycloak } = useKeycloak() - const [ activeStep, setActiveStep ] = useState(BREEDING_PROPERTIES_STEP) + //const [ activeStep, setActiveStep ] = useState(BREEDING_PROPERTIES_STEP) + const [ activeStep, setActiveStep ] = useState(PRODUCTS_STEP) const [ beefProduction, setBeefProduction] = useState({ productionType: "BeefProduction"}) const [completedSteps, setCompletedSteps] = useState>([]) const apiBuilder = new ApiBuilder() diff --git a/frontend/app/src/layouts/producer/AuthenticatedLayout.tsx b/frontend/app/src/layouts/producer/AuthenticatedLayout.tsx index 9c7995d..d727057 100644 --- a/frontend/app/src/layouts/producer/AuthenticatedLayout.tsx +++ b/frontend/app/src/layouts/producer/AuthenticatedLayout.tsx @@ -9,7 +9,7 @@ import { ApiInvoker } from '../../api/ApiInvoker.ts' import Dashboard from '../../domains/dashboard/Dashboard.js'; import CustomerController from '../../domains/customer/CustomerController.js'; import GrowerAccount from '../../domains/producer/ProducerAccount.js' -import ProductionController from '../../domains/production/ProductionController.js' +import ProductionController from '../../domains/production/ProductionController.tsx' import SaleController from '../../domains/sale/SaleController.tsx' import SideMenu from './SideMenu.js' import Producer from 'viandeendirect_eu/dist/model/Producer.js';