@nualang/nualang-ui-components 0.1.1419 → 0.1.1421

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.
@@ -5,174 +5,12 @@ import useMediaQuery from "@mui/material/useMediaQuery";
5
5
  import ImageSearchIcon from "@mui/icons-material/ImageSearch";
6
6
  import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
7
7
  import ExpandLessIcon from "@mui/icons-material/ExpandLess";
8
- import ForumIcon from "@mui/icons-material/Forum";
8
+ import DoneAllIcon from "@mui/icons-material/DoneAll";
9
9
  import OndemandVideoIcon from "@mui/icons-material/OndemandVideo";
10
- import RoleplaySelection from "../RoleplaySelection/RoleplaySelection";
10
+ import RoleplaySelection, { isRoleplayPlayable, topicHasScenario } from "../RoleplaySelection/RoleplaySelection";
11
11
  import PhraseListSelection from "../PhraseListSelection/PhraseListSelection";
12
- import MenuBookIcon from '@mui/icons-material/MenuBook';
13
12
  import { CardInfoSectionItem } from "../../Cards/CardElements";
14
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
15
- function Exercise({
16
- name,
17
- description,
18
- courseSectionTopicId,
19
- handleCreateGame,
20
- t,
21
- isExerciseSelected,
22
- roleplays,
23
- handleSelectExercise = null,
24
- useCase,
25
- getPhraseLists,
26
- courseId,
27
- sectionId,
28
- topicId,
29
- setIsExerciseSelected,
30
- phrases,
31
- topicName
32
- }) {
33
- const noRoleplays = name.toLowerCase() === "roleplays" && roleplays.length === 0;
34
- const noPhrases = name.toLowerCase() === "phrases" && !phrases?.length && !getPhraseLists;
35
- const [roleplaysOpen, setRoleplaysOpen] = useState(noRoleplays ? false : true);
36
- const [phraseListsOpen, setPhraseListsOpen] = useState(noPhrases ? false : true);
37
- const [hasPhraseListsAvailable, setHasPhraseListsAvailable] = useState(true);
38
- const handlePhraseListsLoaded = count => {
39
- if (count === 0) {
40
- setHasPhraseListsAvailable(false);
41
- setPhraseListsOpen(false);
42
- }
43
- };
44
- const noPhraseListsAvailable = name.toLowerCase() === "phrases" && !hasPhraseListsAvailable;
45
- return /*#__PURE__*/_jsxs(Tooltip, {
46
- title: (name === "roleplays" && noRoleplays ? t("topic_no_roleplays") : "") || (name === "phrases" && noPhrases ? t("topic_no_phrases") : "") || (noPhraseListsAvailable ? t("no_phrase_lists") : ""),
47
- children: [/*#__PURE__*/_jsxs(ListItemButton, {
48
- onClick: () => {
49
- if (name.toLowerCase() === "roleplays") {
50
- setRoleplaysOpen(!roleplaysOpen);
51
- } else if (name.toLowerCase() === "phrases") {
52
- setPhraseListsOpen(!phraseListsOpen);
53
- }
54
- },
55
- display: "flex",
56
- alignItems: "center",
57
- justifyContent: "space-between",
58
- disabled: isExerciseSelected || noRoleplays || noPhrases || noPhraseListsAvailable,
59
- sx: theme => ({
60
- [theme.breakpoints.up("sm")]: {
61
- ml: 3.5
62
- }
63
- }),
64
- children: [name.toLowerCase() === "phrases" && /*#__PURE__*/_jsx(ListItemIcon, {
65
- children: /*#__PURE__*/_jsx(MenuBookIcon, {})
66
- }), name.toLowerCase() === "roleplays" && /*#__PURE__*/_jsx(ListItemIcon, {
67
- children: /*#__PURE__*/_jsx(ForumIcon, {})
68
- }), /*#__PURE__*/_jsx(Box, {
69
- sx: {
70
- width: "100%"
71
- },
72
- children: /*#__PURE__*/_jsx(ListItemText, {
73
- primary: t(name),
74
- secondary: t(description)
75
- })
76
- }), name.toLowerCase() === "phrases" && /*#__PURE__*/_jsx(ListItemIcon, {
77
- children: phraseListsOpen ? /*#__PURE__*/_jsx(ExpandLessIcon, {}) : /*#__PURE__*/_jsx(ExpandMoreIcon, {})
78
- }), name.toLowerCase() === "roleplays" && /*#__PURE__*/_jsx(ListItemIcon, {
79
- children: roleplaysOpen ? /*#__PURE__*/_jsx(ExpandLessIcon, {}) : /*#__PURE__*/_jsx(ExpandMoreIcon, {})
80
- })]
81
- }), name.toLowerCase() === "phrases" && getPhraseLists && /*#__PURE__*/_jsx(Collapse, {
82
- in: phraseListsOpen,
83
- timeout: "auto",
84
- unmountOnExit: true,
85
- children: /*#__PURE__*/_jsx(Box, {
86
- sx: {
87
- ml: 7
88
- },
89
- children: /*#__PURE__*/_jsx(PhraseListSelection, {
90
- getPhraseLists: getPhraseLists,
91
- courseId: courseId,
92
- sectionId: sectionId,
93
- topicId: topicId,
94
- handleCreateGame: handleCreateGame,
95
- courseSectionTopicId: courseSectionTopicId,
96
- t: t,
97
- isExerciseSelected: isExerciseSelected,
98
- setIsExerciseSelected: setIsExerciseSelected,
99
- isExpanded: phraseListsOpen,
100
- onPhraseListsLoaded: handlePhraseListsLoaded,
101
- topicName: topicName
102
- })
103
- })
104
- }), name.toLowerCase() === "roleplays" && /*#__PURE__*/_jsx(Collapse, {
105
- in: roleplaysOpen,
106
- timeout: "auto",
107
- unmountOnExit: true,
108
- children: /*#__PURE__*/_jsx(Box, {
109
- sx: {
110
- ml: 7
111
- },
112
- children: /*#__PURE__*/_jsx(RoleplaySelection, {
113
- roleplays: roleplays,
114
- handleCreateGame: handleCreateGame,
115
- courseSectionTopicId: courseSectionTopicId,
116
- t: t,
117
- isExerciseSelected: isExerciseSelected,
118
- handleSelectExercise: handleSelectExercise,
119
- useCase: useCase,
120
- topicName: topicName
121
- })
122
- })
123
- })]
124
- });
125
- }
126
- function ExerciseList({
127
- t,
128
- exercises = [],
129
- isMember,
130
- courseId,
131
- sectionId,
132
- topicId,
133
- handleCreateGame,
134
- section,
135
- isExerciseSelected,
136
- setIsExerciseSelected,
137
- roleplays,
138
- phrases,
139
- handleSelectExercise,
140
- useCase,
141
- handleStartExercise,
142
- isCreator,
143
- getPhraseLists,
144
- ...otherProps
145
- }) {
146
- const courseSectionTopicId = `${courseId}|${sectionId}|${topicId}`;
147
- return /*#__PURE__*/_jsx(List, {
148
- component: "div",
149
- disablePadding: true,
150
- children: exercises.map((exercise, i) => {
151
- const keyId = `exerc_${courseSectionTopicId}_${exercise}_${i}`;
152
- return /*#__PURE__*/_jsx(Exercise, {
153
- t: t,
154
- ...exercise,
155
- isMember: isMember,
156
- courseSectionTopicId: courseSectionTopicId,
157
- handleCreateGame: handleCreateGame,
158
- section: section,
159
- isExerciseSelected: isExerciseSelected,
160
- setIsExerciseSelected: setIsExerciseSelected,
161
- roleplays: roleplays,
162
- courseId: courseId,
163
- sectionId: sectionId,
164
- topicId: topicId,
165
- phrases: phrases,
166
- handleSelectExercise: handleSelectExercise,
167
- useCase: useCase,
168
- handleStartExercise: handleStartExercise,
169
- isCreator: isCreator,
170
- getPhraseLists: getPhraseLists,
171
- ...otherProps
172
- }, keyId);
173
- })
174
- });
175
- }
176
14
  function Topic({
177
15
  t,
178
16
  courseId,
@@ -183,41 +21,32 @@ function Topic({
183
21
  description,
184
22
  picture,
185
23
  roleplays = [],
186
- bots = [],
187
- completions = [],
188
- isMember,
189
- nextTopic,
190
- prevTopic,
191
- handleViewCourseTopic,
192
24
  isTopicHidden,
193
- completion = {},
194
- sectionIndex,
195
- index,
196
- moveTopic,
197
- onDropSection,
198
- handleCreateGame,
199
- phrases,
200
- section,
201
- isExerciseSelected,
202
- setIsExerciseSelected,
203
- getRoleplays,
204
- handleSelectExercise,
205
- useCase,
206
- handleStartExercise,
207
- isCreator,
208
- courseSectionTopicId,
25
+ sourceType = "phrases",
209
26
  getPhraseLists,
210
- ...otherProps
27
+ selectedListIds,
28
+ onTogglePhraseList,
29
+ onToggleTopicAll,
30
+ selectedScenarioId,
31
+ onSelectScenario,
32
+ courseSectionTopicId
211
33
  }) {
212
34
  const theme = useTheme();
213
35
  const isLargeScreen = useMediaQuery(theme.breakpoints.up("sm"));
214
36
  const topicRef = useRef(null);
215
- const [isExerciseListOpen, setExerciseListOpen] = useState(false);
37
+ const [isOpen, setIsOpen] = useState(false);
216
38
  const [isFocused, setIsFocused] = useState(false);
39
+ // Enriched phrase lists for this topic, reported up by PhraseListSelection
40
+ // once loaded. Drives the subtitle and Select all / Clear all.
41
+ const [loadedLists, setLoadedLists] = useState(null);
42
+ const topicKey = `${courseId}|${sectionId}|${topicId}`;
43
+ const isPhrases = sourceType === "phrases";
44
+ const playableRoleplays = roleplays.filter(isRoleplayPlayable);
217
45
  useEffect(() => {
218
- if (courseSectionTopicId.split("|")[0] === courseId && courseSectionTopicId.split("|")[1] === sectionId && courseSectionTopicId.split("|")[2] === topicId) {
46
+ const [cId, sId, tId] = courseSectionTopicId?.split("|") || [];
47
+ if (cId === courseId && sId === sectionId && tId === topicId) {
219
48
  setIsFocused(true);
220
- setExerciseListOpen(true);
49
+ setIsOpen(true);
221
50
  const element = topicRef.current;
222
51
  if (element) {
223
52
  const dialogContent = document.querySelector(".MuiDialogContent-root");
@@ -233,31 +62,53 @@ function Topic({
233
62
  }
234
63
  }
235
64
  }, [courseSectionTopicId, courseId, sectionId, topicId]);
236
- const exercises = [{
237
- name: "phrases",
238
- description: `phrases_exercise_desc`
239
- }, {
240
- name: "roleplays",
241
- description: `roleplay_exercise_desc`
242
- }];
243
- const toggleExerciseList = () => {
244
- setExerciseListOpen(!isExerciseListOpen);
245
- };
246
- const hasNonEmptyRoleplay = roleplays.some(roleplay => roleplay?.script?.length !== 0 && roleplay?.script?.some(line => line.text !== undefined));
247
- return /*#__PURE__*/_jsx(_Fragment, {
248
- children: /*#__PURE__*/_jsxs(Tooltip, {
249
- title: !phrases?.length && !getPhraseLists ? t("topic_no_phrases") : "",
65
+ if (isTopicHidden) return null;
66
+ // In scenarios mode, drop topics that have no playable scenarios.
67
+ if (!isPhrases && !topicHasScenario(roleplays)) return null;
68
+ const noPhraseSource = isPhrases && !getPhraseLists;
69
+ const noScenarioSource = !isPhrases && playableRoleplays.length === 0;
70
+ const isTopicDisabled = noPhraseSource || noScenarioSource;
71
+ const selectedCount = isPhrases && loadedLists ? loadedLists.filter(l => selectedListIds?.has(l.phraseListId)).length : 0;
72
+ const listCount = loadedLists ? loadedLists.length : null;
73
+ const allSelected = isPhrases && listCount > 0 && selectedCount === listCount;
74
+ let subtitle = description;
75
+ if (isPhrases) {
76
+ if (listCount != null) {
77
+ subtitle = selectedCount ? t("n_of_m_lists_selected", {
78
+ n: selectedCount,
79
+ m: listCount
80
+ }) : t("n_phrase_lists", {
81
+ count: listCount
82
+ });
83
+ }
84
+ } else {
85
+ subtitle = t("n_scenarios", {
86
+ count: playableRoleplays.length
87
+ });
88
+ }
89
+ const showSelectAll = isPhrases && isOpen && listCount > 0;
90
+ return /*#__PURE__*/_jsxs(_Fragment, {
91
+ children: [/*#__PURE__*/_jsx(Tooltip, {
92
+ title: noPhraseSource ? t("topic_no_phrases") : noScenarioSource ? t("topic_no_roleplays") : "",
250
93
  placement: "top",
251
- children: [!isTopicHidden && /*#__PURE__*/_jsxs(ListItemButton, {
94
+ children: /*#__PURE__*/_jsxs(ListItemButton, {
252
95
  ref: topicRef,
253
96
  selected: isFocused,
254
- display: "flex",
255
- alignItems: "center",
256
- justifyContent: "space-between",
257
- onClick: toggleExerciseList,
97
+ onClick: () => setIsOpen(v => !v),
258
98
  "data-cy": "topic-list-item",
259
- disabled: !phrases?.length && !getPhraseLists && !hasNonEmptyRoleplay || isExerciseSelected,
99
+ disabled: isTopicDisabled,
100
+ "aria-expanded": isOpen,
101
+ sx: {
102
+ display: "flex",
103
+ alignItems: "center",
104
+ px: 2,
105
+ py: 1,
106
+ borderRadius: 1
107
+ },
260
108
  children: [isLargeScreen && /*#__PURE__*/_jsx(ListItemAvatar, {
109
+ sx: {
110
+ minWidth: 56
111
+ },
261
112
  children: picture ? /*#__PURE__*/_jsx(Avatar, {
262
113
  src: picture,
263
114
  alt: topicName
@@ -267,35 +118,12 @@ function Topic({
267
118
  })
268
119
  }), /*#__PURE__*/_jsxs(Box, {
269
120
  sx: {
270
- fontWeight: "fontWeightBold",
271
- width: "100%"
121
+ flex: 1,
122
+ minWidth: 0
272
123
  },
273
124
  children: [/*#__PURE__*/_jsx(ListItemText, {
274
- primary: isLargeScreen ? topicName || "" : /*#__PURE__*/_jsxs(_Fragment, {
275
- children: [/*#__PURE__*/_jsx(Box, {
276
- sx: {
277
- mb: 1
278
- },
279
- children: picture ? /*#__PURE__*/_jsx(Avatar, {
280
- src: picture,
281
- alt: topicName
282
- }) : /*#__PURE__*/_jsx(Avatar, {
283
- alt: topicName,
284
- children: /*#__PURE__*/_jsx(ImageSearchIcon, {})
285
- })
286
- }), /*#__PURE__*/_jsx(Typography, {
287
- variant: "body1",
288
- children: topicName || ""
289
- })]
290
- }),
291
- secondary: /*#__PURE__*/_jsx(_Fragment, {
292
- children: /*#__PURE__*/_jsx(Typography, {
293
- variant: "body2",
294
- component: "p",
295
- color: "textSecondary",
296
- children: description
297
- })
298
- })
125
+ primary: topicName || "",
126
+ secondary: subtitle
299
127
  }), videoUrl && /*#__PURE__*/_jsx(Box, {
300
128
  sx: {
301
129
  display: "flex",
@@ -314,40 +142,81 @@ function Topic({
314
142
  })]
315
143
  })
316
144
  })]
145
+ }), showSelectAll && /*#__PURE__*/_jsxs(Box, {
146
+ role: "button",
147
+ onClick: e => {
148
+ e.stopPropagation();
149
+ onToggleTopicAll(loadedLists);
150
+ },
151
+ sx: {
152
+ display: "flex",
153
+ alignItems: "center",
154
+ gap: 0.75,
155
+ px: 1,
156
+ py: 0.5,
157
+ borderRadius: "25px",
158
+ cursor: "pointer"
159
+ },
160
+ children: [/*#__PURE__*/_jsx(DoneAllIcon, {
161
+ sx: {
162
+ fontSize: 18,
163
+ color: "primary.main"
164
+ }
165
+ }), /*#__PURE__*/_jsx(Typography, {
166
+ variant: "body2",
167
+ sx: {
168
+ fontWeight: 600,
169
+ color: "primary.main"
170
+ },
171
+ children: allSelected ? t("clear_all") : t("select_all")
172
+ })]
317
173
  }), /*#__PURE__*/_jsx(ListItemIcon, {
318
- children: isExerciseListOpen ? /*#__PURE__*/_jsx(ExpandLessIcon, {}) : /*#__PURE__*/_jsx(ExpandMoreIcon, {})
319
- })]
320
- }), /*#__PURE__*/_jsx(Collapse, {
321
- in: isExerciseListOpen,
322
- timeout: "auto",
323
- unmountOnExit: true,
324
- children: /*#__PURE__*/_jsx(ExerciseList, {
325
- t: t,
326
- topicInfo: {
327
- topicName,
328
- description
174
+ sx: {
175
+ minWidth: 56,
176
+ justifyContent: "flex-end"
329
177
  },
330
- exercises: exercises,
331
- isMember: isMember,
178
+ children: isOpen ? /*#__PURE__*/_jsx(ExpandLessIcon, {
179
+ sx: {
180
+ color: "text.secondary"
181
+ }
182
+ }) : /*#__PURE__*/_jsx(ExpandMoreIcon, {
183
+ sx: {
184
+ color: "text.secondary"
185
+ }
186
+ })
187
+ })]
188
+ })
189
+ }), /*#__PURE__*/_jsx(Collapse, {
190
+ in: isOpen,
191
+ timeout: "auto",
192
+ unmountOnExit: true,
193
+ children: /*#__PURE__*/_jsxs(Box, {
194
+ sx: {
195
+ ml: 7
196
+ },
197
+ children: [isPhrases && getPhraseLists && /*#__PURE__*/_jsx(PhraseListSelection, {
198
+ getPhraseLists: getPhraseLists,
332
199
  courseId: courseId,
333
200
  sectionId: sectionId,
334
201
  topicId: topicId,
335
- handleCreateGame: handleCreateGame,
336
- section: section,
337
- isExerciseSelected: isExerciseSelected,
338
- setIsExerciseSelected: setIsExerciseSelected,
339
- roleplays: roleplays,
340
- phrases: phrases,
341
- handleSelectExercise: handleSelectExercise,
342
- useCase: useCase,
343
- handleStartExercise: handleStartExercise,
344
- isCreator: isCreator,
345
- getPhraseLists: getPhraseLists,
202
+ courseSectionTopicId: topicKey,
203
+ t: t,
204
+ isExpanded: isOpen,
205
+ selectedListIds: selectedListIds,
206
+ onTogglePhraseList: onTogglePhraseList,
207
+ onPhraseListsLoaded: setLoadedLists,
346
208
  topicName: topicName,
347
- ...otherProps
348
- })
349
- })]
350
- })
209
+ topicVideoUrl: videoUrl
210
+ }), !isPhrases && /*#__PURE__*/_jsx(RoleplaySelection, {
211
+ roleplays: roleplays,
212
+ courseSectionTopicId: topicKey,
213
+ t: t,
214
+ selectedScenarioId: selectedScenarioId,
215
+ onSelectScenario: onSelectScenario,
216
+ topicName: topicName
217
+ })]
218
+ })
219
+ })]
351
220
  });
352
221
  }
353
222
  function Section({
@@ -357,171 +226,85 @@ function Section({
357
226
  sectionName,
358
227
  isHidden,
359
228
  topics = [],
360
- handleCreateGame,
361
- section,
362
- isExerciseSelected,
363
- setIsExerciseSelected,
364
- getRoleplays,
365
- handleSelectExercise,
366
- useCase,
367
- handleStartExercise,
368
- isCreator,
369
- courseSectionTopicId,
229
+ sourceType,
370
230
  getPhraseLists,
371
- ...otherProps
231
+ selectedListIds,
232
+ onTogglePhraseList,
233
+ onToggleTopicAll,
234
+ selectedScenarioId,
235
+ onSelectScenario,
236
+ courseSectionTopicId
372
237
  }) {
373
- const root = {
374
- width: "100%"
375
- };
376
- return /*#__PURE__*/_jsx(_Fragment, {
377
- children: !isHidden && /*#__PURE__*/_jsx(List, {
378
- subheader: /*#__PURE__*/_jsx(ListSubheader, {
379
- disableGutters: true,
380
- disableSticky: true,
381
- component: "div",
382
- id: `${sectionName}-section-list-subheader`,
383
- sx: {
384
- fontWeight: !isExerciseSelected ? "bold" : "normal"
385
- },
386
- children: sectionName
387
- }),
388
- sx: root,
389
- children: topics.map((topic, i) => /*#__PURE__*/_jsx(Topic, {
390
- index: i,
391
- topics: topics,
392
- topicLength: topics.length,
393
- sectionId: sectionId,
394
- handleCreateGame: handleCreateGame,
395
- courseId: courseId,
396
- phrases: topic.phrases,
397
- section: section,
398
- t: t,
399
- ...topic,
400
- ...otherProps,
401
- picture: topic.picture,
402
- isExerciseSelected: isExerciseSelected,
403
- setIsExerciseSelected: setIsExerciseSelected,
404
- getRoleplays: getRoleplays,
405
- handleSelectExercise: handleSelectExercise,
406
- useCase: useCase,
407
- handleStartExercise: handleStartExercise,
408
- isCreator: isCreator,
409
- courseSectionTopicId: courseSectionTopicId,
410
- getPhraseLists: getPhraseLists
411
- }, `${sectionId}-${topic.topicId}`))
412
- })
413
- });
414
- }
415
- function SectionList({
416
- sections = [],
417
- handleFetchTopic,
418
- teachClassrooms,
419
- handleCreateGame,
420
- courseId,
421
- t,
422
- isExerciseSelected,
423
- setIsExerciseSelected,
424
- getRoleplays,
425
- handleSelectExercise,
426
- useCase,
427
- handleStartExercise,
428
- isCreator,
429
- courseSectionTopicId,
430
- getPhraseLists,
431
- ...otherProps
432
- }) {
433
- return /*#__PURE__*/_jsx(_Fragment, {
434
- children: sections.length > 0 ? sections.map((section, index) => {
435
- return /*#__PURE__*/_jsx(Section, {
436
- index: index,
437
- handleFetchTopic: handleFetchTopic,
438
- teachClassrooms: teachClassrooms,
439
- handleCreateGame: handleCreateGame,
440
- courseId: courseId,
441
- t: t,
442
- ...section,
443
- isExerciseSelected: isExerciseSelected,
444
- setIsExerciseSelected: setIsExerciseSelected,
445
- section: section,
446
- getRoleplays: getRoleplays,
447
- handleSelectExercise: handleSelectExercise,
448
- useCase: useCase,
449
- handleStartExercise: handleStartExercise,
450
- isCreator: isCreator,
451
- courseSectionTopicId: courseSectionTopicId,
452
- getPhraseLists: getPhraseLists,
453
- ...otherProps
454
- }, section.sectionId);
455
- }) : /*#__PURE__*/_jsx(Typography, {
456
- children: t("sections_not_found")
457
- })
238
+ if (isHidden) return null;
239
+ // In scenarios mode, only show topics that actually have scenarios; if the
240
+ // whole section has none, hide the section (and its subheader) entirely.
241
+ const visibleTopics = sourceType === "scenarios" ? topics.filter(tp => topicHasScenario(tp.roleplays)) : topics;
242
+ if (visibleTopics.length === 0) return null;
243
+ return /*#__PURE__*/_jsx(List, {
244
+ subheader: /*#__PURE__*/_jsx(ListSubheader, {
245
+ disableGutters: true,
246
+ disableSticky: true,
247
+ component: "div",
248
+ id: `${sectionName}-section-list-subheader`,
249
+ sx: {
250
+ fontWeight: "bold"
251
+ },
252
+ children: sectionName
253
+ }),
254
+ sx: {
255
+ width: "100%"
256
+ },
257
+ children: visibleTopics.map(topic => /*#__PURE__*/_jsx(Topic, {
258
+ sectionId: sectionId,
259
+ courseId: courseId,
260
+ t: t,
261
+ ...topic,
262
+ picture: topic.picture,
263
+ sourceType: sourceType,
264
+ getPhraseLists: getPhraseLists,
265
+ selectedListIds: selectedListIds,
266
+ onTogglePhraseList: onTogglePhraseList,
267
+ onToggleTopicAll: onToggleTopicAll,
268
+ selectedScenarioId: selectedScenarioId,
269
+ onSelectScenario: onSelectScenario,
270
+ courseSectionTopicId: courseSectionTopicId
271
+ }, `${sectionId}-${topic.topicId}`))
458
272
  });
459
273
  }
460
274
  function ExerciseSelection({
461
275
  t = text => text,
462
276
  sections = [],
463
- isMember,
464
- isCreator,
465
277
  courseId,
466
- handleFetchTopic,
467
- isPublic,
468
- handleSwitchChange,
469
278
  isLoading,
470
- teachClassrooms,
471
- handleCreateGame,
472
- isExerciseSelected,
473
- setIsExerciseSelected,
474
- getRoleplays,
475
- handleSelectExercise,
476
- useCase,
477
- handleStartExercise,
478
- courseSectionTopicId,
279
+ sourceType = "phrases",
479
280
  getPhraseLists,
480
- ...otherProps
281
+ selectedListIds,
282
+ onTogglePhraseList,
283
+ onToggleTopicAll,
284
+ selectedScenarioId,
285
+ onSelectScenario,
286
+ courseSectionTopicId
481
287
  }) {
482
- if (isLoading) {
483
- return /*#__PURE__*/_jsx(_Fragment, {
484
- children: /*#__PURE__*/_jsx(SectionList, {
485
- t: t,
486
- sections: sections,
487
- isMember: isMember,
488
- courseId: courseId,
489
- handleFetchTopic: handleFetchTopic,
490
- isCreator: isCreator,
491
- isPublic: isPublic,
492
- handleSwitchChange: handleSwitchChange,
493
- teachClassrooms: teachClassrooms,
494
- handleCreateGame: handleCreateGame,
495
- isExerciseSelected: isExerciseSelected,
496
- setIsExerciseSelected: setIsExerciseSelected,
497
- getRoleplays: getRoleplays,
498
- handleStartExercise: handleStartExercise,
499
- courseSectionTopicId: courseSectionTopicId,
500
- getPhraseLists: getPhraseLists,
501
- ...otherProps
502
- })
288
+ if (!isLoading && sections.length === 0) {
289
+ return /*#__PURE__*/_jsx(Typography, {
290
+ children: t("sections_not_found")
503
291
  });
504
292
  }
505
293
  return /*#__PURE__*/_jsx(_Fragment, {
506
- children: /*#__PURE__*/_jsx(SectionList, {
507
- t: t,
508
- sections: sections,
509
- isMember: isMember,
294
+ children: sections.map(section => /*#__PURE__*/_jsx(Section, {
510
295
  courseId: courseId,
511
- handleFetchTopic: handleFetchTopic,
512
- isCreator: isCreator,
513
- isPublic: isPublic,
514
- handleSwitchChange: handleSwitchChange,
515
- teachClassrooms: teachClassrooms,
516
- handleCreateGame: handleCreateGame,
517
- isExerciseSelected: isExerciseSelected,
518
- setIsExerciseSelected: setIsExerciseSelected,
519
- handleSelectExercise: handleSelectExercise,
520
- useCase: useCase,
521
- courseSectionTopicId: courseSectionTopicId,
296
+ t: t,
297
+ ...section,
298
+ section: section,
299
+ sourceType: sourceType,
522
300
  getPhraseLists: getPhraseLists,
523
- ...otherProps
524
- })
301
+ selectedListIds: selectedListIds,
302
+ onTogglePhraseList: onTogglePhraseList,
303
+ onToggleTopicAll: onToggleTopicAll,
304
+ selectedScenarioId: selectedScenarioId,
305
+ onSelectScenario: onSelectScenario,
306
+ courseSectionTopicId: courseSectionTopicId
307
+ }, section.sectionId))
525
308
  });
526
309
  }
527
310
  export default ExerciseSelection;