components
3 years ago
hocs
5 years ago
pages
3 years ago
scss
4 years ago
App.js
5 years ago
analytics.scss
5 years ago
index.js
4 years ago
routes.js
5 years ago
util.js
4 years ago
App.js
61 lines
| 1 | const { useState } = wp.element; |
| 2 | |
| 3 | import { Route, Router } from "@/router"; |
| 4 | |
| 5 | import AnalyticsUpgrade from "./pages/AnalyticsUpgrade"; |
| 6 | import Dashboard from "./pages/Dashboard"; |
| 7 | |
| 8 | import User from "./pages/User"; |
| 9 | import Video from "./pages/Video"; |
| 10 | import { routes } from "./routes"; |
| 11 | |
| 12 | export default () => { |
| 13 | const scrollToTop = () => { |
| 14 | window.scrollTo(0, 0); |
| 15 | }; |
| 16 | |
| 17 | const [startDate, setStartDate] = useState( |
| 18 | new Date(Date.now() - 7 * 24 * 60 * 60 * 1000) |
| 19 | ); |
| 20 | const [endDate, setEndDate] = useState(new Date()); |
| 21 | |
| 22 | if (!prestoPlayer?.isPremium) { |
| 23 | return ( |
| 24 | <div className="presto-dashboard__content"> |
| 25 | <AnalyticsUpgrade /> |
| 26 | </div> |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | return ( |
| 31 | <div className="presto-dashboard__content"> |
| 32 | <Router routes={routes}> |
| 33 | <Route path={routes.dashboard.path} onRoute={scrollToTop}> |
| 34 | <Dashboard |
| 35 | startDate={startDate} |
| 36 | endDate={endDate} |
| 37 | setStartDate={setStartDate} |
| 38 | setEndDate={setEndDate} |
| 39 | /> |
| 40 | </Route> |
| 41 | <Route path={routes.video.path} onRoute={scrollToTop}> |
| 42 | <Video |
| 43 | startDate={startDate} |
| 44 | endDate={endDate} |
| 45 | setStartDate={setStartDate} |
| 46 | setEndDate={setEndDate} |
| 47 | /> |
| 48 | </Route> |
| 49 | <Route path={routes.user.path} onRoute={scrollToTop}> |
| 50 | <User |
| 51 | startDate={startDate} |
| 52 | endDate={endDate} |
| 53 | setStartDate={setStartDate} |
| 54 | setEndDate={setEndDate} |
| 55 | /> |
| 56 | </Route> |
| 57 | </Router> |
| 58 | </div> |
| 59 | ); |
| 60 | }; |
| 61 |