Skip to content

Commit

Permalink
Pending changes exported from your codespace
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpochat committed Feb 16, 2024
1 parent c510665 commit 9eb993d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 205 deletions.
233 changes: 36 additions & 197 deletions frontend/app/package-lock.json

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

2 changes: 1 addition & 1 deletion frontend/app/src/api/mock/MockApiProductions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class MockApiProductions {
id: 1,
animalIdentifier: '1234',
slaughterDate: '2023-10-01T10:00:00',
animalLiveWeight: 450,
warmCarcassWeight: 450,
animalType: 'BEEF_COW',
lots: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react'
import BeefProductionForm from './views/BeefProductionForm'
import BeefProductionForm from './views/BeefProductionForm.tsx'
import PackageLotsCreator from './views/PackageLotsCreator'
import ProductionsList from './views/ProductionsList.tsx'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function BeefProductionCard({
Abattage le {dayjs(beefProduction.slaughterDate).format('DD/MM/YYYY')}
</Typography>
<Typography component="div">
Poids vif estimé : {beefProduction.animalLiveWeight} kg
Poids de carcasse chaude : {beefProduction.warmCarcassWeight} kg
</Typography>
</CardContent>
{getActions()}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react"
import { useState } from "react"

import { Button, ButtonGroup, Typography, Stepper, Step, StepLabel, StepContent } from "@mui/material"
Expand All @@ -12,7 +13,7 @@ import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'
import 'dayjs/locale/fr'

import { BeefProduction } from 'viandeendirect_eu';
import PackageLotsCreator from "./PackageLotsCreator"
import PackageLotsCreator from "./PackageLotsCreator.js"

export default function BeefProductionForm({ callback }) {

Expand All @@ -31,13 +32,16 @@ export default function BeefProductionForm({ callback }) {
<StepLabel>Définir les caractéristiques de l'abattage</StepLabel>
<StepContent>
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale="fr">
<FormContainer onSuccess={validateProductionProperties} defaultValues={{ "animalLiveWeight": 400 }} >
<FormContainer onSuccess={validateProductionProperties} defaultValues={{ "warmCarcassWeight": 400 }}>
<div className="form">
<div>
<TextFieldElement required validation={{ required: 'Champ obligatoire'}} name="animalIdentifier" label="Numéro d'identification de l'animal" variant="standard" />
</div>
<div>
<SliderElement min={100} max={1000} step={50} required validation={{ required: 'Champ obligatoire'}} name="animalLiveWeight" label="Poids vif" variant="standard" />
<SliderElement value={beefProduction.warmCarcassWeight} onChange={updateProductionWeigth} min={100} max={1000} step={50} required validation={{ required: 'Champ obligatoire'}} name="warmCarcassWeight" label="Poids estimé de l'animal vif" variant="standard" />
<div>
<span>Poids de carcasse chaude : {beefProduction.warmCarcassWeight} kg</span>
</div>
</div>
<div>
<DatePickerElement required validation={{ required: 'Champ obligatoire'}} name="birthDate" label="Date de naissance" variant="standard" />
Expand Down Expand Up @@ -78,13 +82,18 @@ export default function BeefProductionForm({ callback }) {
</Stepper>
</>

function updateProductionWeigth(event, weight) {
console.log(weight)
setBeefProduction({...beefProduction,
warmCarcassWeight: weight
})
}

function validateProductionProperties(productionFormData) {
console.log(productionFormData)
setBeefProduction({...beefProduction,
productionType: "BeefProduction",
animalIdentifier: productionFormData.animalIdentifier,
animalLiveWeight: productionFormData.animalLiveWeight,
warmCarcassWeight: productionFormData.warmCarcassWeight,
birthDate: productionFormData.birthDate,
slaughterDate: productionFormData.slaughterDate,
birthPlace: productionFormData.birthPlace,
Expand Down

0 comments on commit 9eb993d

Please sign in to comment.