diff --git a/src/app/(app)/settings/layout.tsx b/src/app/(app)/settings/layout.tsx index 23323b86dd..e30b8108c8 100644 --- a/src/app/(app)/settings/layout.tsx +++ b/src/app/(app)/settings/layout.tsx @@ -2,7 +2,7 @@ import { usePathname } from 'next/navigation'; import useUser from 'components/hooks/useUser'; import useMessages from 'components/hooks/useMessages'; -import SideNav from './SideNav'; +import SideNav from 'components/layout/SideNav'; import styles from './layout.module.css'; export default function SettingsLayout({ children }) { diff --git a/src/app/(app)/websites/[id]/WebsiteChart.js b/src/app/(app)/websites/[id]/WebsiteChart.js index 7e20e78542..d05ff42208 100644 --- a/src/app/(app)/websites/[id]/WebsiteChart.js +++ b/src/app/(app)/websites/[id]/WebsiteChart.js @@ -1,6 +1,6 @@ import { useMemo } from 'react'; import PageviewsChart from 'components/metrics/PageviewsChart'; -import { useApi, useDateRange, useTimezone, usePageQuery } from 'components/hooks'; +import { useApi, useDateRange, useTimezone, useNavigation } from 'components/hooks'; import { getDateArray } from 'lib/date'; export function WebsiteChart({ websiteId }) { @@ -9,7 +9,7 @@ export function WebsiteChart({ websiteId }) { const [timezone] = useTimezone(); const { query: { url, referrer, os, browser, device, country, region, city, title }, - } = usePageQuery(); + } = useNavigation(); const { get, useQuery } = useApi(); const { data, isLoading } = useQuery( diff --git a/src/app/(app)/websites/[id]/WebsiteDetails.js b/src/app/(app)/websites/[id]/WebsiteDetails.js index 4e7ed19d90..78996b7817 100644 --- a/src/app/(app)/websites/[id]/WebsiteDetails.js +++ b/src/app/(app)/websites/[id]/WebsiteDetails.js @@ -3,7 +3,7 @@ import { Loading } from 'react-basics'; import { usePathname } from 'next/navigation'; import Page from 'components/layout/Page'; import FilterTags from 'components/metrics/FilterTags'; -import usePageQuery from 'components/hooks/usePageQuery'; +import useNavigation from 'components/hooks/useNavigation'; import { useWebsite } from 'components/hooks'; import WebsiteChart from './WebsiteChart'; import WebsiteMenuView from './WebsiteMenuView'; @@ -18,7 +18,7 @@ export default function WebsiteDetails({ websiteId }) { const { query: { view, url, referrer, os, browser, device, country, region, city, title }, - } = usePageQuery(); + } = useNavigation(); if (isLoading || error) { return ; diff --git a/src/app/(app)/websites/[id]/WebsiteMenuView.js b/src/app/(app)/websites/[id]/WebsiteMenuView.js index 55c617fc6c..51c5e8c7c7 100644 --- a/src/app/(app)/websites/[id]/WebsiteMenuView.js +++ b/src/app/(app)/websites/[id]/WebsiteMenuView.js @@ -1,6 +1,4 @@ -import { Icon, Button, Flexbox, Text } from 'react-basics'; -import Link from 'next/link'; -import { GridRow, GridColumn } from 'components/layout/Grid'; +import { Text } from 'react-basics'; import BrowsersTable from 'components/metrics/BrowsersTable'; import CountriesTable from 'components/metrics/CountriesTable'; import RegionsTable from 'components/metrics/RegionsTable'; @@ -13,12 +11,11 @@ import QueryParametersTable from 'components/metrics/QueryParametersTable'; import ReferrersTable from 'components/metrics/ReferrersTable'; import ScreenTable from 'components/metrics/ScreenTable'; import EventsTable from 'components/metrics/EventsTable'; -import Icons from 'components/icons'; -import SideNav from '../../settings/SideNav'; -import usePageQuery from 'components/hooks/usePageQuery'; +import SideNav from 'components/layout/SideNav'; +import useNavigation from 'components/hooks/useNavigation'; import useMessages from 'components/hooks/useMessages'; import styles from './WebsiteMenuView.module.css'; -import useLocale from 'components/hooks/useLocale'; +import LinkButton from 'components/common/LinkButton'; const views = { url: PagesTable, @@ -38,93 +35,86 @@ const views = { export default function WebsiteMenuView({ websiteId, websiteDomain }) { const { formatMessage, labels } = useMessages(); - const { dir } = useLocale(); const { - resolveUrl, + makeUrl, + pathname, query: { view }, - } = usePageQuery(); + } = useNavigation(); const items = [ { key: 'url', label: formatMessage(labels.pages), - url: resolveUrl({ view: 'url' }), + url: makeUrl({ view: 'url' }), }, { key: 'referrer', label: formatMessage(labels.referrers), - url: resolveUrl({ view: 'referrer' }), + url: makeUrl({ view: 'referrer' }), }, { key: 'browser', label: formatMessage(labels.browsers), - url: resolveUrl({ view: 'browser' }), + url: makeUrl({ view: 'browser' }), }, { key: 'os', label: formatMessage(labels.os), - url: resolveUrl({ view: 'os' }), + url: makeUrl({ view: 'os' }), }, { key: 'device', label: formatMessage(labels.devices), - url: resolveUrl({ view: 'device' }), + url: makeUrl({ view: 'device' }), }, { key: 'country', label: formatMessage(labels.countries), - url: resolveUrl({ view: 'country' }), + url: makeUrl({ view: 'country' }), }, { key: 'region', label: formatMessage(labels.regions), - url: resolveUrl({ view: 'region' }), + url: makeUrl({ view: 'region' }), }, { key: 'city', label: formatMessage(labels.cities), - url: resolveUrl({ view: 'city' }), + url: makeUrl({ view: 'city' }), }, { key: 'language', label: formatMessage(labels.languages), - url: resolveUrl({ view: 'language' }), + url: makeUrl({ view: 'language' }), }, { key: 'screen', label: formatMessage(labels.screens), - url: resolveUrl({ view: 'screen' }), + url: makeUrl({ view: 'screen' }), }, { key: 'event', label: formatMessage(labels.events), - url: resolveUrl({ view: 'event' }), + url: makeUrl({ view: 'event' }), }, { key: 'query', label: formatMessage(labels.queryParameters), - url: resolveUrl({ view: 'query' }), + url: makeUrl({ view: 'query' }), }, ]; const DetailsComponent = views[view] || (() => null); return ( - - - - - - - +
+
+ + {formatMessage(labels.back)} + - - +
+
- - +
+
); } diff --git a/src/app/(app)/websites/[id]/WebsiteMenuView.module.css b/src/app/(app)/websites/[id]/WebsiteMenuView.module.css index 4ba6ab3889..5710ac731f 100644 --- a/src/app/(app)/websites/[id]/WebsiteMenuView.module.css +++ b/src/app/(app)/websites/[id]/WebsiteMenuView.module.css @@ -1,7 +1,25 @@ +.layout { + display: grid; + grid-template-columns: 300px 1fr; + border-top: 1px solid var(--base300); +} + .menu { + display: flex; + flex-direction: column; position: relative; + padding: 20px 20px 20px 0; +} + +.back { + display: inline-flex; + align-items: center; + align-self: center; + margin-bottom: 20px; } .content { min-height: 800px; + padding: 20px 0 20px 20px; + border-left: 1px solid var(--base300); } diff --git a/src/app/(app)/websites/[id]/WebsiteMetricsBar.js b/src/app/(app)/websites/[id]/WebsiteMetricsBar.js index f0055eb6f0..b2aa8ca429 100644 --- a/src/app/(app)/websites/[id]/WebsiteMetricsBar.js +++ b/src/app/(app)/websites/[id]/WebsiteMetricsBar.js @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { useApi, useDateRange, useMessages, usePageQuery, useSticky } from 'components/hooks'; +import { useApi, useDateRange, useMessages, useNavigation, useSticky } from 'components/hooks'; import WebsiteDateFilter from 'components/input/WebsiteDateFilter'; import MetricCard from 'components/metrics/MetricCard'; import MetricsBar from 'components/metrics/MetricsBar'; @@ -17,10 +17,10 @@ export function WebsiteMetricsBar({ websiteId, showFilter = true, sticky }) { const { startDate, endDate, modified } = dateRange; const { ref, isSticky } = useSticky({ enabled: sticky }); const { - resolveUrl, + makeUrl, router, query: { url, referrer, title, os, browser, device, country, region, city }, - } = usePageQuery(); + } = useNavigation(); const { data, error, isLoading, isFetched } = useQuery( [ @@ -64,7 +64,7 @@ export function WebsiteMetricsBar({ websiteId, showFilter = true, sticky }) { }; const handleAddFilter = ({ name, value }) => { - router.push(resolveUrl({ [name]: value })); + router.push(makeUrl({ [name]: value })); }; const WebsiteFilterButton = () => { diff --git a/src/app/(app)/websites/[id]/event-data/EventDataTable.js b/src/app/(app)/websites/[id]/event-data/EventDataTable.js index c79916ce5f..fb98e7e76a 100644 --- a/src/app/(app)/websites/[id]/event-data/EventDataTable.js +++ b/src/app/(app)/websites/[id]/event-data/EventDataTable.js @@ -1,12 +1,12 @@ import Link from 'next/link'; import { GridTable, GridColumn } from 'react-basics'; -import { useMessages, usePageQuery } from 'components/hooks'; +import { useMessages, useNavigation } from 'components/hooks'; import Empty from 'components/common/Empty'; import { DATA_TYPES } from 'lib/constants'; export function EventDataTable({ data = [] }) { const { formatMessage, labels } = useMessages(); - const { resolveUrl } = usePageQuery(); + const { makeUrl } = useNavigation(); if (data.length === 0) { return ; @@ -16,7 +16,7 @@ export function EventDataTable({ data = [] }) { {row => ( - + {row.eventName} )} diff --git a/src/app/(app)/websites/[id]/event-data/EventDataValueTable.js b/src/app/(app)/websites/[id]/event-data/EventDataValueTable.js index 75c11e32b7..4e50f5b9b3 100644 --- a/src/app/(app)/websites/[id]/event-data/EventDataValueTable.js +++ b/src/app/(app)/websites/[id]/event-data/EventDataValueTable.js @@ -1,5 +1,5 @@ import { GridTable, GridColumn, Button, Icon, Text } from 'react-basics'; -import { useMessages, usePageQuery } from 'components/hooks'; +import { useMessages, useNavigation } from 'components/hooks'; import Link from 'next/link'; import Icons from 'components/icons'; import PageHeader from 'components/layout/PageHeader'; @@ -8,12 +8,12 @@ import { DATA_TYPES } from 'lib/constants'; export function EventDataValueTable({ data = [], event }) { const { formatMessage, labels } = useMessages(); - const { resolveUrl } = usePageQuery(); + const { makeUrl } = useNavigation(); const Title = () => { return ( <> - +