import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n'; import { Alert, Card, Form, Pagination, SearchField, Stack, } from '@openedx/paragon'; import { useCallback, useState } from 'react'; import Loading from '../../generic/Loading'; import AlertError from '../../generic/alert-error'; import { useContentLibraryV2List } from '../data/apiHooks'; import messages from './messages'; import { ContentType } from '../routes'; interface EmptyStateProps { hasSearchQuery: boolean; } const EmptyState = ({ hasSearchQuery }: EmptyStateProps) => ( {hasSearchQuery ? ( ) : ( )} {hasSearchQuery ? ( ) : ( )} ); interface SelectLibraryProps { selectedLibrary: string; setSelectedLibrary: (libraryKey: string) => void; itemType: ContentType; } const SelectLibrary = ({ selectedLibrary, setSelectedLibrary, itemType }: SelectLibraryProps) => { const intl = useIntl(); const [searchQuery, setSearchQuery] = useState(''); const [currentPage, setCurrentPage] = useState(1); const handleSearch = useCallback((search: string) => { setSearchQuery(search); setCurrentPage(1); }, []); const { data, isPending, isError, error, } = useContentLibraryV2List({ page: currentPage, pageSize: 5, search: searchQuery, }); if (isError) { return ; } if (isPending) { return ; } return ( {data.results.length === 0 ? () : ( <> ) => setSelectedLibrary(e.target.value)} value={selectedLibrary} className="mt-4" > {data.results.map((library) => ( setSelectedLibrary(library.id)} className="card-item" > {library.title}} subtitle={`${library.org} / ${library.slug}`} actions={( {' '} )} /> {library.description} ))} > )} ); }; export default SelectLibrary;
{hasSearchQuery ? ( ) : ( )}
{library.description}