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

feat(Bonus Pagamenti Digitali): [#175011093,#175011182] Add bancomat entrypoint and stub navigation #2269

Merged

Conversation

fabriziofff
Copy link
Contributor

@fabriziofff fabriziofff commented Oct 7, 2020

Short description

This pr adds an entry point for the add bancomat as payment method and a base template to orchestrate single unit of work.

List of changes proposed in this pull request

  • Changed PaymentMethodsList.tsx in order to accepts paymentMethods?: ReadonlyArray<IPaymentMethod>;
  • Changed AddPaymentMethodScreen.tsx in order to add the add bancomat entry point (only when bpdEnabled and !inPayment.isSome()).
  • Added draft navigation actions, stack and routes for iban workflow.
  • Added WorkUnit to model the information needed to execute a single work unit.
  • Added withResetNavigationStack utility saga to execute another saga and restore the navigation stack after the execution.
  • Added executeWorkUnit, a saga used to execute a single work unit.
  • Added navigationHistorySizeSelector to read from the store the size of the navigation stack.
  • Added bancomatWorkUnit to execute the add bancomat to wallet work unit.
  • Addded addBancomatToWalletGeneric to concat the operation of add bancomat to wallet and goto wallethomescreen (placeholder, will be refined in the next iterations).

@pagopa-github-bot pagopa-github-bot changed the title [#175011093] Add bancomat entrypoint and stub navigation feat(Bonus Pagamenti Digitali): [#175011093] Add bancomat entrypoint and stub navigation Oct 7, 2020
@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented Oct 7, 2020

Affected stories

  • 🌟 #175011093: Come CIT voglio poter selezionare "bancomat" tra la lista dei metodi di pagamento che è possibile aggiungere
  • 🌟 #175011182: Aggiungere lo stack di navigazione per il flusso onboarding bancomat

Generated by 🚫 dangerJS against d7f6946

@codecov-io
Copy link

codecov-io commented Oct 7, 2020

Codecov Report

Merging #2269 into master will decrease coverage by 0.05%.
The diff coverage is 71.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2269      +/-   ##
==========================================
- Coverage   47.92%   47.86%   -0.06%     
==========================================
  Files         543      554      +11     
  Lines       15788    16031     +243     
  Branches     3159     3200      +41     
==========================================
+ Hits         7566     7674     +108     
- Misses       8180     8315     +135     
  Partials       42       42              
Impacted Files Coverage Δ
ts/components/wallet/PaymentMethodsList.tsx 46.00% <50.00%> (-0.94%) ⬇️
ts/sagas/workUnit/index.ts 50.00% <50.00%> (ø)
ts/screens/wallet/AddPaymentMethodScreen.tsx 51.42% <57.14%> (-0.30%) ⬇️
...bancomat/saga/orchestration/addBancomatToWallet.ts 63.63% <63.63%> (ø)
ts/sagas/wallet.ts 19.48% <75.00%> (+0.40%) ⬆️
...onboarding/bancomat/screens/PocBancomatScreen1.tsx 78.94% <78.94%> (ø)
...es/wallet/onboarding/bancomat/navigation/action.ts 100.00% <100.00%> (ø)
...wallet/onboarding/bancomat/navigation/navigator.ts 100.00% <100.00%> (ø)
...es/wallet/onboarding/bancomat/navigation/routes.ts 100.00% <100.00%> (ø)
.../wallet/onboarding/bancomat/store/actions/index.ts 100.00% <100.00%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update acd2b18...d7f6946. Read the comment docs.

@fabriziofff fabriziofff marked this pull request as ready for review October 7, 2020 16:15
@fabriziofff fabriziofff changed the title feat(Bonus Pagamenti Digitali): [#175011093] Add bancomat entrypoint and stub navigation feat(Bonus Pagamenti Digitali): [#175011093.#175011182] Add bancomat entrypoint and stub navigation Oct 7, 2020
@fabriziofff fabriziofff changed the title feat(Bonus Pagamenti Digitali): [#175011093.#175011182] Add bancomat entrypoint and stub navigation feat(Bonus Pagamenti Digitali): [#175011093,#175011182] Add bancomat entrypoint and stub navigation Oct 7, 2020
* the navigation stack return to the screen from which the saga was invoked
* @param g
*/
export function* withResetNavigationStack<T>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be an enhancement?
In this way we can call withResetNavigationStack by passing also the parameters taken by g

export function* withResetNavigationStack<T>(
  g: (...args: any) => Generator<Effect, T>,
  args?: Array<any>
): Generator<Effect, T, any> {
  const currentNavigationStackSize: ReturnType<typeof navigationHistorySizeSelector> = yield select(
    navigationHistorySizeSelector
  );
  const res: T = yield call(() => (args ? g(...args) : g()));
  const newNavigationStackSize: ReturnType<typeof navigationHistorySizeSelector> = yield select(
    navigationHistorySizeSelector
  );
  const deltaNavigation = newNavigationStackSize - currentNavigationStackSize;
  if (deltaNavigation > 1) {
    yield put(navigationHistoryPop(deltaNavigation - 1));
  }
  yield put(NavigationActions.back());
  return res;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea, in case of a saga with some parameters was to use:

  const res: SagaCallReturnType<typeof executeWorkUnit> = yield call(
    withResetNavigationStack,
    () => bancomatWorkUnit("Hola, ¿que tal?")
  );

In order to preserve the type of the arguments of the g method. Using args?: Array<any> I could pass any types and any size of parameters which may not match the signature.
What you think?

@Undermaken Undermaken merged commit c98a4e8 into master Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants