diff --git a/src/app/(app)/websites/[id]/event-data/WebsiteEventData.js b/src/app/(app)/websites/[id]/event-data/WebsiteEventData.js
index dc5a0b9ce2..b5982e321c 100644
--- a/src/app/(app)/websites/[id]/event-data/WebsiteEventData.js
+++ b/src/app/(app)/websites/[id]/event-data/WebsiteEventData.js
@@ -3,7 +3,7 @@ import { Flexbox, Loading } from 'react-basics';
import EventDataTable from './EventDataTable';
import EventDataValueTable from './EventDataValueTable';
import { EventDataMetricsBar } from './EventDataMetricsBar';
-import { useDateRange, useApi, usePageQuery } from 'components/hooks';
+import { useDateRange, useApi, useNavigation } from 'components/hooks';
import styles from './WebsiteEventData.module.css';
function useData(websiteId, event) {
@@ -28,7 +28,7 @@ function useData(websiteId, event) {
export default function WebsiteEventData({ websiteId }) {
const {
query: { event },
- } = usePageQuery();
+ } = useNavigation();
const { data, isLoading } = useData(websiteId, event);
return (
diff --git a/src/components/common/FilterLink.js b/src/components/common/FilterLink.js
index 2a95e011da..89648255a4 100644
--- a/src/components/common/FilterLink.js
+++ b/src/components/common/FilterLink.js
@@ -2,13 +2,13 @@ import { Icon, Icons } from 'react-basics';
import classNames from 'classnames';
import Link from 'next/link';
import { safeDecodeURI } from 'next-basics';
-import usePageQuery from 'components/hooks/usePageQuery';
+import useNavigation from 'components/hooks/useNavigation';
import useMessages from 'components/hooks/useMessages';
import styles from './FilterLink.module.css';
export function FilterLink({ id, value, label, externalUrl, children, className }) {
const { formatMessage, labels } = useMessages();
- const { resolveUrl, query } = usePageQuery();
+ const { makeUrl, query } = useNavigation();
const active = query[id] !== undefined;
const selected = query[id] === value;
@@ -22,7 +22,7 @@ export function FilterLink({ id, value, label, externalUrl, children, className
{children}
{!value && `(${label || formatMessage(labels.unknown)})`}
{value && (
-
+
{safeDecodeURI(label || value)}
)}
diff --git a/src/components/common/LinkButton.js b/src/components/common/LinkButton.js
index 54c7fa6319..f63b1cf855 100644
--- a/src/components/common/LinkButton.js
+++ b/src/components/common/LinkButton.js
@@ -1,11 +1,15 @@
+import classNames from 'classnames';
import Link from 'next/link';
import { Icon, Icons, Text } from 'react-basics';
import styles from './LinkButton.module.css';
+import { useLocale } from 'components/hooks';
+
+export function LinkButton({ href, icon, className, children }) {
+ const { dir } = useLocale();
-export function LinkButton({ href, icon, children }) {
return (
-
- {icon || }
+
+ {icon || }
{children}
);
diff --git a/src/components/hooks/index.js b/src/components/hooks/index.js
index 2596ba57ef..79c0937cca 100644
--- a/src/components/hooks/index.js
+++ b/src/components/hooks/index.js
@@ -10,7 +10,7 @@ export * from './useFormat';
export * from './useLanguageNames';
export * from './useLocale';
export * from './useMessages';
-export * from './usePageQuery';
+export * from './useNavigation';
export * from './useReport';
export * from './useReports';
export * from './useRequireLogin';
diff --git a/src/components/hooks/usePageQuery.js b/src/components/hooks/useNavigation.js
similarity index 66%
rename from src/components/hooks/usePageQuery.js
rename to src/components/hooks/useNavigation.js
index de87e247e8..658e81ed05 100644
--- a/src/components/hooks/usePageQuery.js
+++ b/src/components/hooks/useNavigation.js
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { buildUrl } from 'next-basics';
-export function usePageQuery() {
+export function useNavigation() {
const router = useRouter();
const pathname = usePathname();
const params = useSearchParams();
@@ -17,11 +17,11 @@ export function usePageQuery() {
return obj;
}, [params]);
- function resolveUrl(params, reset) {
- return buildUrl(pathname, { ...(reset ? {} : query) });
+ function makeUrl(params, reset) {
+ return reset ? pathname : buildUrl(pathname, { ...query, ...params });
}
- return { pathname, query, resolveUrl, router };
+ return { pathname, query, router, makeUrl };
}
-export default usePageQuery;
+export default useNavigation;
diff --git a/src/components/layout/Grid.js b/src/components/layout/Grid.js
index 080310e522..86b08887b2 100644
--- a/src/components/layout/Grid.js
+++ b/src/components/layout/Grid.js
@@ -1,6 +1,6 @@
import classNames from 'classnames';
-import styles from './Grid.module.css';
import { mapChildren } from 'react-basics';
+import styles from './Grid.module.css';
export function Grid({ className, ...otherProps }) {
return ;
diff --git a/src/components/layout/Page.module.css b/src/components/layout/Page.module.css
index d60413f457..ac83d9a75f 100644
--- a/src/components/layout/Page.module.css
+++ b/src/components/layout/Page.module.css
@@ -5,6 +5,7 @@
background: var(--base50);
position: relative;
max-width: 1320px;
+ min-height: calc(100vh - 60px);
margin: 0 auto;
padding: 0 20px;
}
diff --git a/src/app/(app)/settings/SideNav.js b/src/components/layout/SideNav.js
similarity index 100%
rename from src/app/(app)/settings/SideNav.js
rename to src/components/layout/SideNav.js
diff --git a/src/app/(app)/settings/SideNav.module.css b/src/components/layout/SideNav.module.css
similarity index 100%
rename from src/app/(app)/settings/SideNav.module.css
rename to src/components/layout/SideNav.module.css
diff --git a/src/components/metrics/EventsChart.js b/src/components/metrics/EventsChart.js
index 3a1c644f0b..f2cf48d11a 100644
--- a/src/components/metrics/EventsChart.js
+++ b/src/components/metrics/EventsChart.js
@@ -3,7 +3,7 @@ import { Loading } from 'react-basics';
import { colord } from 'colord';
import BarChart from './BarChart';
import { getDateArray } from 'lib/date';
-import { useApi, useLocale, useDateRange, useTimezone, usePageQuery } from 'components/hooks';
+import { useApi, useLocale, useDateRange, useTimezone, useNavigation } from 'components/hooks';
import { EVENT_COLORS } from 'lib/constants';
import { renderDateLabels, renderStatusTooltipPopup } from 'lib/charts';
@@ -14,7 +14,7 @@ export function EventsChart({ websiteId, className, token }) {
const [timezone] = useTimezone();
const {
query: { url, event },
- } = usePageQuery();
+ } = useNavigation();
const { data, isLoading } = useQuery(['events', websiteId, modified, event], () =>
get(`/websites/${websiteId}/events`, {
diff --git a/src/components/metrics/FilterTags.js b/src/components/metrics/FilterTags.js
index cb88a7dbad..554c223ae5 100644
--- a/src/components/metrics/FilterTags.js
+++ b/src/components/metrics/FilterTags.js
@@ -1,6 +1,6 @@
import { safeDecodeURI } from 'next-basics';
import { Button, Icon, Icons, Text } from 'react-basics';
-import usePageQuery from 'components/hooks/usePageQuery';
+import useNavigation from 'components/hooks/useNavigation';
import useMessages from 'components/hooks/useMessages';
import styles from './FilterTags.module.css';
@@ -8,9 +8,9 @@ export function FilterTags({ params }) {
const { formatMessage, labels } = useMessages();
const {
router,
- resolveUrl,
+ makeUrl,
query: { view },
- } = usePageQuery();
+ } = useNavigation();
if (Object.keys(params).filter(key => params[key]).length === 0) {
return null;
@@ -18,9 +18,9 @@ export function FilterTags({ params }) {
function handleCloseFilter(param) {
if (!param) {
- router.push(resolveUrl({ view }, true));
+ router.push(makeUrl({ view }, true));
} else {
- router.push(resolveUrl({ [param]: undefined }));
+ router.push(makeUrl({ [param]: undefined }));
}
}
diff --git a/src/components/metrics/MetricsTable.js b/src/components/metrics/MetricsTable.js
index 1bf8419b78..d36bc91e1e 100644
--- a/src/components/metrics/MetricsTable.js
+++ b/src/components/metrics/MetricsTable.js
@@ -6,7 +6,7 @@ import classNames from 'classnames';
import useApi from 'components/hooks/useApi';
import { percentFilter } from 'lib/filters';
import useDateRange from 'components/hooks/useDateRange';
-import usePageQuery from 'components/hooks/usePageQuery';
+import useNavigation from 'components/hooks/useNavigation';
import ErrorMessage from 'components/common/ErrorMessage';
import ListTable from './ListTable';
import { DEFAULT_ANIMATION_DURATION } from 'lib/constants';
@@ -28,9 +28,9 @@ export function MetricsTable({
}) {
const [{ startDate, endDate, modified }] = useDateRange(websiteId);
const {
- resolveUrl,
+ makeUrl,
query: { url, referrer, title, os, browser, device, country, region, city },
- } = usePageQuery();
+ } = useNavigation();
const { formatMessage, labels } = useMessages();
const { get, useQuery } = useApi();
const { dir } = useLocale();
@@ -103,7 +103,7 @@ export function MetricsTable({
{data && !error && }
{data && !error && limit && (
-
+