Skip to content

Commit

Permalink
Ft/advanced-resorces-page-correction (#23)
Browse files Browse the repository at this point in the history
* feat: adding advanced resource page

* fix: importing data instead of fetching them

* refactor: removing unnecessary components

* feat: advanced resources

* feat: add cards elements

* fix : advanced resources

* feat: add arrows

* feat: Informationcard

* feat: add correct cordinate

* feat: making arrow  transparent

* feat: making arrow  transparent

* fix/arrow-draft

* chore: properly handle the arrow linking

* fix: correct errors

* feat: add react flow

* feat: add arrows to the components

* feat: add the custom node

* feat: add reusable components

* feat: add reusable component

* feat:adding advanced resources

* feat: relender data in advanced way

* feat: remove all unnecessary file

* feat: add code refactoring and remove code douplication

* feat: add grid for positioning

* feat: add custom height on card

* feat: add advanced resources page

* feat: adding the dynamic generated classes into safelist in tailwindconfig

* feat: adding advanced resource page

* fix: remove all unused files and update reusable component

* fix: working on comment from yanick

* feat: fixing all reviews about custom data

* feat: refactor advanced resources page

* feat: add case  study page and core tools kits

* fix: code refactor from reviews

* fix: code refactor from nestor's reviews

* fix: code refactor from nestor's reviews

* feat: improve the data parsing and rendering

---------

Co-authored-by: Nestor Ngabonziza <[email protected]>
Co-authored-by: Yannick Musafiri <[email protected]>
  • Loading branch information
3 people authored Apr 12, 2024
1 parent f175a82 commit 2cdcd9d
Show file tree
Hide file tree
Showing 33 changed files with 7,819 additions and 687 deletions.
62 changes: 62 additions & 0 deletions generate-output-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const csvFilePath = './public/data.csv'
const csv = require('csvtojson')
const groupBy = require("lodash.groupby");
const fs = require('fs')
const relations = require('./public/output.json')

function removeEmptyFields(obj) {
return Object.fromEntries(Object.entries(obj).filter(([_, v]) => v));
}

function parseTags(tags) {
const list = tags.split(';').map(el => el.trim()).filter((item) => item).map(line => {
const [key, value] = line.split(':')
return {
key: key.trim(),
value: value?.trim() || value
}
})
const groupedList = groupBy(list, 'key');

const output = {}

Object.keys(groupedList).forEach(key => {
output[key] = groupedList[key].map(item => item.value)
});
return output;
}


async function generateOutputJson() {
// load relationships from json
const relatedData = new Map();
relations.forEach((item) => {
relatedData.set(item['Key'], item);
});

const jsonArray = await csv().fromFile(csvFilePath)
const output = jsonArray.map((item) => {
const manualTags = parseTags(item['Manual Tags'] || "")
const autoTags = parseTags(item['Automatic Tags'] || "")
const relations = relatedData.get(item['Key'])?.PARSED_RELATES_TO || [];
// const tags = relatedData.get(item['Key'])?.PARSED_MANUAL_TAGS || [];
const level = manualTags['CO-DESIGN LEVEL'] || [];
delete manualTags['CO-DESIGN LEVEL'];

manualTags['CO_DESIGN_LEVEL'] = level;
const coreToolKits = manualTags['CORE TOOLKIT'];
if(coreToolKits) {
manualTags['CORE_TOOLKIT'] = coreToolKits;
delete manualTags['CORE TOOLKIT'];
}
return {
...removeEmptyFields(item),
'PARSED_MANUAL_TAGS': manualTags,
'PARSED_AUTOMATIC_TAGS': autoTags,
'PARSED_RELATES_TO': relations
}
});
fs.writeFileSync('./public/data.json', JSON.stringify(output, null, 2))
}

generateOutputJson()
Loading

0 comments on commit 2cdcd9d

Please sign in to comment.