Skip to content

Commit

Permalink
update the getCSV method to fix the column mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
pengyin-shan committed Nov 22, 2024
1 parent a0735e9 commit 7d89f68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/components/shared/getCSVData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ const getCSVData = (headerGroups, data) => {
if (!data || !data.length) {
return [];
}
const headers = headerGroups[0].headers;
const csvData = [
headerGroups[0].headers.map((column) => column.render("Header")),
headers.map((column) => column.render("Header")),
...data.map((row) => {
if (!row) {
return [];
}
return Object.entries(row).map(([key, cell]) => {
return cell || "";
return headers.map((column) => {
const value = row[column.id] || "";
return value;
});
})
];
Expand Down
1 change: 0 additions & 1 deletion src/components/shared/titleii/TitleIIPracticeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ function TitleIIPracticeTable({

const resultData = React.useMemo(() => {
if (!statePerformance[year]) return [];

return statePerformance[year].map((stateData) => {
const stateCode = stateCodes.find((obj) => obj.code === stateData.state);
const stateName = stateCode ? stateCode.name : stateData.state;
Expand Down

0 comments on commit 7d89f68

Please sign in to comment.