Skip to content

Commit

Permalink
use new key name
Browse files Browse the repository at this point in the history
  • Loading branch information
podborski committed Jan 9, 2024
1 parent 7d3d0b9 commit 5296741
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/components/DataDisplay/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ export default function Table({ data, globalFilter }: { data: object[]; globalFi
const keys = new Set<string>();
data.forEach((row) => Object.keys(row).forEach((key) => keys.add(key)));

// Remove isMPEG from keys
if (keys.has("isMPEG")) keys.delete("isMPEG");
// Remove isMPEGFFC from keys
if (keys.has("isMPEGFFC")) keys.delete("isMPEGFFC");

// Generate columns
return Array.from(keys).map((header) => {
if (header === "code") {
return columnHelper.accessor(header, {
// eslint-disable-next-line react/no-danger, react/no-unstable-nested-components
cell: (info) =>
info.getValue() && info.row.original.isMPEG ? (
info.getValue() && info.row.original.isMPEGFFC ? (
<a
href={`${process.env.FFC_URL}?query=="${(
info.getValue() as string
Expand Down
6 changes: 3 additions & 3 deletions src/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Specification = {
specification: string;
url: string;
description: string;
MPEG: boolean;
MPEGFFC: boolean;
};

type ReturnType = Record<string, unknown>[];
Expand Down Expand Up @@ -41,7 +41,7 @@ export default async function getData(filename: string): Promise<ReturnType> {
(s: any) => s.specification === record.specification
);
return {
isMPEG: spec?.MPEG ?? false,
isMPEGFFC: spec?.MPEGFFC ?? false,
...record
};
});
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function getAllData(): Promise<ReturnType> {
const records = await getData(path.basename(file, ".csv"));
all.push(
...records.map((record: Record<string, unknown>) => ({
isMPEG: record.isMPEG,
isMPEGFFC: record.isMPEGFFC,
code: record.code,
description: record.description,
specification: record.specification,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function cleanRecords(records: object[], strict: boolean = false)
// Sanitize data
return records.map((record: object) => {
return Object.entries(record).reduce((acc, [key, value]) => {
if (key === "isMPEG") return { ...acc, [key]: value };
if (key === "isMPEGFFC") return { ...acc, [key]: value };
if (!value) return acc;
return {
...acc,
Expand Down

0 comments on commit 5296741

Please sign in to comment.