From 794a9cf7bc5dbcc333e0cc24ba2b4f5966a8d0f8 Mon Sep 17 00:00:00 2001 From: Awenes <63660000+Awenes@users.noreply.github.com> Date: Sun, 15 Dec 2024 11:24:12 +0100 Subject: [PATCH] Error fixed --- src/pages/vendorcomponents/topProducts.tsx | 114 ++++++++++----------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/pages/vendorcomponents/topProducts.tsx b/src/pages/vendorcomponents/topProducts.tsx index 81f6d8d5..bf5a5fff 100644 --- a/src/pages/vendorcomponents/topProducts.tsx +++ b/src/pages/vendorcomponents/topProducts.tsx @@ -1,5 +1,5 @@ -import { useState, useEffect } from 'react'; -import axios from 'axios'; +// import { useState, useEffect } from 'react'; +// import axios from 'axios'; import { Table, @@ -10,70 +10,70 @@ import { TableRow, } from "../../../src/components/ui/table" -interface ProductData { - product_id: number; - category_id: number; - user_id: number; - name: string; - description: string; - image: string; - created_at: string; - total_revenue: number; - total_cost: number; - total_quantity_sold: number; - total_profit: number; - average_stock: number; - sales_data: { - date: string; - price: number; - quantity_sold: number; - revenue: number; - cost: number; - profit: number; - }[]; - profit_margin: number; - average_price: number; - stock_turnover_rate: number; - is_profitable: boolean; - profit_per_unit: number; -} +// interface ProductData { +// product_id: number; +// category_id: number; +// user_id: number; +// name: string; +// description: string; +// image: string; +// created_at: string; +// total_revenue: number; +// total_cost: number; +// total_quantity_sold: number; +// total_profit: number; +// average_stock: number; +// sales_data: { +// date: string; +// price: number; +// quantity_sold: number; +// revenue: number; +// cost: number; +// profit: number; +// }[]; +// profit_margin: number; +// average_price: number; +// stock_turnover_rate: number; +// is_profitable: boolean; +// profit_per_unit: number; +// } -interface ApiResponse { - count: number; - next: string | null; - previous: string | null; - results: ProductData[]; -} +// interface ApiResponse { +// count: number; +// next: string | null; +// previous: string | null; +// results: ProductData[]; +// } const TopProducts = () => { // const [productData, setProductData] = useState([]); - const [isLoading, setIsLoading] = useState(true); - const [error, setError] = useState(null); + // const [isLoading, setIsLoading] = useState(true); + // const [error, setError] = useState(null); - useEffect(() => { - const fetchData = async () => { - try { - const response = await axios.get('https://renergy-hub-django-backend.onrender.com/api/v1/financial/analytics/top-profit',{withCredentials:true}); - console.log(response.data.results); - } catch (err) { - setError('Failed to fetch product data.'); - console.error(err); - } finally { - setIsLoading(false); - } - }; + // useEffect(() => { + // const fetchData = async () => { + // try { + // const response = await axios.get('https://renergy-hub-django-backend.onrender.com/api/v1/financial/analytics/top-profit',{withCredentials:true}); + // console.log(response.data.results); + // } catch (err) { + // setError('Failed to fetch product data.'); + // console.error(err); + // } finally { + // setIsLoading(false); + // } + // }; - fetchData(); - }, []); + // fetchData(); + // }, []); - if (isLoading) { - return
; - } + // if (isLoading) { + // return
; + // } - if (error) { - return
Error: {error}
; - } + // if (error) { + // return
Error: {error}
; + // } return (