I have used
deep merge to generate the org-configurations. It takes two objects and merges them into one object. When a property is defined in both the objects, the later one will take the precedence. When a property is present only in the first or the second object, it will be copied as it is. Thus when we will write new configurations, we can start that by only defining the most important properties like a slug, host etc. All other properties will be copied from the default. Also, English texts will be taken from the default which means new org config can define text only in their additional language and they will have English + additional language in the website.
For arrays found in objects, it simply takes the array in the latest object so header links, footer links etc are placed in an array and will not copy default links if not provided.
For the frontend part, I've added the following functionalities in the past week:
- Header component is ready
- Footer component is ready
- Added favicon, css_path, title and logo fields to the org-configurations. If they are provided respective properties will be set for the Org. All the org will have a folder inside <root>/client/assets/ by org-slug name, and all the paths in the config file will be relative to that directory. Like for a CSS file stored in `<root>/client/assets/org1/css/index.css` css_path will be `css/index.css`.
- Added a very basic 404 page which is rendered when the org_slug provided in the url is not found.
- Added the registration form with all the functionalities. Things that remain in the registration form:
- All the error are being handled perfectly but I don't know what to do on success. The backend will return auth-token on registration but what should we do on the frontend? Should I auto-login the registered user or redirect to the login page or show a page to confirm email?
- Also, All the text in the form supports multiple languages except for response from the server. What should we do about it?
- Also rendering text and generating asset path is done using the functions, so there won't be a problem if we decide to make some changes in their logic in future :)
You can test the fronted by writing additional config file and starting server using `npm run start`
Register route /:org_slug/register
The build is failing as I'm not done writing the tests yet. Will update the PR with tests soon.
Vivek