This project was bootstrapped with Create React App.
To run project use:
npm i
npm start
Since sample data looks pretty organised and already contains keys, I decided to normalise it within the application. However I didn't find a quick way to describe kids/records structure with normalizr schemas, so I implemented my own normalise function, with following assumptions:
- Each entity item contains
data
andkids
keys; - Within
data
key might be a various number of key/value pairs (but at least one should represent id); - Every provided id is unique within the same entity type (anyway, it could be easily modified to use combined ids);
kids
key might have a various number of key/value pairs, where:
- key is a child entity name;
- value is an object with
record
key, which contains actual child entities;
- Available schemas are:
- patients - root entity;
- relatives - child entity, hides under
has_relatives
key inkids
; - phones - child entity, hides under
has_phone
key inkids
;
To make data layer I picked Redux (mainly, because it's the tech you're using) and isolate all data connections within two container components RootTable
and ChildTable
.
Here are some notes, about the implementation:
- Since there were no strict specifications on item deleting, I did it the easiest way - by just removing link from the parent element;
- Dealing with deep object structures in JS might be quite painful (checkout this pyramid of doom in rootReducer :)), however I decided not to involve heavy artillery (ImmutableJS), because there's only one reducer;
Considering project size is quite small and design isn't primary task focus, I decided to go on with css, without any extra preprocessors. However, to ensure css extensibility, I picked BEM methodology.
Things I keep in mind but omit for development speed:
- add css modules;
- add css linting tool (like CSSComb);
- add proper styles, according to design (fonts, paddings, button icons, text alignment, etc);
- add proper reset.css;
I used lint scheme shipped with create-react-app
and formatted all the code using prettier.
Unfortunately, there are no actual tests now, since good test coverage requires a lot of time. Let me know if it's a critical task criteria.
This application is WTFPL Licensed.