Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix

kruzhambus2c32f8a2e2e4
diff --git a/src/pages/Dashboard/Dashboard.container.jsx b/src/pages/Dashboard/Dashboard.container.jsx
index 2a1b7ecb5..e01d47602 100644
--- a/src/pages/Dashboard/Dashboard.container.jsx
+++ b/src/pages/Dashboard/Dashboard.container.jsx
@@ -11,7 +11,7 @@ const mapStateToProps = (state) => ({
isLoading: state.ui.projects.isLoading,
total: state.ui.projects.total,
error: state.ui.projects.error,
- curentPageRedux: state.ui.projects.curentPage,
+ dashboardPaginationPage: state.ui.projects.dashboardPaginationPage,
})
const mapDispatchToProps = (dispatch) => ({
@@ -33,8 +33,8 @@ const mapDispatchToProps = (dispatch) => ({
loadProjects: (take, skip) => {
dispatch(UIActions.loadProjects(take, skip))
},
- setCurentPageRedux: (page) => {
- dispatch(UIActions.setCurentPage(page))
+ setDashboardPaginationPage: (page) => {
+ dispatch(UIActions.setDashboardPaginationPage(page))
},
})
diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsx
index 6b0644bba..0739dc0da 100644
--- a/src/pages/Dashboard/Dashboard.jsx
+++ b/src/pages/Dashboard/Dashboard.jsx
@@ -13,6 +13,7 @@ import _map from 'lodash/map'
import _isUndefined from 'lodash/isUndefined'
import _filter from 'lodash/filter'
import _find from 'lodash/find'
+import _ceil from 'lodash/ceil'
import { useTranslation } from 'react-i18next'
import { EyeIcon, CalendarIcon } from '@heroicons/react/outline'
import { ArrowSmUpIcon, ArrowSmDownIcon, XCircleIcon } from '@heroicons/react/solid'
@@ -171,13 +172,13 @@ const NoProjects = ({ t }) => (
)
const Dashboard = ({
- projects, isLoading, error, user, deleteProjectFailed, setProjectsShareData, setUserShareData, userSharedUpdate, sharedProjectError, loadProjects, total, setCurentPageRedux, curentPageRedux,
+ projects, isLoading, error, user, deleteProjectFailed, setProjectsShareData, setUserShareData, userSharedUpdate, sharedProjectError, loadProjects, total, setDashboardPaginationPage, dashboardPaginationPage,
}) => {
const { t, i18n: { language } } = useTranslation('common')
const [showActivateEmailModal, setShowActivateEmailModal] = useState(false)
const history = useHistory()
- const pageAmount = useMemo(() => Math.ceil(total / ENTRIES_PER_PAGE_DASHBOARD), [total])
+ const pageAmount = useMemo(() => _ceil(total / ENTRIES_PER_PAGE_DASHBOARD), [total])
const onNewProject = () => {
if (user.isActive || isSelfhosted) {
@@ -188,9 +189,9 @@ const Dashboard = ({
}
useEffect(() => {
- loadProjects(ENTRIES_PER_PAGE_DASHBOARD, (curentPageRedux - 1) * ENTRIES_PER_PAGE_DASHBOARD)
+ loadProjects(ENTRIES_PER_PAGE_DASHBOARD, (dashboardPaginationPage - 1) * ENTRIES_PER_PAGE_DASHBOARD)
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [curentPageRedux])
+ }, [dashboardPaginationPage])
if (error && !isLoading) {
return (
@@ -281,7 +282,7 @@ const Dashboard = ({
{
pageAmount > 1 && (
- <Pagination page={curentPageRedux} setPage={(page) => setCurentPageRedux(page)} pageAmount={pageAmount || 0} />
+ <Pagination page={dashboardPaginationPage} setPage={(page) => setDashboardPaginationPage(page)} pageAmount={pageAmount || 0} />
)
}
</div>
@@ -321,8 +322,8 @@ Dashboard.propTypes = {
userSharedUpdate: PropTypes.func.isRequired,
loadProjects: PropTypes.func.isRequired,
total: PropTypes.number.isRequired,
- setCurentPageRedux: PropTypes.func.isRequired,
- curentPageRedux: PropTypes.number.isRequired,
+ setDashboardPaginationPage: PropTypes.func.isRequired,
+ dashboardPaginationPage: PropTypes.number.isRequired,
}
Dashboard.defaultProps = {
diff --git a/src/redux/actions/ui/index.js b/src/redux/actions/ui/index.js
index 431d6a234..e0455eb75 100644
--- a/src/redux/actions/ui/index.js
+++ b/src/redux/actions/ui/index.js
@@ -26,8 +26,8 @@ const setTotal = (total) => ({
},
})
-const setCurentPage = (page) => ({
- type: types.SET_CURENT_PAGE,
+const setDashboardPaginationPage = (page) => ({
+ type: types.SET_DASHBOARD_PAGINATION_PAGE,
payload: {
page,
},
@@ -153,7 +153,7 @@ const UIActions = {
setGeneralStats,
setPaddleLastEvent,
setTotalMonthlyEvents,
- setCurentPage,
+ setDashboardPaginationPage,
setTotal,
setShowNoEventsLeftBanner,
setProjectsShareData,
diff --git a/src/redux/actions/ui/types.js b/src/redux/actions/ui/types.js
index 8684dccc5..fb4943e18 100644
--- a/src/redux/actions/ui/types.js
+++ b/src/redux/actions/ui/types.js
@@ -15,7 +15,7 @@ export const types = {
SET_PADDLE_LAST_EVENT: 'UI_SET_PADDLE_LAST_EVENT',
SET_TOTAL_MONTHLY_EVENTS: 'UI_SET_TOTAL_MONTHLY_EVENTS',
SET_TOTAL: 'UI_SET_TOTAL',
- SET_CURENT_PAGE: 'UI_SET_CURENT_PAGE',
+ SET_DASHBOARD_PAGINATION_PAGE: 'UI_SET_DASHBOARD_PAGINATION_PAGE',
SET_SHOW_NO_EVENTS_LEFT: 'UI_SET_SHOW_NO_EVENTS_LEFT',
SET_PROJECTS_SHARE_DATA: 'UI_SET_PROJECTS_SHARE_DATA',
SHARE_VERIFY_ASYNC: 'UI_SHARE_VERIFY_ASYNC',
diff --git a/src/redux/constants/index.js b/src/redux/constants/index.js
index 79ae7d319..4deae4a6c 100644
--- a/src/redux/constants/index.js
+++ b/src/redux/constants/index.js
@@ -165,4 +165,4 @@ export const roleAdmin = {
}
export const INVITATION_EXPIRES_IN = 48 // hours
-export const ENTRIES_PER_PAGE_DASHBOARD = 4
+export const ENTRIES_PER_PAGE_DASHBOARD = 10
diff --git a/src/redux/reducers/ui/projects.js b/src/redux/reducers/ui/projects.js
index 23ea79756..b52603387 100644
--- a/src/redux/reducers/ui/projects.js
+++ b/src/redux/reducers/ui/projects.js
@@ -10,7 +10,7 @@ const getInitialState = () => {
error: null,
totalMonthlyEvents: null,
total: 0,
- curentPage: 1,
+ dashboardPaginationPage: 1,
}
}
@@ -26,11 +26,11 @@ const projectsReducer = (state = getInitialState(), { type, payload }) => {
}
}
- case types.SET_CURENT_PAGE: {
+ case types.SET_DASHBOARD_PAGINATION_PAGE: {
const { page } = payload
return {
...state,
- curentPage: page,
+ dashboardPaginationPage: page,
}
}
diff --git a/src/ui/Pagination.jsx b/src/ui/Pagination.jsx
index 3c5fe5e30..3b559aae8 100644
--- a/src/ui/Pagination.jsx
+++ b/src/ui/Pagination.jsx
@@ -1,9 +1,13 @@
-import React from 'react'
+import React, { memo } from 'react'
import { ArrowNarrowLeftIcon, ArrowNarrowRightIcon } from '@heroicons/react/solid'
import _map from 'lodash/map'
import cx from 'clsx'
+import { useTranslation } from 'react-i18next'
+import PropTypes from 'prop-types'
const Pagination = ({ page, setPage, pageAmount }) => {
+ const { t } = useTranslation('common')
+
return (
<nav className='border-t border-gray-200 px-4 flex items-center justify-between sm:px-0'>
<div className='-mt-px w-0 flex-1 flex'>
@@ -15,7 +19,7 @@ const Pagination = ({ page, setPage, pageAmount }) => {
className='border-t-2 border-transparent pt-4 pr-1 inline-flex items-center text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300'
>
<ArrowNarrowLeftIcon className='mr-3 h-5 w-5 text-gray-400' aria-hidden='true' />
- Previous
+ { t('project.prev') }
</button>
)
}
@@ -69,7 +73,7 @@ const Pagination = ({ page, setPage, pageAmount }) => {
onClick={() => setPage(page + 1)}
className='border-t-2 border-transparent pt-4 pl-1 inline-flex items-center text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300'
>
- Next
+ { t('project.next') }
<ArrowNarrowRightIcon className='ml-3 h-5 w-5 text-gray-400' aria-hidden='true' />
</button>
)
@@ -79,4 +83,10 @@ const Pagination = ({ page, setPage, pageAmount }) => {
)
}
-export default Pagination
+Pagination.propTypes = {
+ page: PropTypes.number.isRequired,
+ setPage: PropTypes.func.isRequired,
+ pageAmount: PropTypes.number.isRequired,
+}
+
+export default memo(Pagination)