diff --git a/src/main/webapp/ui/src/Inventory/Subsample/Fields/Quantity.js b/src/main/webapp/ui/src/Inventory/Subsample/Fields/Quantity.js index c6a8e4066..c9631a24f 100644 --- a/src/main/webapp/ui/src/Inventory/Subsample/Fields/Quantity.js +++ b/src/main/webapp/ui/src/Inventory/Subsample/Fields/Quantity.js @@ -162,12 +162,19 @@ function QuantityField< ); }} > - There {parentSample.subSamplesCount === 2 ? "is" : "are"}{" "} - {parentSample.subSamplesCount - 1} other{" "} - {parentSample.subSamplesCount === 2 - ? parentSample.subSampleAlias.alias - : parentSample.subSampleAlias.plural} - . + {parentSample.subSamplesCount === 1 ? ( + `The parent sample only has one ${parentSample.subSampleAlias.alias}.` + ) : ( + <> + There{" "} + {parentSample.subSamplesCount === 2 ? "is" : "are"}{" "} + {parentSample.subSamplesCount - 1} other{" "} + {parentSample.subSamplesCount === 2 + ? parentSample.subSampleAlias.alias + : parentSample.subSampleAlias.plural} + . + + )} )} diff --git a/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js b/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js index 4f41ba66d..f3d8aab8f 100644 --- a/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js +++ b/src/main/webapp/ui/src/Inventory/components/Fields/Sample.js @@ -6,6 +6,9 @@ import { type Sample } from "../../../stores/definitions/Sample"; import { RecordLink } from "../RecordLink"; import FormField from "../../../components/Inputs/FormField"; import Box from "@mui/material/Box"; +import Link from "@mui/material/Link"; +import Typography from "@mui/material/Typography"; +import NavigateContext from "../../../stores/contexts/Navigate"; export default function SampleField< Fields: { @@ -15,6 +18,8 @@ export default function SampleField< FieldOwner: HasUneditableFields >({ fieldOwner }: {| fieldOwner: FieldOwner |}): Node { const sample = fieldOwner.fieldValues.sample; + const { useNavigate } = React.useContext(NavigateContext); + const navigate = useNavigate(); return ( ( - - - + <> + + + + {sample.globalId && ( + + { + e.preventDefault(); + if (sample.globalId) + navigate( + `/inventory/search?parentGlobalId=${sample.globalId}` + ); + }} + > + {sample.subSamplesCount === 1 ? ( + `The parent sample only has one ${sample.subSampleAlias.alias}.` + ) : ( + <> + There {sample.subSamplesCount === 2 ? "is" : "are"}{" "} + {sample.subSamplesCount - 1} other{" "} + {sample.subSamplesCount === 2 + ? sample.subSampleAlias.alias + : sample.subSampleAlias.plural} + . + + )} + + + )} + )} /> );