I have a backend Rails application that is mainly API endpoints and a front-end application that is mainly being built in React.
Consider the following models:
What I would like to do now is letting the user create a "chart panel" in one step.
I've been wondering for a while now if it is better to:
What would be the ideal approach?
Maybe perform a single POST
request to /panels/
for each panel creating with the following request body (Given that every panel needs a content):
{
dimensions: '',
positions: '',
content: {
type: 'chart', // singleValue, section
// content attributes
}
}
My suggestion is that Panel
should be a centralized component (which parses dimensions and positions) and for each children
you render them according content.type
. You will be able to use a single endpoint and still keep RESTFul standards.