richie-education 2.25.0-b2.dev174 → 2.25.0-b2.dev176

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ import { Spinner } from 'components/Spinner';
7
7
  import context from 'utils/context';
8
8
  import { useIntersectionObserver } from 'hooks/useIntersectionObserver';
9
9
  import { CourseListItem, CourseProductRelation } from 'types/Joanie';
10
+ import Banner from 'components/Banner';
10
11
 
11
12
  const messages = defineMessages({
12
13
  loading: {
@@ -33,7 +34,7 @@ interface TeacherDashboardCourseListProps {
33
34
  courseAndProductList?: (CourseListItem | CourseProductRelation)[];
34
35
  isLoadingMore?: boolean;
35
36
  hasMore?: boolean;
36
- isLoading?: boolean;
37
+ isNewSearchLoading?: boolean;
37
38
  }
38
39
 
39
40
  const TeacherDashboardCourseList = ({
@@ -41,7 +42,7 @@ const TeacherDashboardCourseList = ({
41
42
  organizationId,
42
43
  loadMore,
43
44
  courseAndProductList = [],
44
- isLoading = false,
45
+ isNewSearchLoading = false,
45
46
  isLoadingMore = false,
46
47
  hasMore = false,
47
48
  }: TeacherDashboardCourseListProps) => {
@@ -55,27 +56,34 @@ const TeacherDashboardCourseList = ({
55
56
 
56
57
  return (
57
58
  <div
58
- className={classNames('dashboard-course-list', { 'dashboard-course-list--fade': isLoading })}
59
+ className={classNames('dashboard-course-list', {
60
+ 'dashboard-course-list--fade': isNewSearchLoading,
61
+ })}
59
62
  >
60
63
  {titleTranslated && (
61
64
  <h2 className="dashboard-course-list__title dashboard__page_title">{titleTranslated}</h2>
62
65
  )}
63
- {courseAndProductList.length > 0 ? (
66
+
67
+ {courseAndProductList.length > 0 && (
64
68
  <CourseGlimpseList
65
69
  courses={getCourseGlimpseListProps(courseAndProductList, intl, organizationId)}
66
70
  context={context}
67
71
  className="dashboard__course-glimpse-list"
68
72
  />
69
- ) : (
70
- <FormattedMessage {...messages.emptyList} />
71
73
  )}
72
74
 
73
- {isLoadingMore && (
75
+ {(isNewSearchLoading && courseAndProductList.length === 0) || isLoadingMore ? (
74
76
  <Spinner aria-labelledby="loading-courses-data">
75
77
  <span id="loading-courses-data">
76
78
  <FormattedMessage {...messages.loading} />
77
79
  </span>
78
80
  </Spinner>
81
+ ) : (
82
+ courseAndProductList.length === 0 && (
83
+ <div className="dashboard__courses__empty">
84
+ <Banner message={intl.formatMessage(messages.emptyList)} />
85
+ </div>
86
+ )
79
87
  )}
80
88
 
81
89
  {hasMore && (
@@ -60,7 +60,6 @@ const useLearnerCoursesSearch = () => {
60
60
  };
61
61
 
62
62
  return {
63
- query,
64
63
  submitSearch,
65
64
  data: orderAndEnrollmentList,
66
65
  isNewSearchLoading,
@@ -36,11 +36,12 @@ export const DashboardCertificates = () => {
36
36
  }
37
37
  }, [certificates.meta?.pagination?.count]);
38
38
 
39
+ if (certificates.states.error) {
40
+ return <Banner message={certificates.states.error} type={BannerType.ERROR} />;
41
+ }
42
+
39
43
  return (
40
44
  <div className="dashboard-certificates">
41
- {certificates.states.error && (
42
- <Banner message={certificates.states.error} type={BannerType.ERROR} />
43
- )}
44
45
  {certificates.items.length === 0 && certificates.states.fetching ? (
45
46
  <Spinner aria-labelledby="loading-certificates-data">
46
47
  <span id="loading-certificates-data">
@@ -39,9 +39,12 @@ export const DashboardContracts = () => {
39
39
  }
40
40
  }, [count]);
41
41
 
42
+ if (error) {
43
+ return <Banner message={error} type={BannerType.ERROR} />;
44
+ }
45
+
42
46
  return (
43
47
  <div className="dashboard-contracts">
44
- {error && <Banner message={error} type={BannerType.ERROR} />}
45
48
  {contracts.length === 0 && fetching ? (
46
49
  <Spinner aria-labelledby="loading-contract-data">
47
50
  <span id="loading-contract-data">
@@ -32,18 +32,8 @@ const messages = defineMessages({
32
32
 
33
33
  export const DashboardCourses = () => {
34
34
  const intl = useIntl();
35
- const {
36
- data,
37
- query,
38
- isLoadingMore,
39
- isNewSearchLoading,
40
- next,
41
- hasMore,
42
- submitSearch,
43
- count,
44
- error,
45
- } = useLearnerCoursesSearch();
46
-
35
+ const { data, isLoadingMore, isNewSearchLoading, next, hasMore, submitSearch, count, error } =
36
+ useLearnerCoursesSearch();
47
37
  const loadMoreButtonRef = useRef<HTMLButtonElement & HTMLAnchorElement>(null);
48
38
  useIntersectionObserver({
49
39
  target: loadMoreButtonRef,
@@ -61,11 +51,7 @@ export const DashboardCourses = () => {
61
51
  <SearchBar onSubmit={submitSearch} />
62
52
  <SearchResultsCount nbResults={count} />
63
53
  </SearchBar.Container>
64
- {count === 0 && !query && (
65
- <div className="dashboard__courses__empty">
66
- <Banner message={intl.formatMessage(messages.emptyList)} />
67
- </div>
68
- )}
54
+
69
55
  <div
70
56
  className={classNames('dashboard__courses__list', {
71
57
  'dashboard-course-list--fade': isNewSearchLoading,
@@ -82,13 +68,21 @@ export const DashboardCourses = () => {
82
68
  </div>
83
69
  ))}
84
70
  </div>
85
- {(isLoadingMore || isNewSearchLoading) && (
86
- <Spinner aria-labelledby="loading-orders-enrollments">
87
- <span id="loading-orders-enrollments">
71
+
72
+ {(isNewSearchLoading && data.length === 0) || isLoadingMore ? (
73
+ <Spinner aria-labelledby="loading-courses-data">
74
+ <span id="loading-courses-data">
88
75
  <FormattedMessage {...messages.loading} />
89
76
  </span>
90
77
  </Spinner>
78
+ ) : (
79
+ data.length === 0 && (
80
+ <div className="dashboard__courses__empty">
81
+ <Banner message={intl.formatMessage(messages.emptyList)} />
82
+ </div>
83
+ )
91
84
  )}
85
+
92
86
  {hasMore && (
93
87
  <Button
94
88
  onClick={() => next()}
@@ -52,7 +52,7 @@ export const TeacherDashboardCoursesLoader = () => {
52
52
  courseAndProductList={data}
53
53
  loadMore={next}
54
54
  isLoadingMore={isLoadingMore}
55
- isLoading={isNewSearchLoading}
55
+ isNewSearchLoading={isNewSearchLoading}
56
56
  hasMore={hasMore}
57
57
  />
58
58
  </div>
@@ -65,7 +65,7 @@ export const TeacherDashboardOrganizationCourseLoader = () => {
65
65
  courseAndProductList={data}
66
66
  loadMore={next}
67
67
  isLoadingMore={isLoadingMore}
68
- isLoading={isNewSearchLoading}
68
+ isNewSearchLoading={isNewSearchLoading}
69
69
  hasMore={hasMore}
70
70
  />
71
71
  </>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "richie-education",
3
- "version": "2.25.0-b2.dev174",
3
+ "version": "2.25.0-b2.dev176",
4
4
  "description": "A CMS to build learning portals for Open Education",
5
5
  "main": "sandbox/manage.py",
6
6
  "scripts": {