1
+ /* eslint-disable react/require-default-props */
1
2
import React , { useContext } from 'react' ;
2
3
import { useParams } from 'react-router' ;
3
4
import { FormattedMessage } from '@edx/frontend-platform/i18n' ;
@@ -10,27 +11,37 @@ import messages from './messages';
10
11
import { LibraryContext } from './common/context' ;
11
12
import { useContentLibrary } from './data/apiHooks' ;
12
13
13
- export const NoComponents = ( ) => {
14
+ type NoSearchResultsProps = {
15
+ searchType ?: 'collection' | 'component' ,
16
+ } ;
17
+
18
+ export const NoComponents = ( { searchType = 'component' } : NoSearchResultsProps ) => {
14
19
const { openAddContentSidebar } = useContext ( LibraryContext ) ;
15
20
const { libraryId } = useParams ( ) ;
16
21
const { data : libraryData } = useContentLibrary ( libraryId ) ;
17
22
const canEditLibrary = libraryData ?. canEditLibrary ?? false ;
18
23
19
24
return (
20
25
< Stack direction = "horizontal" gap = { 3 } className = "mt-6 justify-content-center" >
21
- < FormattedMessage { ...messages . noComponents } />
26
+ { searchType === 'collection'
27
+ ? < FormattedMessage { ...messages . noCollections } />
28
+ : < FormattedMessage { ...messages . noComponents } /> }
22
29
{ canEditLibrary && (
23
30
< Button iconBefore = { Add } onClick = { ( ) => openAddContentSidebar ( ) } >
24
- < FormattedMessage { ...messages . addComponent } />
31
+ { searchType === 'collection'
32
+ ? < FormattedMessage { ...messages . addCollection } />
33
+ : < FormattedMessage { ...messages . addComponent } /> }
25
34
</ Button >
26
35
) }
27
36
</ Stack >
28
37
) ;
29
38
} ;
30
39
31
- export const NoSearchResults = ( ) => (
32
- < Stack direction = "horizontal" gap = { 3 } className = "mt-6 justify-content-center" >
33
- < FormattedMessage { ...messages . noSearchResults } />
40
+ export const NoSearchResults = ( { searchType = 'component' } : NoSearchResultsProps ) => (
41
+ < Stack direction = "horizontal" gap = { 3 } className = "my-6 justify-content-center" >
42
+ { searchType === 'collection'
43
+ ? < FormattedMessage { ...messages . noSearchResultsCollections } />
44
+ : < FormattedMessage { ...messages . noSearchResults } /> }
34
45
< ClearFiltersButton variant = "primary" size = "md" />
35
46
</ Stack >
36
47
) ;
0 commit comments