- Assert type collection, dataset or file here
+
+ This is a : {collectionItem?.type === 'file' && 'File'}
+ {collectionItem?.type === 'dataset' && 'Dataset'}
+ {collectionItem?.type === 'collection' && 'Collection'}
+
)
})}
diff --git a/src/sections/collection/collection-items-panel/search-panel/SearchPanel.tsx b/src/sections/collection/collection-items-panel/search-panel/SearchPanel.tsx
index 5d3d8861b..3506f55f4 100644
--- a/src/sections/collection/collection-items-panel/search-panel/SearchPanel.tsx
+++ b/src/sections/collection/collection-items-panel/search-panel/SearchPanel.tsx
@@ -1,25 +1,29 @@
import { useState } from 'react'
import { Button, Form } from '@iqss/dataverse-design-system'
import { Search } from 'react-bootstrap-icons'
-import { QueryParamKey, Route } from '../../../Route.enum'
import styles from './SearchPanel.module.scss'
-export const SearchPanel = () => {
- const [searchValue, setSearchValue] = useState('')
+interface SearchPanelProps {
+ initialSearchValue?: string
+ isLoadingCollectionItems: boolean
+ onSubmitSearch: (searchValue: string) => void
+}
+
+export const SearchPanel = ({
+ initialSearchValue = '',
+ isLoadingCollectionItems,
+ onSubmitSearch
+}: SearchPanelProps) => {
+ const [searchValue, setSearchValue] = useState(initialSearchValue)
const handleSubmit = (event: React.FormEvent) => {
event.preventDefault()
const trimmedSearchValue = searchValue.trim()
- if (!trimmedSearchValue) return
-
- console.log({ trimmedSearchValue })
+ const encodedSearchValue = encodeURIComponent(trimmedSearchValue)
- // const encodedSearchValue = encodeURIComponent(trimmedSearchValue)
-
- // const searchParams = new URLSearchParams()
- // searchParams.set(QueryParamKey.QUERY, encodedSearchValue)
+ onSubmitSearch(encodedSearchValue)
}
const handleSearchChange = (event: React.ChangeEvent) => {
@@ -37,7 +41,12 @@ export const SearchPanel = () => {
value={searchValue}
onChange={handleSearchChange}
/>
- } aria-label="Search submit" />
+ }
+ aria-label="Search submit"
+ disabled={isLoadingCollectionItems}
+ />