boxwise / boxtribute

The code base for Boxtribute 2.0, a humanitarian aid web application making it easy to source, store and distribute goods to people in need in a fair and dignified way
https://www.boxtribute.org/
Apache License 2.0
31 stars 12 forks source link

Handle /qrreader redirect from dropapp #1492

Closed fhenrich33 closed 3 weeks ago

fhenrich33 commented 3 weeks ago

Tests didn't catch that because we mock on tests from the what would be redirected paths. 😬

fhenrich33 commented 3 weeks ago

BUG 2.0 /qrreader/ is broken

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.57%. Comparing base (69a3396) to head (344a044). Report is 3 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1492 +/- ## ========================================== - Coverage 85.59% 85.57% -0.02% ========================================== Files 232 232 Lines 21707 21712 +5 Branches 1914 1914 ========================================== Hits 18580 18580 - Misses 3088 3093 +5 Partials 39 39 ``` | [Flag](https://app.codecov.io/gh/boxwise/boxtribute/pull/1492/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=boxwise) | Coverage Δ | | |---|---|---| | [backend](https://app.codecov.io/gh/boxwise/boxtribute/pull/1492/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=boxwise) | `99.07% <ø> (ø)` | | | [frontend](https://app.codecov.io/gh/boxwise/boxtribute/pull/1492/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=boxwise) | `82.32% <ø> (-0.03%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=boxwise#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

HaGuesto commented 3 weeks ago

Hey @fhenrich33 Thanks for the quick fix from your side. Unfortunately, I found three other cases which we would also have to add in the if statement.

Thus, I would rather like to fix the general problem then doing a quickfix.

What is the general problem?

Any request where the route does NOT start with /bases/<baseId>/* will be redirect to bases/<baseId retrieved with useLoadAndSetGlobalPreferences>/. The reason is that the route is not found in App.tsx and in NotFoundView it redirects then to the route /. When useLoadAndSetGlobalPreferences sets the context of selectedBase it is then redirected to bases/<baseId retrieved with useLoadAndSetGlobalPreferences>/.

How to fix this?

I think the easiest way is to remove all forwarding from dropapp to routes which do not start with /bases/<baseId> and do a bit of a refactor once we get into enabling MultiBase access. I will take care of this in dropapp.

HaGuesto commented 3 weeks ago

Could you quickly check though all navigate instances and other redirects if the urls always start with bases/<currentBaseId>? @fhenrich33

fhenrich33 commented 3 weeks ago

Could you quickly check though all navigate instances and other redirects if the urls always start with bases/<currentBaseId>? @fhenrich33

Will do! Please let me know if there's something else I can help with regarding this.

fhenrich33 commented 3 weeks ago

@HaGuesto

If you search all instances of navigate( with match case on (Alt + C on VSCode), you will find that all but the instances bellow navigates to bases/<currentBaseId>/*:

// front/src/providers/Auth0ProviderWithHistory.tsx
// line 14

navigate(appState?.returnTo || window.location.pathname);
// front/src/views/Transfers/TransferAgreementOverview/TransferAgreementOverviewView.tsx
// lines 103, 127

onRightButtonClick = () => navigate("create");
// front/src/components/Table/Table.tsx
// line 21

onClick={() => navigate(row.original.href)}