Skip to content

Commit

Permalink
Merge pull request #1178 from themeum/TUTOR-instructor-query-fix
Browse files Browse the repository at this point in the history
refactor: Refactor instructor list query in CourseBasic.tsx and FormWPEditor.tsx
  • Loading branch information
b-l-i-n-d authored Oct 2, 2024
2 parents fdb8418 + c840a4c commit a4706f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const CourseBasic = () => {

const userList = useUserListQuery(userSearchText);

const instructorListQuery = useInstructorListQuery(String(courseId) ?? '');
const instructorListQuery = useInstructorListQuery(String(courseId) ?? '', isMultiInstructorEnabled);

const convertedCourseInstructors = (courseDetails?.course_instructors || []).map((instructor) => ({
id: instructor.id,
Expand Down
6 changes: 3 additions & 3 deletions assets/react/v3/shared/components/fields/FormWPEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const FormWPEditor = ({
<Show
when={editorUsed.name === 'classic' && !loading}
fallback={
<div css={styles.editorOverlay}>
<div css={styles.editorOverlay(!loading)}>
{loading ? (
<LoadingOverlay />
) : (
Expand Down Expand Up @@ -294,10 +294,10 @@ const styles = {
display: flex;
align-items: center;
`,
editorOverlay: css`
editorOverlay: (isLoading: boolean) => css`
height: 360px;
${styleUtils.flexCenter()};
background-color: ${rgba(colorTokens.background.modal, 0.6)};
background-color: ${isLoading ? rgba(colorTokens.background.modal, 0.6) : 'transparent'};
border-radius: ${borderRadius.card};
`,
editWithButton: css`
Expand Down
3 changes: 2 additions & 1 deletion assets/react/v3/shared/services/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const getInstructorList = (courseId: string) => {
.then((response) => response.data);
};

export const useInstructorListQuery = (courseId: string) => {
export const useInstructorListQuery = (courseId: string, isEnabled: boolean) => {
return useQuery({
queryKey: ['InstructorList', courseId],
queryFn: () =>
Expand All @@ -73,5 +73,6 @@ export const useInstructorListQuery = (courseId: string) => {
avatar_url: item.avatar_url,
}));
}),
enabled: isEnabled,
});
};

0 comments on commit a4706f2

Please sign in to comment.