refactor: change customParams to requestParams
This commit is contained in:
@@ -57,7 +57,7 @@ describe('<CardItem />', () => {
|
||||
|
||||
it('should render correct links for non-library course pagination', () => {
|
||||
const props = studioHomeMock.archivedCourses[0];
|
||||
const { getByText, getByTestId } = render(<RootWrapper {...props} isPaginationEnabled />);
|
||||
const { getByText, getByTestId } = render(<RootWrapper {...props} isPaginated />);
|
||||
const courseTitleLink = getByText(props.displayName);
|
||||
expect(courseTitleLink).toHaveAttribute('href', `${getConfig().STUDIO_BASE_URL}${props.url}`);
|
||||
const dropDownMenu = getByTestId('toggle-dropdown');
|
||||
|
||||
@@ -26,7 +26,7 @@ const CardItem = ({
|
||||
run,
|
||||
isLibraries,
|
||||
courseKey,
|
||||
isPaginationEnabled,
|
||||
isPaginated,
|
||||
url,
|
||||
cmsLink,
|
||||
}) => {
|
||||
@@ -59,7 +59,7 @@ const CardItem = ({
|
||||
)}
|
||||
subtitle={subtitle}
|
||||
actions={showActions && (
|
||||
isPaginationEnabled ? (
|
||||
isPaginated ? (
|
||||
<Dropdown>
|
||||
<Dropdown.Toggle
|
||||
as={IconButton}
|
||||
@@ -109,7 +109,7 @@ const CardItem = ({
|
||||
|
||||
CardItem.defaultProps = {
|
||||
isLibraries: false,
|
||||
isPaginationEnabled: false,
|
||||
isPaginated: false,
|
||||
courseKey: '',
|
||||
rerunLink: '',
|
||||
lmsLink: '',
|
||||
@@ -129,7 +129,7 @@ CardItem.propTypes = {
|
||||
url: PropTypes.string.isRequired,
|
||||
isLibraries: PropTypes.bool,
|
||||
courseKey: PropTypes.string,
|
||||
isPaginationEnabled: PropTypes.bool,
|
||||
isPaginated: PropTypes.bool,
|
||||
};
|
||||
|
||||
export default injectIntl(CardItem);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const getStudioHomeData = state => state.studioHome.studioHomeData;
|
||||
export const getLoadingStatuses = (state) => state.studioHome.loadingStatuses;
|
||||
export const getSavingStatuses = (state) => state.studioHome.savingStatuses;
|
||||
export const getStudioHomeCoursesParams = (state) => state.studioHome.studioHomeCoursesCustomParams;
|
||||
export const getStudioHomeCoursesParams = (state) => state.studioHome.studioHomeCoursesRequestParams;
|
||||
|
||||
@@ -17,7 +17,7 @@ const slice = createSlice({
|
||||
deleteNotificationSavingStatus: '',
|
||||
},
|
||||
studioHomeData: {},
|
||||
studioHomeCoursesCustomParams: {
|
||||
studioHomeCoursesRequestParams: {
|
||||
currentPage: 1,
|
||||
},
|
||||
},
|
||||
@@ -52,7 +52,7 @@ const slice = createSlice({
|
||||
},
|
||||
updateStudioHomeCoursesCustomParams: (state, { payload }) => {
|
||||
const { currentPage } = payload;
|
||||
state.studioHomeCoursesCustomParams.currentPage = currentPage;
|
||||
state.studioHomeCoursesRequestParams.currentPage = currentPage;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('updateStudioHomeCoursesCustomParams action', () => {
|
||||
deleteNotificationSavingStatus: '',
|
||||
},
|
||||
studioHomeData: {},
|
||||
studioHomeCoursesCustomParams: {
|
||||
studioHomeCoursesRequestParams: {
|
||||
currentPage: 1,
|
||||
},
|
||||
};
|
||||
@@ -25,10 +25,10 @@ describe('updateStudioHomeCoursesCustomParams action', () => {
|
||||
expect(result).toEqual(initialState);
|
||||
});
|
||||
|
||||
it('should update the currentPage in studioHomeCoursesCustomParams', () => {
|
||||
it('should update the currentPage in studioHomeCoursesRequestParams', () => {
|
||||
const newState = {
|
||||
...initialState,
|
||||
studioHomeCoursesCustomParams: {
|
||||
studioHomeCoursesRequestParams: {
|
||||
currentPage: 2,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
fetchCourseDataSuccessV2,
|
||||
} from './slice';
|
||||
|
||||
function fetchStudioHomeData(search, hasHomeData, customParams = {}, isPaginationEnabled = false) {
|
||||
function fetchStudioHomeData(search, hasHomeData, requestParams = {}, isPaginationEnabled = false) {
|
||||
return async (dispatch) => {
|
||||
dispatch(updateLoadingStatuses({ studioHomeLoadingStatus: RequestStatus.IN_PROGRESS }));
|
||||
dispatch(updateLoadingStatuses({ courseLoadingStatus: RequestStatus.IN_PROGRESS }));
|
||||
@@ -33,7 +33,7 @@ function fetchStudioHomeData(search, hasHomeData, customParams = {}, isPaginatio
|
||||
}
|
||||
try {
|
||||
if (isPaginationEnabled) {
|
||||
const coursesData = await getStudioHomeCoursesV2(search || '', customParams);
|
||||
const coursesData = await getStudioHomeCoursesV2(search || '', requestParams);
|
||||
dispatch(fetchCourseDataSuccessV2(coursesData));
|
||||
} else {
|
||||
const coursesData = await getStudioHomeCourses(search || '');
|
||||
|
||||
@@ -15,7 +15,7 @@ export const initialState = {
|
||||
deleteNotificationSavingStatus: '',
|
||||
},
|
||||
studioHomeData: {},
|
||||
studioHomeCoursesCustomParams: {
|
||||
studioHomeCoursesRequestParams: {
|
||||
currentPage: 1,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user