Skip to content

Commit

Permalink
add default_entries parameter for grant list
Browse files Browse the repository at this point in the history
  • Loading branch information
c2d13p committed Dec 12, 2024
1 parent a618efe commit 98d87c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions widgets/src/components/HomeGrantList.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import {
} from '../utils';
import './styles.css';

export function HomeGrantList({}) {
const [numberOfEntries, setNumberOfEntries] = useState(6);
export function HomeGrantList({ default_entries = 3 }) {
const [numberOfEntries, setNumberOfEntries] = useState(default_entries * 2);

const { isLoading, error, data } = useQuery([ 'homegrants', numberOfEntries ], async () => {
const now = new Date()
now.setHours(0, 0, 0, 0)

const grants = await axios.get(getManageURL("public/grants"), { params: { _limit: numberOfEntries, from: now} })
const grants = await axios.get(getManageURL("public/grants"), { params: { from: now} })
if (grants.data) {
return grants.data.data
}
Expand Down Expand Up @@ -54,7 +54,7 @@ export function HomeGrantList({}) {
<div className="row">{all_grant_list}</div>
{showButton && (
<div className="d-flex flex-row justify-content-center">
<Button className="load-button" onClick={() => setNumberOfEntries(numberOfEntries + 3)}>
<Button className="load-button" onClick={() => setNumberOfEntries(numberOfEntries + default_entries)}>
{'Load more'}
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion widgets/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
show_excerpt: false
})
dmwidgets.loadComponent(document.getElementById('homegrantlist'), "HomeGrantList", {
_limit: 10,
default_entries: 1,
})
dmwidgets.loadComponent(document.getElementById('homevisitlist'), "HomeVisitList", {
default_entries: 5,
Expand Down
2 changes: 1 addition & 1 deletion widgets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dmwidgets.loadComponent = (target, name, props = {}) => {
element = <HomeEventList {...props}></HomeEventList>
break;
case 'HomeGrantList':
element = <HomeGrantList></HomeGrantList>
element = <HomeGrantList {...props}></HomeGrantList>
break;
case 'HomeVisitList':
element = <HomeVisitList {...props}></HomeVisitList>
Expand Down

0 comments on commit 98d87c9

Please sign in to comment.