Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds units for width and height for Pressure Sore #8284

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,41 +110,47 @@ let make = (
<label className="block font-medium text-black text-left">
{str("Width")}
</label>
<input
type_="number"
value={state.width->Belt.Float.toString}
step={0.1}
placeholder="Width (cm)"
className="cui-input-base px-2 py-1"
disabled={previewMode}
onChange={e => {
let value = ReactEvent.Form.target(e)["value"]->Belt.Float.fromString
switch value {
| Some(value) => setState(prev => {...prev, width: value})
| None => setState(prev => {...prev, width: 0.0})
}
}}
/>
<div className="relative mt-1 flex items-center">
<input
type_="number"
value={state.width->Belt.Float.toString}
step={0.1}
placeholder="Width (cm)"
className="cui-input-base px-2 py-1"
disabled={previewMode}
onChange={e => {
let value = ReactEvent.Form.target(e)["value"]->Belt.Float.fromString
switch value {
| Some(value) => setState(prev => {...prev, width: value})
| None => setState(prev => {...prev, width: 0.0})
}
}}
/>
<span className="absolute inset-y-0 right-5 flex items-center pr-3 text-grey-500 font-medium">{str("cm")}</span>
</div>
</div>
<div>
<label className="block font-medium text-black text-left">
{str("Height")}
</label>
<input
type_="number"
value={state.length->Belt.Float.toString}
step={0.1}
placeholder="Length (cm)"
className="cui-input-base px-2 py-1"
disabled={previewMode}
onChange={e => {
let value = ReactEvent.Form.target(e)["value"]->Belt.Float.fromString
switch value {
| Some(value) => setState(prev => {...prev, length: value})
| None => setState(prev => {...prev, length: 0.0})
}
}}
/>
<div className="relative mt-1 flex items-center">
<input
type_="number"
value={state.length->Belt.Float.toString}
step={0.1}
placeholder="Length (cm)"
className="cui-input-base px-2 py-1"
disabled={previewMode}
onChange={e => {
let value = ReactEvent.Form.target(e)["value"]->Belt.Float.fromString
switch value {
| Some(value) => setState(prev => {...prev, length: value})
| None => setState(prev => {...prev, length: 0.0})
}
}}
/>
<span className="absolute inset-y-0 right-5 flex items-center pr-3 text-grey-500 font-medium">{str("cm")}</span>
</div>
</div>
</div>
<div className="flex flex-col sm:flex-row gap-2 mt-2">
Expand Down Expand Up @@ -196,13 +202,13 @@ let make = (
<div className="grid grid-cols-2 items-center gap-4 justify-around mt-4">
<div className="flex flex-col items-center text-center">
<div className="text-black font-bold text-xl">
{str(state.width->Belt.Float.toString)}
{str(`${state.width->Belt.Float.toString} cm`)}
</div>
<div className="text-sm text-secondary-700"> {str("Width")} </div>
</div>
<div className="flex flex-col items-center text-center">
<div className="text-black font-bold text-xl">
{str(state.length->Belt.Float.toString)}
{str(`${state.length->Belt.Float.toString} cm`)}
</div>
<div className="text-sm text-secondary-700"> {str("Length")} </div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ const formatValue = (value: unknown, key?: string): ReactNode => {
}

if (typeof value === "number") {
return value % 1 ? value.toFixed(2) : value;
const formattedValue = value % 1 ? value.toFixed(2) : value;

if (key === "length" || key === "width") {
return `${formattedValue} cm`;
}

return formattedValue;
}

if (typeof value === "string") {
Expand Down Expand Up @@ -74,7 +80,9 @@ const formatValue = (value: unknown, key?: string): ReactNode => {
<span className="text-xs uppercase text-secondary-700">
{key.replaceAll(/_/g, " ")}
</span>
<span className="text-sm font-semibold capitalize text-secondary-700">
<span
className={`text-sm font-semibold text-secondary-700 ${key === "length" || key === "width" ? "" : "capitalize"}`}
>
{formatValue(value, key)}
</span>
</div>
Expand Down
Loading