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

Hide N/A and null values in event log #8376 #8381

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ interface IProps {
* object - array, date
*/
const formatValue = (value: unknown, key?: string): ReactNode => {
if (value == null) {
return "N/A";
if (value == null || value == "N/A") {
return null;
}

if (typeof value === "boolean") {
Expand All @@ -25,7 +25,7 @@ const formatValue = (value: unknown, key?: string): ReactNode => {
const trimmed = value.trim().replaceAll(/_/g, " ");

if (trimmed === "") {
return "Empty";
return null;
}

if (!isNaN(Number(trimmed))) {
Expand Down Expand Up @@ -88,16 +88,19 @@ export default function GenericEvent(props: IProps) {
const { t } = useTranslation();
return (
<div className="flex w-full flex-col gap-4 rounded-lg border border-secondary-400 p-4 @container">
{Object.entries(props.values).map(([key, value]) => (
<div className="flex w-full flex-col items-start gap-2">
<span className="text-xs capitalize text-secondary-700">
{t(key).replaceAll(/_/g, " ")}
</span>
<span className="break-all text-sm font-semibold text-secondary-700">
{formatValue(value, key)}
</span>
</div>
))}
{Object.entries(props.values)
.map(([key, value]) => ({ key, value: formatValue(value, key) }))
.filter(({ value }) => value != null)
.map(({ key, value }) => (
<div key={key} className="flex w-full flex-col items-start gap-2">
<span className="text-xs capitalize text-secondary-700">
{t(key).replaceAll(/_/g, " ")}
</span>
<span className="break-all text-sm font-semibold text-secondary-700">
{value}
</span>
</div>
))}
</div>
);
}
38 changes: 23 additions & 15 deletions src/Components/Facility/Consultations/NeurologicalTables.tsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has nothing to do with Event Logs.
You might want to have a look at this file instead: https://github.com/coronasafe/care_fe/blob/develop/src/Components/Facility/ConsultationDetails/Events/GenericEvent.tsx

Nithin9585 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,30 @@ const DataTable = (props: any) => {
</div>
<div className="flex flex-row overflow-x-auto">
{data.map((x: any, i: any) => {
return (
<div
key={`${title}_${i}`}
className="flex flex-col divide-x divide-secondary-200"
>
<div className="w-20 bg-secondary-50 px-2 py-3 text-center text-xs font-medium leading-4 text-secondary-900">
{x.date}
</div>
<div className="whitespace-nowrap bg-white px-2 py-4 text-center text-sm leading-5 text-secondary-900">
{x.left}
</div>
<div className="whitespace-nowrap bg-white px-2 py-4 text-center text-sm leading-5 text-secondary-900">
{x.right}
if (
x.left !== "N/A" &&
x.left !== null &&
x.right !== "N/A" &&
x.right !== null
) {
return (
<div
key={`${title}_${i}`}
className="flex flex-col divide-x divide-secondary-200"
>
<div className="w-20 bg-secondary-50 px-2 py-3 text-center text-xs font-medium leading-4 text-secondary-900">
{x.date}
</div>
<div className="whitespace-nowrap bg-white px-2 py-4 text-center text-sm leading-5 text-secondary-900">
{x.left}
</div>
<div className="whitespace-nowrap bg-white px-2 py-4 text-center text-sm leading-5 text-secondary-900">
{x.right}
</div>
</div>
</div>
);
);
}
return null;
})}
</div>
</div>
Expand Down
Loading