Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Feature: reset state when clicking Prev/Next buttons (PCD-848) (#50)
Browse files Browse the repository at this point in the history
* ✨ Add: state reset when clicking Prev/Next buttons

* ♻️  Refactor: rename handler

* ♻️  Refactor: add "Handler" to handler function
  • Loading branch information
sebasfavaron authored Jan 18, 2022
1 parent 1b8bc2f commit 8f09360
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/pages/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ export function Event() {

const previousEventURI = `/event/${parseInt(eventId)-1}`;
const nextEventURI = `/event/${parseInt(eventId)+1}`;
const resetState = () => {
setTableIsLoading(true)
setCanDownloadCsv(CSV_STATUS.NoTokens)
setPageIndex(0)
setEnsNames([])
}
const onPageChangeHandler = () => {
resetState()
}

return (
<main id="site-main" role="main" className="app-content event-main">
Expand Down Expand Up @@ -192,14 +201,14 @@ export function Event() {
}}>
<div style={{flex: '0 0 18rem', display: 'flex', flexDirection: "column", justifyContent: "center"}}>
<div className='prev-next-buttons' style={{display: 'flex', justifyContent: 'space-between', marginBottom: 38,}}>
<Link to={previousEventURI}>
<Link onClick={onPageChangeHandler} to={previousEventURI}>
<FontAwesomeIcon icon={faAngleLeft}/>{' Prev'}
</Link>
<h4 style={{marginBottom: '0'}}>
<div className='event-title'>EVENT ID</div>
<div className='event-id'>#{eventId}</div>
</h4>
<Link to={nextEventURI}>
<Link onClick={onPageChangeHandler} to={nextEventURI}>
{'Next '}<FontAwesomeIcon icon={faAngleRight}/>
</Link>
</div>
Expand Down

0 comments on commit 8f09360

Please sign in to comment.