Skip to content

Commit

Permalink
Change Catalog to use v2 API endpoint for courses (#1987)
Browse files Browse the repository at this point in the history
* swap catalog to use v2

* tests, lint, fmt
  • Loading branch information
JenniWhitman authored Nov 9, 2023
1 parent 9b85ae4 commit 0256cc4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/public/src/containers/pages/CatalogPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
coursesNextPageSelector,
coursesQuery,
coursesQueryKey
} from "../../lib/queries/courses"
} from "../../lib/queries/catalogCourses"

import {
programsSelector,
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/src/containers/pages/CatalogPage_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ describe("CatalogPage", function() {

sinon.assert.calledWith(
helper.handleRequestStub,
"/api/courses/?page=2&live=true&page__live=true&courserun_is_enrollable=true",
"/api/v2/courses/?page=2&live=true&page__live=true&courserun_is_enrollable=true",
"GET"
)

Expand Down
24 changes: 24 additions & 0 deletions frontend/public/src/lib/queries/catalogCourses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { pathOr } from "ramda"

import { nextState } from "./util"

export const coursesSelector = pathOr(null, ["entities", "courses", "results"])

export const coursesNextPageSelector = pathOr(null, [
"entities",
"courses",
"next"
])

export const coursesQueryKey = "courses"

export const coursesQuery = page => ({
queryKey: coursesQueryKey,
url: `/api/v2/courses/?page=${page}&live=true&page__live=true&courserun_is_enrollable=true`,
transform: json => ({
courses: json
}),
update: {
courses: nextState
}
})

0 comments on commit 0256cc4

Please sign in to comment.