'How to handle changing valid values for UI and REST server

I have a UI developed in react, redux and mui for new version of our app. This UI is used for some process made up of several rounds. A round goes for 6 months. Every round might involve some changes in dropdown values, checkboxes etc shown in UI. Consequently, the valid values stored in database can also change from round to round. In each round, the valid values are stored in the existing database of old version of app. In new version of app, we somehow need to read these values to decide how to render UI (drop down values, checkboxes etc). We are planning to write a REST end point, which we can run anytime (say at the beginning of each round). This REST end point will read from the existing database and create a single json capturing all information about the round and then store this JSON in the database. Before loading any component, react can fetch this JSON from database using another REST end point and then decide how to render the UI.

Q1. Does this approach sounds OK? Or there any other standard / preferred approach to handle such scenarios?

Q2. We have written REST endpoints in spring boot. We used Enums for valid drop down list values (like for nationality, valid values can be Indian, Ukranian, Nepali etc.). But in above case, where valid values can change from round to round, how to define valid values at server side?



Solution 1:[1]

The steps that you mentioned is somehow standard, where things get updated in the backend database and before mounting your round component new data will be rendered. you can have a variable for round and when round changes you can use useEffect for this to fetch the new details.

example:

useEffect(() => {
  if (round) {
   fetchRoundDetails(round); 
  }

}, [round]);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 safwan mansuri