Skip to content

Commit

Permalink
Fixed wrong date range showing in title when changing the dates in da…
Browse files Browse the repository at this point in the history
…shboard
  • Loading branch information
rayceramsay committed Aug 28, 2024
1 parent e36651b commit 5e3a2f9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ function Dashboard() {

const [startDate, setStartDate] = useState(`${currentYear}-01-01`)
const [endDate, setEndDate] = useState(`${currentYear}-12-31`)
const [fetchedStartDate, setFetchedStartDate] = useState(startDate)
const [fetchedEndDate, setFetchedEndDate] = useState(endDate)
const [getPageData, { data: pageData, loading: pageLoading, error: pageError, called: hasPageFetchedOnce }] =
useLazyQuery(GET_ANALYTICS_DASHBOARD_DATA)
useLazyQuery(GET_ANALYTICS_DASHBOARD_DATA, {
onCompleted: () => {
setFetchedStartDate(startDate)
setFetchedEndDate(endDate)
},
})
useEffect(() => {
if (!hasPageFetchedOnce) {
getPageData({ variables: { startDate, endDate } })
Expand Down Expand Up @@ -56,7 +63,7 @@ function Dashboard() {
<main className={styles.wrapper}>
<div className={styles.titleRow}>
<h1 className={styles.mainTitle}>
Analytics for {startDate} to {endDate}
Analytics for {fetchedStartDate} to {fetchedEndDate}
</h1>
<form action='' className={styles.dateLimitsForm}>
<label className={styles.dateLimitInputContainer}>
Expand Down

0 comments on commit 5e3a2f9

Please sign in to comment.