HEX
Server: LiteSpeed
System: Linux premium263.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: eastcjee (525)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /home/eastcjee/public_html/wp-content/plugins/presto-player/src/admin/analytics/pages/Dashboard.js
/** @jsx jsx */

const { __ } = wp.i18n;
const { Flex, FlexBlock, FlexItem } = wp.components;
const { useState, useEffect } = wp.element;

import TopUsers from "../components/TopUsers";
import TopVideos from "../components/TopVideos";
import OverviewPanel from "../components/OverviewPanel";
import DatePicker from "../components/DatePicker";
import apiFetch from "@wordpress/api-fetch";
import { Notice } from "@wordpress/components";
import { css, jsx } from "@emotion/core";

export default function ({ startDate, endDate, setStartDate, setEndDate }) {
  const [noticeStatus, setNoticeStatus] = useState(false);

  // run this only on mount.
  useEffect(() => {
    apiFetch({ path: "/wp/v2/settings" }).then((post) => {
      if (post?.presto_player_analytics?.enable === false) {
        setNoticeStatus(true);
      }
    });
  }, []);

  return (
    <>
      {/* Component decleared below this code  */}
      {noticeStatus ? <MyNotice /> : ""}
      <Flex>
        <FlexBlock>
          <h1>{__("Analytics", "presto-player")}</h1>
        </FlexBlock>
        <FlexItem>
          <DatePicker
            startDate={startDate}
            setStartDate={setStartDate}
            endDate={endDate}
            setEndDate={setEndDate}
          />
        </FlexItem>
      </Flex>

      <div className="presto-flow">
        <div className="presto-dashboard">
          <div className="presto-dashboard__row">
            <div className="presto-dashboard__item is-large">
              <OverviewPanel startDate={startDate} endDate={endDate} />
            </div>
            <div className="presto-dashboard__item">
              <TopUsers startDate={startDate} endDate={endDate} />
            </div>
          </div>

          <div className="presto-dashboard__row">
            <div className="presto-dashboard__item is-large">
              <TopVideos startDate={startDate} endDate={endDate} />
            </div>
          </div>
        </div>
      </div>
    </>
  );
}

const MyNotice = () => (
  <Notice
    css={css`
      margin: 0 0 1em 0 !important;
    `}
    status="warning"
    isDismissible={false}
  >
    <p>
      {__(
        "Analytics are currently disabled. To collect analytics, turn them on in your settings page.",
        "presto-player"
      )}
    </p>
  </Notice>
);