import React, { useState } from 'react'; import { useSelector } from 'react-redux'; import classNames from 'classnames'; import Head from 'next/head'; import Link from 'next/link'; import Page from '../layout/Page'; import PageHeader from '../layout/PageHeader'; import useFetch from '../../hooks/useFetch'; import DropDown from '../common/DropDown'; import styles from './Test.module.css'; import WebsiteChart from '../metrics/WebsiteChart'; import EventsChart from '../metrics/EventsChart'; import Button from '../common/Button'; import EmptyPlaceholder from '../common/EmptyPlaceholder'; export default function TestConsole() { const user = useSelector(state => state.user); const [website, setWebsite] = useState(); const { data } = useFetch('/api/websites'); if (!data || !user?.is_admin) { return null; } const options = data.map(({ name, website_id }) => ({ label: name, value: website_id })); const selectedValue = options.find(({ value }) => value === website?.website_id)?.value; function handleSelect(value) { setWebsite(data.find(({ website_id }) => website_id === value)); } function handleClick() { window.umami('event (default)'); window.umami.trackView('/page-view', 'https://www.google.com'); window.umami.trackEvent('event (custom)', 'custom-type'); } return ( {typeof window !== 'undefined' && website && (