-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(studies): SKFP-1387 Add table and search
- Loading branch information
GaelleA
committed
Dec 5, 2024
1 parent
f440213
commit f653e94
Showing
11 changed files
with
295 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.pageContent { | ||
width: 100%; | ||
} | ||
.pageContent .tableWrapper { | ||
width: 100%; | ||
gap: 0 !important; | ||
} | ||
.pageContent .title { | ||
margin: 0; | ||
} | ||
.pageContent .label { | ||
margin-bottom: 8px; | ||
} | ||
.pageContent .inputContainer { | ||
display: flex; | ||
gap: 8px; | ||
margin-bottom: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { useEffect, useState } from 'react'; | ||
import intl from 'react-intl-universal'; | ||
import ProLabel from '@ferlab/ui/core/components/ProLabel'; | ||
import ProTable from '@ferlab/ui/core/components/ProTable'; | ||
import GridCard from '@ferlab/ui/core/view/v2/GridCard'; | ||
import { Input, Space, Typography } from 'antd'; | ||
import { getColumns, TABLE_ID } from 'views/PublicStudies/utils'; | ||
|
||
import { useGlobals } from 'store/global'; | ||
import { getProTableDictionary } from 'utils/translation'; | ||
|
||
import styles from './index.module.css'; | ||
|
||
const { Title } = Typography; | ||
|
||
const PageContent = () => { | ||
const [searchValue, setSearchValue] = useState(''); | ||
|
||
const { stats, isFetchingStats } = useGlobals(); | ||
const { studiesStatistics = [] } = stats || {}; | ||
|
||
const [filteredStudies, setFilteredStudies] = useState(studiesStatistics); | ||
|
||
useEffect(() => { | ||
setFilteredStudies(studiesStatistics); | ||
}, [studiesStatistics]); | ||
|
||
const searchPrescription = (value: any) => { | ||
if (value?.target?.value) { | ||
const searchValue = value.target.value; | ||
setSearchValue(searchValue); | ||
|
||
const filteredValues = studiesStatistics.filter((study) => | ||
study.study_name.toLowerCase().includes(searchValue.toLowerCase()), | ||
); | ||
setFilteredStudies(filteredValues); | ||
} else { | ||
setSearchValue(''); | ||
setFilteredStudies(studiesStatistics); | ||
} | ||
}; | ||
|
||
const defaultColumns = getColumns(); | ||
|
||
return ( | ||
<Space direction="vertical" size={16} className={styles.pageContent}> | ||
<Title className={styles.title} level={4}> | ||
{intl.get('screen.publicStudies.title')} | ||
</Title> | ||
|
||
<div> | ||
<ProLabel className={styles.label} title={intl.get('screen.publicStudies.search.title')} /> | ||
<div className={styles.inputContainer}> | ||
<Input | ||
allowClear | ||
onChange={searchPrescription} | ||
placeholder={intl.get('screen.publicStudies.search.placeholder')} | ||
size="large" | ||
value={searchValue} | ||
/> | ||
</div> | ||
</div> | ||
|
||
<GridCard | ||
content={ | ||
<ProTable | ||
tableId={TABLE_ID} | ||
columns={defaultColumns} | ||
wrapperClassName={styles.tableWrapper} | ||
loading={isFetchingStats} | ||
showSorterTooltip={false} | ||
bordered | ||
headerConfig={{ | ||
hideItemsCount: true, | ||
}} | ||
size="small" | ||
dataSource={filteredStudies.map((i) => ({ ...i, key: i.study_code }))} | ||
dictionary={getProTableDictionary()} | ||
/> | ||
} | ||
/> | ||
</Space> | ||
); | ||
}; | ||
|
||
export default PageContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.studiesPage { | ||
display: flex; | ||
} | ||
|
||
.scrollContent { | ||
width: 100%; | ||
padding: var(--default-page-content-padding); | ||
} | ||
|
||
.descriptionCell::after { | ||
content: ''; | ||
display: block; | ||
} | ||
|
||
.dbgapLink { | ||
margin-right: 8px; | ||
} | ||
.dbgapLink:last-child { | ||
margin-right: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
import { useEffect } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
import ScrollContent from '@ferlab/ui/core/layout/ScrollContent'; | ||
|
||
import PublicLayout from 'components/PublicLayout'; | ||
import { fetchStats } from 'store/global/thunks'; | ||
|
||
import PageContent from './PageContent'; | ||
import { SCROLL_WRAPPER_ID } from './utils'; | ||
|
||
import style from './index.module.css'; | ||
|
||
const PublicStudies = () => { | ||
const dispatch = useDispatch(); | ||
|
||
useEffect(() => { | ||
dispatch(fetchStats()); | ||
}, [dispatch]); | ||
|
||
const PublicStudies = () => ( | ||
<PublicLayout> | ||
<span></span> | ||
</PublicLayout> | ||
); | ||
return ( | ||
<PublicLayout> | ||
<div className={style.studiesPage}> | ||
<ScrollContent id={SCROLL_WRAPPER_ID} className={style.scrollContent}> | ||
<PageContent /> | ||
</ScrollContent> | ||
</div> | ||
</PublicLayout> | ||
); | ||
}; | ||
|
||
export default PublicStudies; |
Oops, something went wrong.