allow more than 400 credential types in drop down while adding new credential

This commit is contained in:
Nikhil Jain
2022-02-23 11:30:55 +05:30
parent fa47e48a15
commit 61323c7f85

View File

@@ -86,14 +86,19 @@ function CredentialAdd({ me }) {
const { data } = await CredentialTypesAPI.read({ page_size: 200 }); const { data } = await CredentialTypesAPI.read({ page_size: 200 });
const credTypes = data.results; const credTypes = data.results;
if (data.next && data.next.includes('page=2')) { if (data.next && data.next.includes('page=2')) {
let pageNo = 2;
/* eslint-disable no-await-in-loop */
do {
const { const {
data: { results }, data: { results },
} = await CredentialTypesAPI.read({ } = await CredentialTypesAPI.read({
page_size: 200, page_size: 200,
page: 2, page: pageNo,
}); });
credTypes.concat(results); credTypes.push(...results);
} pageNo++;
} while (data.count !== credTypes.length);
} /* eslint-enable no-await-in-loop */
const creds = credTypes.reduce((credentialTypesMap, credentialType) => { const creds = credTypes.reduce((credentialTypesMap, credentialType) => {
credentialTypesMap[credentialType.id] = credentialType; credentialTypesMap[credentialType.id] = credentialType;