Skip to content

Commit e1eb695

Browse files
authored
certification type (#108)
1 parent 20b592b commit e1eb695

File tree

7 files changed

+45
-24
lines changed

7 files changed

+45
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"homepage": "https://github.com/mitodl/course-search-utils#readme",
3939
"dependencies": {
40-
"@mitodl/open-api-axios": "^2024.5.6",
40+
"@mitodl/open-api-axios": "^2024.6.4",
4141
"axios": "^1.6.7",
4242
"fuse.js": "^7.0.0",
4343
"query-string": "^6.13.1",

src/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,11 @@ export const LEVELS = {
4848
introductory: "Introductory"
4949
}
5050

51+
export const CERTIFICATION_TYPES = {
52+
none: "No Certificate",
53+
completion: "Certificate of Completion",
54+
micromasters: "MicroMasters Credential",
55+
professional: "Professional Certificate"
56+
}
57+
5158
export const BOOLEAN_FACET_NAMES = ["certification", "professional"]

src/facet_display/FacetDisplay.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
BooleanFacets,
1111
BucketWithLabel
1212
} from "./types"
13-
import { LEVELS, DEPARTMENTS } from "../constants"
13+
import { LEVELS, DEPARTMENTS, CERTIFICATION_TYPES } from "../constants"
1414
import MultiFacetGroup from "./MultiFacetGroup"
1515

1616
interface FacetDisplayProps {
@@ -27,6 +27,16 @@ interface FacetDisplayProps {
2727
onFacetChange: (name: string, value: string, isEnabled: boolean) => void
2828
}
2929

30+
export const getCertificationTypeName = (certificationType: string): string => {
31+
if (certificationType in CERTIFICATION_TYPES) {
32+
return CERTIFICATION_TYPES[
33+
certificationType as keyof typeof CERTIFICATION_TYPES
34+
]
35+
} else {
36+
return certificationType
37+
}
38+
}
39+
3040
export const getDepartmentName = (departmentId: string): string => {
3141
if (departmentId in DEPARTMENTS) {
3242
return DEPARTMENTS[departmentId as keyof typeof DEPARTMENTS]

src/facet_display/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface Facets {
5353
resource_type?: string[]
5454
content_feature_type?: string[]
5555
learning_format?: string[]
56+
certification_type?: string[]
5657
}
5758

5859
export interface BooleanFacets {

src/hooks/validation.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
LearningResourcesSearchRetrieveSortbyEnum: SortByEnum,
1010
LearningResourcesSearchRetrieveAggregationsEnum: AggregationsEnum,
1111
LearningResourcesSearchRetrieveLearningFormatEnum: LearningFormatEnum,
12+
CertificationTypeEnum,
1213
ContentFileSearchRetrieveSortbyEnum,
1314
ContentFileSearchRetrieveAggregationsEnum
1415
} = v1
@@ -39,23 +40,24 @@ type QueryParamValidators<ReqParams> = {
3940
}
4041

4142
const resourceSearchValidators: QueryParamValidators<ResourceSearchRequest> = {
42-
resource_type: withinEnum(Object.values(ResourceTypeEnum)),
43-
department: withinEnum(Object.values(DepartmentEnum)),
44-
level: withinEnum(Object.values(LevelEnum)),
45-
platform: withinEnum(Object.values(PlatformEnum)),
46-
offered_by: withinEnum(Object.values(OfferedByEnum)),
47-
sortby: values => withinEnum(Object.values(SortByEnum))(values)[0],
48-
q: first,
49-
topic: identity,
50-
certification: firstBoolean,
51-
professional: firstBoolean,
52-
aggregations: withinEnum(Object.values(AggregationsEnum)),
53-
course_feature: identity,
54-
limit: firstNumber,
55-
offset: firstNumber,
56-
id: numbers,
57-
free: firstBoolean,
58-
learning_format: withinEnum(Object.values(LearningFormatEnum))
43+
resource_type: withinEnum(Object.values(ResourceTypeEnum)),
44+
department: withinEnum(Object.values(DepartmentEnum)),
45+
level: withinEnum(Object.values(LevelEnum)),
46+
platform: withinEnum(Object.values(PlatformEnum)),
47+
offered_by: withinEnum(Object.values(OfferedByEnum)),
48+
sortby: values => withinEnum(Object.values(SortByEnum))(values)[0],
49+
q: first,
50+
topic: identity,
51+
certification: firstBoolean,
52+
professional: firstBoolean,
53+
aggregations: withinEnum(Object.values(AggregationsEnum)),
54+
course_feature: identity,
55+
limit: firstNumber,
56+
offset: firstNumber,
57+
id: numbers,
58+
free: firstBoolean,
59+
learning_format: withinEnum(Object.values(LearningFormatEnum)),
60+
certification_type: withinEnum(Object.values(CertificationTypeEnum))
5961
}
6062

6163
const contentSearchValidators: QueryParamValidators<ContentFileSearchRequest> =

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export {
44
default as FacetDisplay,
55
AvailableFacets,
66
getDepartmentName,
7-
getLevelName
7+
getLevelName,
8+
getCertificationTypeName
89
} from "./facet_display/FacetDisplay"
910
export { default as FilterableFacet } from "./facet_display/FilterableFacet"
1011
export { sanitizeFacets } from "./facet_display/SanitizeFacets"

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,10 @@
762762
dependencies:
763763
make-plural "^7.0.0"
764764

765-
"@mitodl/open-api-axios@^2024.5.6":
766-
version "2024.5.6"
767-
resolved "https://registry.yarnpkg.com/@mitodl/open-api-axios/-/open-api-axios-2024.5.6.tgz#81a0777198da6de54cfbb0968c6fd1f620b11686"
768-
integrity sha512-Z3mmohEeWHI4csKJQlqp5G5szE+6uzE16rX9bSovSfCSui8svpGNyiwlcfsZL7VHMr/6CKT7LYl9I0ydlxvgcw==
765+
"@mitodl/open-api-axios@^2024.6.4":
766+
version "2024.6.4"
767+
resolved "https://registry.yarnpkg.com/@mitodl/open-api-axios/-/open-api-axios-2024.6.4.tgz#e906b764b115665858570f4bbf04bc065a2eeb4f"
768+
integrity sha512-oJ3AwyDTrHOQXairhtqHyBHb9CzIf7En2gV7y6BANDKXhYGXKOVvxqWtvV+1jsCzgGWT6A2nBXYsKuVIGoAP6w==
769769
dependencies:
770770
"@types/node" "^20.11.19"
771771
axios "^1.6.5"

0 commit comments

Comments
 (0)