diff --git a/frontend/app/package-lock.json b/frontend/app/package-lock.json index f11c5d1..e7f79a1 100644 --- a/frontend/app/package-lock.json +++ b/frontend/app/package-lock.json @@ -11,6 +11,7 @@ "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.9", + "@mui/lab": "^5.0.0-alpha.165", "@mui/material": "^5.14.11", "@mui/x-date-pickers": "^6.14.0", "@react-keycloak/web": "^3.4.0", @@ -3784,6 +3785,46 @@ } } }, + "node_modules/@mui/lab": { + "version": "5.0.0-alpha.165", + "resolved": "https://registry.npmjs.org/@mui/lab/-/lab-5.0.0-alpha.165.tgz", + "integrity": "sha512-8/zJStT10nh9yrAzLOPTICGhpf5YiGp/JpM0bdTP7u5AE+YT+X2u6QwMxuCrVeW8/WVLAPFg0vtzyfgPcN5T7g==", + "dependencies": { + "@babel/runtime": "^7.23.9", + "@mui/base": "5.0.0-beta.36", + "@mui/system": "^5.15.9", + "@mui/types": "^7.2.13", + "@mui/utils": "^5.15.9", + "clsx": "^2.1.0", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@emotion/react": "^11.5.0", + "@emotion/styled": "^11.3.0", + "@mui/material": ">=5.15.0", + "@types/react": "^17.0.0 || ^18.0.0", + "react": "^17.0.0 || ^18.0.0", + "react-dom": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@emotion/react": { + "optional": true + }, + "@emotion/styled": { + "optional": true + }, + "@types/react": { + "optional": true + } + } + }, "node_modules/@mui/material": { "version": "5.15.10", "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.15.10.tgz", diff --git a/frontend/app/package.json b/frontend/app/package.json index ea6dfdc..bf9cb0c 100644 --- a/frontend/app/package.json +++ b/frontend/app/package.json @@ -6,6 +6,7 @@ "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.9", + "@mui/lab": "^5.0.0-alpha.165", "@mui/material": "^5.14.11", "@mui/x-date-pickers": "^6.14.0", "@react-keycloak/web": "^3.4.0", diff --git a/frontend/app/src/App.css b/frontend/app/src/App.css index bec71f7..8ec3c9b 100644 --- a/frontend/app/src/App.css +++ b/frontend/app/src/App.css @@ -6,11 +6,11 @@ } .form > div { - margin: 1rem; + margin-top: 1rem; } -.form-select-list { - width: 10rem; +.popin-form > div { + margin-top: 1rem; } .card-clickable > *:hover { @@ -50,6 +50,7 @@ .lot__package__description { font-size: x-small; grid-area: description; + white-space:pre-wrap; } .lot__package__net-weight { diff --git a/frontend/app/src/api/mock/MockApiProductions.ts b/frontend/app/src/api/mock/MockApiProductions.ts index a58b74d..81a3e14 100644 --- a/frontend/app/src/api/mock/MockApiProductions.ts +++ b/frontend/app/src/api/mock/MockApiProductions.ts @@ -27,7 +27,9 @@ export class MockApiProductions { return { id: 1, animalIdentifier: '1234', + birthDate: '2022-10-01T10:00:00', slaughterDate: '2023-10-01T10:00:00', + cuttingDate: '2024-10-01T10:00:00', warmCarcassWeight: 450, animalType: 'BEEF_COW', lots: [ diff --git a/frontend/app/src/domains/production/ProductionController.tsx b/frontend/app/src/domains/production/ProductionController.tsx index 6237b4c..c7da641 100644 --- a/frontend/app/src/domains/production/ProductionController.tsx +++ b/frontend/app/src/domains/production/ProductionController.tsx @@ -1,24 +1,32 @@ import React from 'react' import { useState } from 'react' import BeefProductionCreator from './views/beefProductionCreator/BeefProductionCreator.tsx' -import PackageLotsCreator from './views/PackageLotsCreator.js' +import PackageLotsCreator from './views/PackageLotsCreator.tsx' import ProductionsList from './views/ProductionsList.tsx' +import BeefProductionView from './views/BeefProductionView.tsx' export default function ProductionController() { const BEEF_PRODUCTION_CREATION = 'BEEF_PRODUCTION_CREATION' - const BEEF_PRODUCTION_PACKAGE_MODIFICATION = 'BEEF_PRODUCTION_PACKAGE_MODIFICATION' + const BEEF_PRODUCTION_VIEW = 'BEEF_PRODUCTION_VIEW' const PRODUCTIONS_LIST = 'PRODUCTIONS_LIST' const [currentAction, setCurrentAction] = useState(PRODUCTIONS_LIST) + const [context, setContext] = useState(undefined) return <>{getContent()} function getContent() { switch (currentAction) { - case PRODUCTIONS_LIST: return setCurrentAction(BEEF_PRODUCTION_CREATION)}> + case PRODUCTIONS_LIST: return setCurrentAction(BEEF_PRODUCTION_CREATION)} + viewBeefProductionCallback={(production) => { + setContext(production) + setCurrentAction(BEEF_PRODUCTION_VIEW)}}/> case BEEF_PRODUCTION_CREATION: return {setCurrentAction(action)}} /> - case BEEF_PRODUCTION_PACKAGE_MODIFICATION: return + case BEEF_PRODUCTION_VIEW: return { + setCurrentAction(PRODUCTIONS_LIST) + setContext(undefined)}}/> } } } \ No newline at end of file diff --git a/frontend/app/src/domains/production/components/BeefProductionCard.tsx b/frontend/app/src/domains/production/components/BeefProductionCard.tsx index 69419fe..19d803a 100644 --- a/frontend/app/src/domains/production/components/BeefProductionCard.tsx +++ b/frontend/app/src/domains/production/components/BeefProductionCard.tsx @@ -1,14 +1,14 @@ import React from 'react'; -import { useEffect, useState } from 'react'; +import { Button, Card, CardActionArea, CardActions, CardContent, Typography } from "@mui/material" +import { useEffect, useState } from 'react' import { useKeycloak } from '@react-keycloak/web' -import { Button, Card, CardActions, CardContent, Typography } from "@mui/material" import { ApiBuilder } from '../../../api/ApiBuilder.ts' import dayjs from 'dayjs' export default function BeefProductionCard({ production: production, showActions: showActions, - setPackageModificationLayoutContent: setPackageModificationLayoutContent}) { + viewBeefProductionCallback: viewBeefProductionCallback}) { const [beefProduction, setBeefProduction] = useState(production) const { keycloak, initialized } = useKeycloak() @@ -31,17 +31,19 @@ export default function BeefProductionCard({ return ( - - - Abattage bovin - - - Abattage le {dayjs(beefProduction.slaughterDate).format('DD/MM/YYYY')} - - - Poids de carcasse chaude : {beefProduction.warmCarcassWeight} kg - - + viewBeefProductionCallback(beefProduction)}> + + + Abattage bovin + + + Abattage le {dayjs(beefProduction.slaughterDate).format('DD/MM/YYYY')} + + + Poids de carcasse chaude : {beefProduction.warmCarcassWeight} kg + + + {getActions()} ) @@ -51,7 +53,7 @@ export default function BeefProductionCard({ return - + } } diff --git a/frontend/app/src/domains/production/components/PackageLotConfigurator.tsx b/frontend/app/src/domains/production/components/PackageLotConfigurator.tsx index fd1aa9e..f87f7ca 100644 --- a/frontend/app/src/domains/production/components/PackageLotConfigurator.tsx +++ b/frontend/app/src/domains/production/components/PackageLotConfigurator.tsx @@ -1,87 +1,96 @@ import React from 'react' import { useState } from "react" import EditIcon from '@mui/icons-material/Edit'; -import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from "@mui/material" -import { FormContainer, TextFieldElement, useForm } from 'react-hook-form-mui'; +import { Button, ButtonGroup, Dialog, DialogActions, DialogContent, DialogTitle } from "@mui/material" +import { FormContainer, TextFieldElement, TextareaAutosizeElement, useForm } from 'react-hook-form-mui'; /** * * @param {PackageLot} lot * @returns */ -export default function PackageLotConfigurator({packageLot: packageLot, changeCallback: changeCallback}) { +export default function PackageLotConfigurator({ packageLot: packageLot, changeCallback: changeCallback }) { const [quantity, setQuantity] = useState(packageLot.quantity) const [editionPopinOpen, setEditionPopinOpen] = useState(false) - const form = useForm({defaultValues: packageLot}) + const form = useForm({ + defaultValues: { + label: packageLot.label, + description: packageLot.description, + netWeight: packageLot.netWeight, + unitPrice: packageLot.unitPrice + } + }) return
-
-
-
{packageLot.label}
-
{packageLot.description}
-
{packageLot.netWeight} kg
-
{packageLot.unitPrice} € TTC/kg
+
+
+
{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
+
+
{quantity}
+
colis mis en vente
+
{quantity * packageLot.netWeight} kg
+
{quantity * packageLot.netWeight * packageLot.unitPrice} € TTC
-
+
- Modification du colis - - + onClose={cancelForm}> + + Caractéristiques du colis + - - - - - - - + + + + + + + +
@@ -104,6 +113,7 @@ export default function PackageLotConfigurator({packageLot: packageLot, changeCa } function openEditionPopin() { + //form.reset() setEditionPopinOpen(true) } @@ -111,11 +121,22 @@ export default function PackageLotConfigurator({packageLot: packageLot, changeCa setEditionPopinOpen(false) } + function cancelForm(formData) { + form.reset({ + label: packageLot.label, + description: packageLot.description, + netWeight: packageLot.netWeight, + unitPrice: packageLot.unitPrice + }) + closeEditionPopin() + } + function validForm(formData) { packageLot.label = formData.label packageLot.description = formData.description packageLot.unitPrice = formData.unitPrice packageLot.netWeight = formData.netWeight + changeCallback(packageLot) closeEditionPopin() } diff --git a/frontend/app/src/domains/production/components/ProductionCard.tsx b/frontend/app/src/domains/production/components/ProductionCard.tsx index b30d4ba..151fcc2 100644 --- a/frontend/app/src/domains/production/components/ProductionCard.tsx +++ b/frontend/app/src/domains/production/components/ProductionCard.tsx @@ -4,7 +4,7 @@ import BeefProductionCard from "./BeefProductionCard.tsx" export default function ProductionCard({ production: production, showActions: showActions, - setPackageModificationLayoutContent: setPackageModificationLayoutContent + viewBeefProductionCallback: viewBeefProductionCallback }) { switch (production.productionType) { @@ -13,7 +13,7 @@ export default function ProductionCard({ key={production.id} production={production} showActions={showActions} - setPackageModificationLayoutContent={setPackageModificationLayoutContent}> + viewBeefProductionCallback={viewBeefProductionCallback}> default : return <> diff --git a/frontend/app/src/domains/production/views/BeefProductionView.tsx b/frontend/app/src/domains/production/views/BeefProductionView.tsx new file mode 100644 index 0000000..ca2cfa4 --- /dev/null +++ b/frontend/app/src/domains/production/views/BeefProductionView.tsx @@ -0,0 +1,53 @@ +import { Typography, ButtonGroup, Button, Tab, Tabs } from '@mui/material' +import React from 'react' +import { useEffect, useState } from 'react' +import { useKeycloak } from '@react-keycloak/web' +import { ApiBuilder } from '../../../api/ApiBuilder.ts' +import BreedingPropertiesForm from './beefProductionCreator/forms/BreedingPropertiesForm.tsx' +import SlaughterPropertiesForm from './beefProductionCreator/forms/SlaughterPropertiesForm.tsx' +import CuttingPropertiesForm from './beefProductionCreator/forms/CuttingPropertiesForm.tsx' +import TabContext from '@mui/lab/TabContext'; +import TabList from '@mui/lab/TabList'; +import TabPanel from '@mui/lab/TabPanel'; + + +export default function BeefProductionView({ beefProduction: beefProduction, backCallback: backCallback }) { + + const [currentTab, setCurrentTab] = React.useState('1'); + + const changeTab = (event: React.SyntheticEvent, newValue: string) => { + setCurrentTab(newValue); + }; + + + return <> + Abattage bovin + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ +} \ 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.tsx similarity index 100% rename from frontend/app/src/domains/production/views/PackageLotsCreator.js rename to frontend/app/src/domains/production/views/PackageLotsCreator.tsx diff --git a/frontend/app/src/domains/production/views/ProductionsList.tsx b/frontend/app/src/domains/production/views/ProductionsList.tsx index cfef1ba..64d85fd 100644 --- a/frontend/app/src/domains/production/views/ProductionsList.tsx +++ b/frontend/app/src/domains/production/views/ProductionsList.tsx @@ -8,7 +8,9 @@ import { Button, Typography } from "@mui/material" import ProductionCard from '../components/ProductionCard.tsx' -export default function ProductionsList({createBeefProductionCallback: createBeefProductionCallback}) { +export default function ProductionsList({ + createBeefProductionCallback: createBeefProductionCallback, + viewBeefProductionCallback: viewBeefProductionCallback}) { const [productions, setProductions] = useState([]) const { keycloak, initialized } = useKeycloak() @@ -46,7 +48,7 @@ export default function ProductionsList({createBeefProductionCallback: createBee return productions.map(production => + viewBeefProductionCallback={viewBeefProductionCallback}> ) } } \ No newline at end of file diff --git a/frontend/app/src/domains/production/views/beefProductionCreator/BeefProductionCreator.tsx b/frontend/app/src/domains/production/views/beefProductionCreator/BeefProductionCreator.tsx index dbc7247..5933971 100644 --- a/frontend/app/src/domains/production/views/beefProductionCreator/BeefProductionCreator.tsx +++ b/frontend/app/src/domains/production/views/beefProductionCreator/BeefProductionCreator.tsx @@ -10,7 +10,7 @@ import BeefProduction from "viandeendirect_eu/dist/model/BeefProduction.js" import { ApiBuilder } from '../../../../api/ApiBuilder.ts' import { useKeycloak } from '@react-keycloak/web' -import PackageLotsCreator from "../PackageLotsCreator.js" +import PackageLotsCreator from "../PackageLotsCreator.tsx" import BreedingPropertiesForm from "./forms/BreedingPropertiesForm.tsx" import SlaughterPropertiesForm from "./forms/SlaughterPropertiesForm.tsx" import CuttingPropertiesForm from "./forms/CuttingPropertiesForm.tsx" @@ -24,8 +24,7 @@ export default function BeefProductionCreator({ callback }) { const PRODUCTS_STEP = 3 const { keycloak } = useKeycloak() - //const [ activeStep, setActiveStep ] = useState(BREEDING_PROPERTIES_STEP) - const [ activeStep, setActiveStep ] = useState(PRODUCTS_STEP) + const [ activeStep, setActiveStep ] = useState(BREEDING_PROPERTIES_STEP) const [ beefProduction, setBeefProduction] = useState({ productionType: "BeefProduction"}) const [completedSteps, setCompletedSteps] = useState>([]) const apiBuilder = new ApiBuilder() diff --git a/frontend/app/src/domains/production/views/beefProductionCreator/forms/BreedingPropertiesForm.tsx b/frontend/app/src/domains/production/views/beefProductionCreator/forms/BreedingPropertiesForm.tsx index 7496d64..a368881 100644 --- a/frontend/app/src/domains/production/views/beefProductionCreator/forms/BreedingPropertiesForm.tsx +++ b/frontend/app/src/domains/production/views/beefProductionCreator/forms/BreedingPropertiesForm.tsx @@ -4,6 +4,7 @@ import { Button, ButtonGroup } from "@mui/material" import { CheckboxElement, DatePickerElement, FormContainer, SelectElement, SubmitHandler, TextFieldElement, useForm } from 'react-hook-form-mui' import BeefProduction from "viandeendirect_eu/dist/model/BeefProduction" +import dayjs from "dayjs" export default function BreedingPropertiesForm({ beefProduction: beefProduction, @@ -22,7 +23,12 @@ export default function BreedingPropertiesForm({ { id: 'CHAROLAISE', label: 'charolaise' } ] - const form = useForm({defaultValues: beefProduction}) + const form = useForm({defaultValues: { + ...beefProduction, + birthDate: dayjs(beefProduction.birthDate), + slaughterDate: dayjs(beefProduction.slaughterDate), + cuttingDate: dayjs(beefProduction.cuttingDate) + }}) return @@ -57,7 +63,7 @@ export default function BreedingPropertiesForm({
({defaultValues: beefProduction}) - + const form = useForm({defaultValues: { + ...beefProduction, + birthDate: dayjs(beefProduction.birthDate), + slaughterDate: dayjs(beefProduction.slaughterDate), + cuttingDate: dayjs(beefProduction.cuttingDate) + }}) + return
diff --git a/frontend/app/src/domains/production/views/beefProductionCreator/forms/SlaughterPropertiesForm.tsx b/frontend/app/src/domains/production/views/beefProductionCreator/forms/SlaughterPropertiesForm.tsx index d8438de..67e76dd 100644 --- a/frontend/app/src/domains/production/views/beefProductionCreator/forms/SlaughterPropertiesForm.tsx +++ b/frontend/app/src/domains/production/views/beefProductionCreator/forms/SlaughterPropertiesForm.tsx @@ -4,13 +4,20 @@ import { DatePickerElement, FormContainer, SliderElement, TextFieldElement, useF import BeefProduction from "viandeendirect_eu/dist/model/BeefProduction" import { BeefProductionService } from '../../../service/BeefProductionService.ts' +import dayjs from 'dayjs' export default function SlaughterPropertiesForm({ beefProduction: beefProduction, validFormCallback: validFormCallback, cancelFormCallback: cancelFormCallback }) { - const form = useForm({defaultValues: beefProduction}) + const form = useForm({defaultValues: { + ...beefProduction, + birthDate: dayjs(beefProduction.birthDate), + slaughterDate: dayjs(beefProduction.slaughterDate), + cuttingDate: dayjs(beefProduction.cuttingDate) + }}) + const warmCarcassWeight = form.watch('warmCarcassWeight')