Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Base Presenter module #144

Merged
merged 4 commits into from
Mar 5, 2023
Merged

Add Base Presenter module #144

merged 4 commits into from
Mar 5, 2023

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Mar 5, 2023

https://eaflood.atlassian.net/browse/WATER-3906
https://eaflood.atlassian.net/browse/WATER-3925

In the sroc-charging-module-api project all our 'presenters' inherited from a base.presenter.js. It contained handy util methods, for example, formatDate() which formats a date as a DD-MMM-YYYY string.

Turns out, we need exactly that when preparing the transaction data to be sent to the charging module API! So, we add a base.presenter.js module for the first time. We'll bring over some of what we have in the sroc-charging-module-api as it has formatDate() and leftPadZeroes() which is what we need right now.

One thing to note is the sroc-charging-module-api was built mainly from classes. We wanted to align more with JavaScript conventions for this project so have stuck to modules. That means our presenters won't inherit the base. Instead, those that need it can just require() it and its functions. We've stuck with the name 'base' though as it's our convention for a base object that is intended to be used by related objects.

https://eaflood.atlassian.net/browse/WATER-3906
https://eaflood.atlassian.net/browse/WATER-3925

In the [sroc-charging-module-api](https://github.com/DEFRA/sroc-charging-module-api) project all our 'presenters' inherited from a `base.presenter.js`. It contained handy util methods, for example, `formatDate()` which formats a date as a `DD-MMM-YYYY` string.

Turns out, we need exactly that when preparing the transaction data to be sent to the charging module API! So, we add a `base.presenter.js` module for the first time. We'll bring over what we have in the **sroc-charging-module-api** as it has what we need including unit tests.

One thing to note is the **sroc-charging-module-api** was built mainly from [classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes). We wanted to align more with JavaScript conventions for this project so have stuck to modules. That means our presenters won't inherit the base. Instead those that need it can just `require()` it and its functions. We've stuck with the name 'base' though as its our convention for a base object that is intended to be used by related objects.
@Cruikshanks Cruikshanks added the enhancement New feature or request label Mar 5, 2023
@Cruikshanks Cruikshanks self-assigned this Mar 5, 2023
Thought we hadn't added it yet in the previous commit. So, add the missing unit test for it.
@Cruikshanks Cruikshanks marked this pull request as ready for review March 5, 2023 09:00
@Cruikshanks Cruikshanks merged commit 4fe82ec into main Mar 5, 2023
@Cruikshanks Cruikshanks deleted the add-base-presenter branch March 5, 2023 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant