feat: add cohort filter in filter action bar (#172)
* feat: add cohort filter in the filter action bar * test: fix posts view fail test cases * test: add test case for cohort filter
This commit is contained in:
@@ -42,6 +42,7 @@ export async function getThreads(
|
||||
flagged,
|
||||
threadType,
|
||||
countFlagged,
|
||||
cohort,
|
||||
} = {},
|
||||
) {
|
||||
const params = snakeCaseObject({
|
||||
@@ -58,6 +59,7 @@ export async function getThreads(
|
||||
author,
|
||||
flagged,
|
||||
countFlagged,
|
||||
groupId: cohort,
|
||||
});
|
||||
const { data } = await getAuthenticatedHttpClient().get(threadsApiUrl, { params });
|
||||
return data;
|
||||
|
||||
@@ -31,6 +31,7 @@ const threadsSlice = createSlice({
|
||||
filters: {
|
||||
status: PostsStatusFilter.ALL,
|
||||
postType: ThreadType.ALL,
|
||||
cohort: '',
|
||||
search: '',
|
||||
},
|
||||
postEditorVisible: false,
|
||||
@@ -146,6 +147,10 @@ const threadsSlice = createSlice({
|
||||
state.filters.postType = payload;
|
||||
state.pages = [];
|
||||
},
|
||||
setCohortFilter: (state, { payload }) => {
|
||||
state.filters.cohort = payload;
|
||||
state.pages = [];
|
||||
},
|
||||
setSearchQuery: (state, { payload }) => {
|
||||
state.filters.search = payload;
|
||||
// Search doesn't work with following
|
||||
@@ -190,6 +195,7 @@ export const {
|
||||
updateThreadAsRead,
|
||||
updateThreadSuccess,
|
||||
setPostsTypeFilter,
|
||||
setCohortFilter,
|
||||
setSortedBy,
|
||||
setStatusFilter,
|
||||
setSearchQuery,
|
||||
|
||||
@@ -122,6 +122,9 @@ export function fetchThreads(courseId, {
|
||||
if (filters.search) {
|
||||
options.textSearch = filters.search;
|
||||
}
|
||||
if (filters.cohort) {
|
||||
options.cohort = filters.cohort;
|
||||
}
|
||||
return async (dispatch) => {
|
||||
try {
|
||||
dispatch(fetchThreadsRequest({ courseId }));
|
||||
|
||||
Reference in New Issue
Block a user