@@ -18,12 +18,6 @@ import { useDocumentInfo } from "payload/components/utilities";
1818import { MetricMap } from "../../providers/plausible/client" ;
1919import { useTheme } from "payload/dist/admin/components/utilities/Theme" ;
2020
21- /* type ChartOptions = {
22- timeframe?: string;
23- metrics: ChartWidget["metrics"];
24- idMatcher: IdMatcherFunction;
25- }; */
26-
2721type Props = {
2822 options : ChartWidget ;
2923} ;
@@ -37,7 +31,6 @@ const ChartComponent = lazy(() =>
3731const PageViewsChart : React . FC < Props > = ( { options } ) => {
3832 const [ chartData , setChartData ] = useState < ChartData > ( [ ] ) ;
3933 const [ isLoading , setIsLoading ] = useState < boolean > ( true ) ;
40- const chartRef = useRef < any > ( null ) ;
4134 const theme = useTheme ( ) ;
4235 const { publishedDoc } = useDocumentInfo ( ) ;
4336
@@ -70,12 +63,6 @@ const PageViewsChart: React.FC<Props> = ({ options }) => {
7063 } ) . then ( ( response ) => response . json ( ) ) ;
7164
7265 getChartData . then ( ( data : ChartData ) => {
73- /* const processedData: ChartData = [
74- {
75- label: "test",
76- data: data,
77- },
78- ]; */
7966 setChartData ( data ) ;
8067 setIsLoading ( false ) ;
8168 } ) ;
@@ -84,16 +71,6 @@ const PageViewsChart: React.FC<Props> = ({ options }) => {
8471 }
8572 } , [ publishedDoc , pageId ] ) ;
8673
87- useEffect ( ( ) => {
88- const importChart = async ( ) => {
89- /* Dynamic import for react-charts due to ESM and how bundling is done with Payload */
90- const { Chart } = await import ( "react-charts" ) ;
91- chartRef . current = Chart ;
92- } ;
93-
94- importChart ( ) ;
95- } , [ ] ) ;
96-
9774 const chartLabel = useMemo ( ( ) => {
9875 if ( label ) return label ;
9976
@@ -134,10 +111,7 @@ const PageViewsChart: React.FC<Props> = ({ options }) => {
134111 marginBottom : "1.5rem" ,
135112 } }
136113 >
137- { pageId !== "" &&
138- chartRef ?. current &&
139- chartData ?. length &&
140- chartData . length > 0 ? (
114+ { pageId !== "" && chartData ?. length && chartData . length > 0 ? (
141115 < >
142116 < h1 style = { { fontSize : "1.25rem" , marginBottom : "0.5rem" } } >
143117 { chartLabel } ({ timeframeIndicator } )
0 commit comments