Initially there are a few customers, defined in data.json
- Created a
DataTable
component as a main UI to manage customers. UI's update likeedit mode
oradd a new row
are managed by component's state. - The change of data of customers is managed by
redux
- The reducer comprises of two parts. First, return the next state after an action dispatched. Second,
persons
object inreducers.ts
is considered a database of all customers. Whenadd
ordelete
happens, thepersons
object gets updated accordingly.
- Move the update of
persons
object in reducer function's third parameterenhancer
as a middleware. It will help split the logic between UI related data - states and the data layer -persons
object. In real cases, it is more likely the customer data is from a web service. - More tests ....