Skip to content

Commit

Permalink
Merge pull request #674 from NBISweden/develop
Browse files Browse the repository at this point in the history
Merge bugfix to Production
  • Loading branch information
jhagberg authored Jul 10, 2023
2 parents 64e1367 + 96c1e43 commit 968ea9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
12 changes: 6 additions & 6 deletions frontend/package-lock.json

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

22 changes: 16 additions & 6 deletions frontend/src/individual_sellingform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,25 @@ export function IndividualSellingForm({
buyDateHelperText: string;
}) {
const style = useStyles();

const getMinSellingDate = () => {
const minDate = new Date(
individual.herd_tracking
? individual.herd_tracking[0].date.toString()
: individual.birth_date
);
minDate.setDate(minDate.getDate() + 43);
const herdDate = individual.herd_tracking
? new Date(individual.herd_tracking[0].date.toString())
: null;
const birthDate = new Date(individual.birth_date);

let minDate = null;

if (herdDate && herdDate.getTime() === birthDate.getTime()) {
minDate = new Date(birthDate.setDate(birthDate.getDate() + 43));
} else if (herdDate) {
minDate = new Date(herdDate.setDate(herdDate.getDate() + 1));
} else {
minDate = new Date(birthDate.setDate(birthDate.getDate() + 43));
}
return minDate;
};

return (
<>
<Autocomplete
Expand Down

0 comments on commit 968ea9c

Please sign in to comment.