Skip to content

Commit 87950ec

Browse files
refactor: migrate the findLearning modules into its own service
1 parent 0b96997 commit 87950ec

File tree

3 files changed

+8
-43
lines changed

3 files changed

+8
-43
lines changed

src/pages/communities/[slug]/courses/[course_slug]/learning-modules/[id].tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export const getServerSideProps = wrapper.getServerSideProps((store) => async ({
108108
const communitySlug = params?.slug as string;
109109
const courseSlug = params?.course_slug as string;
110110
const id = params?.id as string;
111-
console.log("me sending data")
112111
const [{ data: community }, { data: course }, { data: learningModule }, translations] = await Promise.all([
113112
store.dispatch(fetchCurrentCommunity({ slug: communitySlug, locale })),
114113
store.dispatch(fetchCourse({ slug: courseSlug, locale })),

src/store/feature/learningModules.slice.ts

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,17 @@ export const learningModulesSlice = createSlice({
3232
},
3333
},
3434
extraReducers: (builder) => {
35-
builder
36-
// .addCase(findLearningModule.fulfilled, (state, action) => {
37-
// state.current = action.payload;
38-
// })
39-
// .addCase(getAllLearningModules.fulfilled, (state, action) => {
40-
// state.list = action.payload;
41-
// })
42-
.addCase(HYDRATE, (state, action) => {
43-
return {
44-
...state,
45-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
46-
//@ts-ignore
47-
...action.payload["learningModules"],
48-
};
49-
});
35+
builder.addCase(HYDRATE, (state, action) => {
36+
return {
37+
...state,
38+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
39+
//@ts-ignore
40+
...action.payload["learningModules"],
41+
};
42+
});
5043
},
5144
});
5245

53-
// export const findLearningModule = createAsyncThunk("learningModules/find", async (id: string) => {
54-
// const { data } = await api().server.get(`learning-modules/${id}`);
55-
// return data;
56-
// });
57-
58-
// export const getAllLearningModules = createAsyncThunk("learningModules/all", async (slug: string) => {
59-
// const { data } = await api().server.get<LearningModule[]>(`courses/${slug}/learning-modules`);
60-
// return data;
61-
// });
62-
6346
export const submitModuleAnswer = createAsyncThunk("learningModules/submitAnswer", async ({ ref, course }: { ref: string; course: string }) => {
6447
await api().client.put("interactive-modules/answer", {
6548
module: ref,

src/store/services/learningModules.service.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ export const learningModulesService = createApi({
3838
method: "PUT",
3939
}),
4040
}),
41-
42-
checkAnswer: builder.query({
43-
query: ({ ref, locale }: { ref: string; locale?: string }) => ({
44-
url: "interactive-modules/check-answer",
45-
body: {
46-
module: ref,
47-
},
48-
headers: {
49-
"accept-language": locale,
50-
},
51-
}),
52-
}),
5341
}),
5442
});
5543

@@ -59,8 +47,3 @@ export const getAllLearningModules = ({ slug, locale }: { slug: string; locale?:
5947

6048
export const submitModuleAnswer = ({ ref, course, locale }: { ref: string; course: string; locale?: string }) =>
6149
learningModulesService.endpoints.submitModuleAnswer.initiate({ ref, course, locale });
62-
63-
export const checkAnswer = ({ ref, locale }: { ref: string; locale?: string }) => {
64-
console.log("the locale from check answer in the learning modules");
65-
return learningModulesService.endpoints.checkAnswer.initiate({ ref, locale });
66-
};

0 commit comments

Comments
 (0)