diff --git a/web/src/pages/AllLists/RegistryDetails/ItemsDownloadLabel.tsx b/web/src/pages/AllLists/RegistryDetails/ItemsDownloadLabel.tsx index 839b174..3727764 100644 --- a/web/src/pages/AllLists/RegistryDetails/ItemsDownloadLabel.tsx +++ b/web/src/pages/AllLists/RegistryDetails/ItemsDownloadLabel.tsx @@ -31,18 +31,27 @@ const ItemsDownloadLabel: React.FC<{ registryAddress?: string }> = ({ registryAd useEffect(() => { if (!items || !ref.current) return; setIsPreparing(true); - const flattenedItems = items.flatMap((item) => - item.props.map((prop) => ({ - id: item.id, - status: item.status, - disputed: item.disputed, - propLabel: prop.label, - propDescription: prop.description, - propValue: prop.value, - propIsIdentifier: prop.isIdentifier, - propType: prop.type, - })) - ); + const flattenedItems = items.flatMap((item) => { + let isFirstRow = true; + + return item.props.map((prop) => { + // Create the row with the item details for the first row, otherwise leave them empty + const row = { + id: isFirstRow ? item.id : "", + status: isFirstRow ? item.status : "", + disputed: isFirstRow ? item.disputed : "", + propLabel: prop.label, + propDescription: prop.description, + propValue: prop.value, + propIsIdentifier: prop.isIdentifier, + propType: prop.type, + }; + + isFirstRow = false; + + return row; + }); + }); const csvData = json2csv(flattenedItems); const blob = new Blob([csvData], { type: "text/csv;charset=utf-8;" }); const link = ref.current; diff --git a/yarn.lock b/yarn.lock index f2a0bca..c054290 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4851,6 +4851,7 @@ __metadata: graphql: "npm:^16.8.1" graphql-request: "npm:~6.1.0" jose: "npm:^5.3.0" + json-2-csv: "npm:^5.5.5" lru-cache: "npm:^7.18.3" moment: "npm:^2.30.1" overlayscrollbars: "npm:^2.4.6" @@ -14210,6 +14211,13 @@ __metadata: languageName: node linkType: hard +"deeks@npm:3.1.0": + version: 3.1.0 + resolution: "deeks@npm:3.1.0" + checksum: 4297893cb792bc207b1fdac6090094c8c666669227b385bc69d98ea751294614948288a39a38faa0a44d7045d1bf05eacd188eea7516a1a7d0fee9a7faa34e7d + languageName: node + linkType: hard + "deep-eql@npm:^4.0.1, deep-eql@npm:^4.1.3": version: 4.1.3 resolution: "deep-eql@npm:4.1.3" @@ -14523,6 +14531,13 @@ __metadata: languageName: node linkType: hard +"doc-path@npm:4.1.1": + version: 4.1.1 + resolution: "doc-path@npm:4.1.1" + checksum: 455dd7458d4fa9ec0662fc307c4c3a7112bd0d554b8a6e0e86a6c6554f125727b4f80af430c1038f5d471ed5586c95354260928a31b80e632519480d745af713 + languageName: node + linkType: hard + "docker-compose@npm:0.23.19": version: 0.23.19 resolution: "docker-compose@npm:0.23.19" @@ -20308,6 +20323,16 @@ __metadata: languageName: node linkType: hard +"json-2-csv@npm:^5.5.5": + version: 5.5.5 + resolution: "json-2-csv@npm:5.5.5" + dependencies: + deeks: "npm:3.1.0" + doc-path: "npm:4.1.1" + checksum: 671a72d484349fa2b74e32fb35f02706ea056dee0d840c89b39165ef5f35fddc515b6c1ff9b684689796060af229c7161ce2af5f1d0646bea7694b881187b9d1 + languageName: node + linkType: hard + "json-buffer@npm:3.0.1": version: 3.0.1 resolution: "json-buffer@npm:3.0.1"