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>
);
}
Loading