-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add number of items to tabs of channel view * Extra info for market when revenue share is active * Restrict revenue share duration to 2 weeks * Add QS pagination for crt market * Better signalize revenue share money block on channel view
- Loading branch information
Showing
9 changed files
with
123 additions
and
18 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
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,27 @@ | ||
import { useCallback, useEffect, useState } from 'react' | ||
import { useSearchParams } from 'react-router-dom' | ||
|
||
export type UsePaginationOptions = { | ||
initialPerPage?: number | ||
initialCurrentPage?: number | ||
currentTab?: number | ||
} | ||
|
||
export const useQueryPagination = (opts?: UsePaginationOptions) => { | ||
const [getSearchParams, setSearchParams] = useSearchParams() | ||
const _perPage = +(getSearchParams.get('perPage') ?? opts?.initialPerPage ?? 10) | ||
const _currentPage = +(getSearchParams.get('currentPage') ?? opts?.initialCurrentPage ?? 0) | ||
const [perPage, setPerPage] = useState(_perPage) | ||
const [currentPage, setCurrentPage] = useState(_currentPage) | ||
|
||
useEffect(() => { | ||
setSearchParams({ currentPage: String(currentPage), perPage: String(perPage) }, { replace: true }) | ||
}, [currentPage, perPage, setSearchParams]) | ||
|
||
const resetPagination = useCallback(() => { | ||
setCurrentPage(opts?.initialCurrentPage ?? 0) | ||
setPerPage(opts?.initialCurrentPage ?? 10) | ||
}, [opts?.initialCurrentPage, setCurrentPage, setPerPage]) | ||
|
||
return { currentPage, setCurrentPage, perPage, setPerPage, resetPagination } | ||
} |
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