diff --git a/src/Pages/Robotics/Robots/index.js b/src/Pages/Robotics/Robots/index.js index 5bac544..42db44c 100644 --- a/src/Pages/Robotics/Robots/index.js +++ b/src/Pages/Robotics/Robots/index.js @@ -226,7 +226,7 @@ export default function Robots() { "PATCH", { robotId: record.id, - name: selectedRobotName, + robotName: selectedRobotName, }, {}, myFetchContentType.JSON, @@ -477,6 +477,8 @@ export default function Robots() { }); break; case ReceivedSSECommands.AddUnauthorizedRobot: + console.log("a", unauthorizedRobotsPaginationPageRef.current); + if (unauthorizedRobotsPaginationPageRef.current === 1) { setUnauthorizedRobots((arr) => { const newArr = [...arr]; @@ -547,8 +549,9 @@ export default function Robots() { // if user is on the last page and the last item is removed, we need to go back one page if ( + body.UnauthorizedRobotsTotalPages > 0 && unauthorizedRobotsPaginationPageRef.current > - body.UnauthorizedRobotsTotalPages + body.UnauthorizedRobotsTotalPages ) { unauthorizedRobotsPaginationPageRef.current--; setUnauthorizedRobotsPaginationPage( @@ -574,7 +577,10 @@ export default function Robots() { setUnauthorizedRobotsTotalPages(body.TotalPages); // if user is on the last page and the last item is removed, we need to go back one page - if (unauthorizedRobotsPaginationPageRef.current > body.TotalPages) { + if ( + body.TotalPages > 0 && + unauthorizedRobotsPaginationPageRef.current > body.TotalPages + ) { unauthorizedRobotsPaginationPageRef.current--; setUnauthorizedRobotsPaginationPage( unauthorizedRobotsPaginationPageRef.current @@ -597,7 +603,10 @@ export default function Robots() { setRobotsTotalPages(body.TotalPages); // if user is on the last page and the last item is removed, we need to go back one page - if (robotsPaginationPageRef.current > body.TotalPages) { + if ( + body.TotalPages > 0 && + robotsPaginationPageRef.current > body.TotalPages + ) { robotsPaginationPageRef.current--; setRobotsPaginationPage(robotsPaginationPageRef.current); } @@ -609,7 +618,7 @@ export default function Robots() { const index = arr.findIndex((x) => x.Id === body.RobotId); if (index !== -1) { - newArr[index].Name = body.Name; + newArr[index].Name = body.RobotName; } return newArr; @@ -715,29 +724,25 @@ export default function Robots() { totalPages={robotsTotalPages} /> - {unauthorizedRobots.length > 0 && ( - <> - - {t("robotics.unauthorizedRobots.header")} - + + {t("robotics.unauthorizedRobots.header")} + - +
- { - setUnauthorizedRobotsPaginationPage(page); - unauthorizedRobotsPaginationPageRef.current = page; - }} - totalPages={unauthorizedRobotsTotalPages} - /> - - )} + { + setUnauthorizedRobotsPaginationPage(page); + unauthorizedRobotsPaginationPageRef.current = page; + }} + totalPages={unauthorizedRobotsTotalPages} + /> ); } diff --git a/src/utils.js b/src/utils.js index de0b73e..b234d21 100644 --- a/src/utils.js +++ b/src/utils.js @@ -111,8 +111,8 @@ export const Constants = { MAX_ROBOTICS_ROBOT_NAME_LENGTH: 30, MIN_USER_API_KEY_NAME_LENGTH: 2, MAX_USER_API_KEY_NAME_LENGTH: 30, - ROBOTICS_ROBOTS_PAGINATION_LIMIT: 10, - ROBOTICS_UNAUTHORIZED_PAGINATION_LIMIT: 10, + ROBOTICS_ROBOTS_PAGINATION_LIMIT: 5, + ROBOTICS_UNAUTHORIZED_PAGINATION_LIMIT: 5, }, MAX_AVATAR_SIZE: 5 * 1024 * 1024, ACCEPTED_AVATAR_FILE_TYPES: [