-
Notifications
You must be signed in to change notification settings - Fork 5
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
receivable types: fetch beyond page limit #534
Conversation
Sorting the receivable types by name in the saga does not work. I think the solution is to sort the choices in the select component. |
Should this PR be reviewed yet because it is in the draft phase, or after the sorting is added? |
Great. In my opinion this should be merged in addition to #749 in the API repo, to fix the issue now, and be future-proof if more than 50 are added. |
@henrinie-nc what do you think? |
src/leaseCreateCharge/saga.ts
Outdated
}, | ||
bodyAsJson | ||
} = yield call(fetchReceivableTypes); | ||
while (typeof nextUrl === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this enough of a check to see whether to continue? Maybe something else could be checked to ensure it doesn't end up in infinite loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are more pages, bodyAsJson.next
will be a string that contains the URL. If there are no pages left, bodyAsJson.next
will be null.
In all cases of the switch case below, the nextUrl will be either a string (should continue), or null (should stop). If there is an error in the call(fetchRecceivableTypes, nextUrl)
line, the error is caught and nextUrl is again set to null, just in case even though we are out of the loop by then.
The condition could also be (nextUrl !== null)
, but it should achieve the same thing.
src/leaseCreateCharge/saga.ts
Outdated
@@ -44,7 +44,7 @@ function* fetchReceivableTypesSaga(): Generator<any, any, any> { | |||
switch (statusCode) { | |||
case 200: | |||
allReceivableTypes.push(...bodyAsJson.results); | |||
nextUrl = bodyAsJson.next; | |||
nextUrl = bodyAsJson.next || null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some value in bodyAsJson.next
that is not the next URL, or already null if there are no more receivable types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just thought the value is null
already, if there's no more data coming from backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If what Juho says is correct then the or is a bit rendundant right?
3153632
to
af6c91b
Compare
af6c91b
to
c86e1b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
The default limit for receivable_type/ request is 30, but there are more receivable types for AKV than 30. This change makes the request in the mvj-ui to make several requests in order to get all the available receivable types for the given service unit.