Skip to content

Commit 6c4d6bb

Browse files
committed
docs: add comments
1 parent a704f05 commit 6c4d6bb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/library-authoring/import-course/stepper/ReviewImportDetails.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ export const ReviewImportDetails = ({ courseId, markAnalysisComplete }: Props) =
120120
]);
121121

122122
useEffect(() => {
123+
// Mark complete to inform parent component of analysis completion.
123124
markAnalysisComplete(!isBlockDataPending);
124125
}, [isBlockDataPending]);
125126

127+
/** Filter unsupported blocks by checking if the block type is in the library's list of unsupported blocks. */
126128
const unsupportedBlockTypes = useMemo(() => {
127129
if (!blockTypes) {
128130
return undefined;
@@ -132,6 +134,7 @@ export const ReviewImportDetails = ({ courseId, markAnalysisComplete }: Props) =
132134
));
133135
}, [blockTypes]);
134136

137+
/** Calculate the total number of unsupported blocks by summing up the count for each block type. */
135138
const totalUnsupportedBlocks = useMemo(() => {
136139
if (!unsupportedBlockTypes) {
137140
return 0;
@@ -140,6 +143,7 @@ export const ReviewImportDetails = ({ courseId, markAnalysisComplete }: Props) =
140143
return unsupportedBlocks;
141144
}, [unsupportedBlockTypes]);
142145

146+
// Fetch unsupported blocks usage_key information from meilisearch index.
143147
const { data: unsupportedBlocksData } = useGetContentHits(
144148
[
145149
`context_key = "${courseId}"`,
@@ -151,11 +155,13 @@ export const ReviewImportDetails = ({ courseId, markAnalysisComplete }: Props) =
151155
'always',
152156
);
153157

158+
// Fetch children blocks for each block in the unsupportedBlocks array.
154159
const { data: unsupportedBlocksChildren } = useGetBlockTypes([
155160
`context_key = "${courseId}"`,
156161
`breadcrumbs.usage_key IN [${unsupportedBlocksData?.hits.map((value) => `"${value.usage_key}"`).join(',')}]`,
157162
], (unsupportedBlocksData?.estimatedTotalHits || 0) > 0);
158163

164+
/** Calculate the total number of unsupported children blocks by summing up the count for each block. */
159165
const totalUnsupportedBlockChildren = useMemo(() => {
160166
if (!unsupportedBlocksChildren) {
161167
return 0;
@@ -164,18 +170,22 @@ export const ReviewImportDetails = ({ courseId, markAnalysisComplete }: Props) =
164170
return unsupportedBlocks;
165171
}, [unsupportedBlocksChildren]);
166172

173+
/** Finally calculate the final number of unsupported blocks by adding parent unsupported and children
174+
unsupported blocks. */
167175
const finalUnssupportedBlocks = useMemo(
168176
() => totalUnsupportedBlocks + totalUnsupportedBlockChildren,
169177
[totalUnsupportedBlocks, totalUnsupportedBlockChildren],
170178
);
171179

180+
/** Calculate total supported blocks by subtracting final unsupported blocks from the total number of blocks */
172181
const totalBlocks = useMemo(() => {
173182
if (!blockTypes) {
174183
return undefined;
175184
}
176185
return Object.values(blockTypes).reduce((total, block) => total + block, 0) - finalUnssupportedBlocks;
177186
}, [blockTypes, finalUnssupportedBlocks]);
178187

188+
/** Calculate total components by excluding those that are chapters, sequential, or vertical. */
179189
const totalComponents = useMemo(() => {
180190
if (!blockTypes) {
181191
return undefined;
@@ -192,6 +202,7 @@ export const ReviewImportDetails = ({ courseId, markAnalysisComplete }: Props) =
192202
) - finalUnssupportedBlocks;
193203
}, [blockTypes, finalUnssupportedBlocks]);
194204

205+
/** Calculate the unsupported block percentage based on the final total blocks and unsupported blocks. */
195206
const unsupportedBlockPercentage = useMemo(() => {
196207
if (!blockTypes || !totalBlocks) {
197208
return 0;

0 commit comments

Comments
 (0)