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

Fix: numPages in pagination adding camelCaseObject. #9

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/features/Students/StudentsPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MenuIcon } from '@edx/frontend-component-header/dist/Icons';

import { faTrash } from '@fortawesome/free-solid-svg-icons';
import React, { useEffect, useState, useReducer } from 'react';
import { camelCaseObject } from '@edx/frontend-platform';
import {
ActionRow,
Button,
Expand Down Expand Up @@ -44,8 +45,7 @@ const reducer = (state, action) => {
case 'FETCH_REQUEST':
return { ...state, status: RequestStatus.LOADING };
case 'FETCH_SUCCESS': {
const { results, count } = action.payload;
const numPages = count;
const { results, count, numPages } = action.payload;
return {
...state,
status: RequestStatus.SUCCESS,
Expand Down Expand Up @@ -96,7 +96,7 @@ const StudentsPage = () => {
dispatch({ type: 'FETCH_REQUEST' });

try {
const response = await getStudentbyInstitutionAdmin(currentPage, filters);
const response = camelCaseObject(await getStudentbyInstitutionAdmin(currentPage, filters));
dispatch({ type: 'FETCH_SUCCESS', payload: response.data });
} catch (error) {
dispatch({ type: 'FETCH_FAILURE', payload: error });
Expand Down
12 changes: 6 additions & 6 deletions src/features/Students/StudentsTable/_test_/columns.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ describe('getColumns', () => {
] = columns;

expect(nameColumn).toHaveProperty('Header', 'Name');
expect(nameColumn).toHaveProperty('accessor', 'learner_name');
expect(nameColumn).toHaveProperty('accessor', 'learnerName');

expect(emailColumn).toHaveProperty('Header', 'Email');
expect(emailColumn).toHaveProperty('accessor', 'learner_email');
expect(emailColumn).toHaveProperty('accessor', 'learnerEmail');

expect(courseNameColumn).toHaveProperty('Header', 'Class Name');
expect(courseNameColumn).toHaveProperty('accessor', 'ccx_name');
expect(courseNameColumn).toHaveProperty('accessor', 'ccxName');

expect(ClassIdColumn).toHaveProperty('Header', 'Class Id');
expect(ClassIdColumn).toHaveProperty('accessor', 'ccx_id');
expect(ClassIdColumn).toHaveProperty('accessor', 'ccxId');

expect(instructorsColumn).toHaveProperty('Header', 'Instructors');
expect(instructorsColumn).toHaveProperty('accessor', 'instructors');
Expand All @@ -39,10 +39,10 @@ describe('getColumns', () => {
expect(createdColumn).toHaveProperty('accessor', 'created');

expect(firstAccessColumn).toHaveProperty('Header', 'First Access');
expect(firstAccessColumn).toHaveProperty('accessor', 'first_access');
expect(firstAccessColumn).toHaveProperty('accessor', 'firstAccess');

expect(lastAccessColumn).toHaveProperty('Header', 'Last Access');
expect(lastAccessColumn).toHaveProperty('accessor', 'last_access');
expect(lastAccessColumn).toHaveProperty('accessor', 'lastAccess');

expect(gradeColumn).toHaveProperty('Header', 'Grade');
expect(gradeColumn).toHaveProperty('accessor', 'grade');
Expand Down
20 changes: 10 additions & 10 deletions src/features/Students/StudentsTable/_test_/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ describe('Student Table', () => {
test('renders StudentsTable with data', () => {
const data = [
{
learner_name: 'Student 1',
learner_email: '[email protected]',
ccx_name: 'CCX 1',
learnerName: 'Student 1',
learnerEmail: '[email protected]',
ccxName: 'CCX 1',
instructors: ['Instructor 1'],
created: 'Fri, 25 Aug 2023 19:01:22 GMT',
first_access: 'Fri, 25 Aug 2023 19:01:23 GMT',
last_access: 'Fri, 25 Aug 2023 20:20:22 GMT',
firstAccess: 'Fri, 25 Aug 2023 19:01:23 GMT',
lastAccess: 'Fri, 25 Aug 2023 20:20:22 GMT',
grade: true,
},
{
learner_name: 'Student 2',
learner_email: '[email protected]',
ccx_name: 'CCX 2',
learnerName: 'Student 2',
learnerEmail: '[email protected]',
ccxName: 'CCX 2',
instructors: ['Instructor 2'],
created: 'Sat, 26 Aug 2023 19:01:22 GMT',
first_access: 'Sat, 26 Aug 2023 19:01:24 GMT',
last_access: 'Sat, 26 Aug 2023 21:22:22 GMT',
firstAccess: 'Sat, 26 Aug 2023 19:01:24 GMT',
lastAccess: 'Sat, 26 Aug 2023 21:22:22 GMT',
grade: false,
},
];
Expand Down
20 changes: 10 additions & 10 deletions src/features/Students/StudentsTable/columns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { Badge, Button } from '@edx/paragon';
const getColumns = props => [
{
Header: 'Name',
accessor: 'learner_name',
accessor: 'learnerName',
},
{
Header: 'Email',
accessor: 'learner_email',
accessor: 'learnerEmail',
},
{
Header: 'Class Name',
accessor: 'ccx_name',
accessor: 'ccxName',
},
{
Header: 'Class Id',
accessor: 'ccx_id',
accessor: 'ccxId',
disableSortBy: true,
},
{
Expand All @@ -40,19 +40,19 @@ const getColumns = props => [
},
{
Header: 'First Access',
accessor: 'first_access',
accessor: 'firstAccess',
Cell: ({ row }) => (
row.values.first_access
? new Date(row.values.first_access).toUTCString()
row.values.firstAccess
? new Date(row.values.firstAccess).toUTCString()
: ''
),
},
{
Header: 'Last Access',
accessor: 'last_access',
accessor: 'lastAccess',
Cell: ({ row }) => (
row.values.last_access
? new Date(row.values.last_access).toUTCString()
row.values.lastAccess
? new Date(row.values.lastAccess).toUTCString()
: ''
),
},
Expand Down