In the process of building out the VoirDire App for our client, we ran into an interesting problem. How do we enforce licensing requirements in a cross-cutting way, without tediously identifying every area in the UI where the user might take an action that they were not allowed to take? The client’s licensing requirements were:
On the free plan, a user can have 1 trial, up to 20 jurors, and up to 20 stored questions. With a standard license ($30), up to trials, 100 jurors, and 100 stored questions. An unlimited license ($50) removes all limitations. Since we are using Redux to handle application state, calculating the remaining jurors, trials, etc. in the license can be done with a selector. The selector accepts the entire redux state and the user’s current license key, then calculates whether they are over or under the limit.
...