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

[bug] Don't show "limit-info" div if API returns list for checks #819

Open
pandafy opened this issue Sep 11, 2024 · 2 comments
Open

[bug] Don't show "limit-info" div if API returns list for checks #819

pandafy opened this issue Sep 11, 2024 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers Hacktoberfest

Comments

@pandafy
Copy link
Member

pandafy commented Sep 11, 2024

Describe the bug

If the logged-in user's RadiusGroup does not define any checks, then an empty box is shown where the user's usage is shown.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Setup WiFi Login Pages with OpenWISP RADIUS
  2. Register with a user on WLP
  3. In OpenWISP, change the Radius Group of the user to power-users.
  4. Login to WLP with this user

Expected behavior
The empty div should not appear if the API endpoint returns an empty list for checks.

Add an automated test for this case.

Screenshots
Screenshot from 2024-09-11 22-41-15

@pandafy pandafy added bug Something isn't working good first issue Good for newcomers Hacktoberfest labels Sep 11, 2024
@pandafy
Copy link
Member Author

pandafy commented Sep 11, 2024

I suspect the error to be present here

const response = await axios({
method: "get",
headers: {
"content-type": "application/x-www-form-urlencoded",
Authorization: `Bearer ${userData.auth_token}`,
},
url,
});
options.userChecks = response.data.checks;
if (options.userChecks) {
options.userChecks.forEach((check) => {
if (check.value === String(check.result)) {
isPlanExhausted = true;
}
});
}
if (planExhausted !== isPlanExhausted) {
setPlanExhausted(isPlanExhausted);
if (isPlanExhausted) {
toast.info(t`PLAN_EXHAUSTED_TOAST`);
}
}
if (response.data.plan) {
options.userPlan = response.data.plan;
}
if (!showRadiusUsage) {
options.showRadiusUsage = true;
}
this.setState(options);

@yours7himanshu
Copy link

yours7himanshu commented Oct 30, 2024

@pandafy
This can be solved by checking condition if options.userChecks.length===0
Then we will return a word like item not present etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers Hacktoberfest
Projects
Status: To do (general)
Development

No branches or pull requests

2 participants