1
- import { useState , useEffect } from 'react' ;
2
- import axios from 'axios' ;
1
+ // import { useState, useEffect } from 'react';
2
+ // import axios from 'axios';
3
3
4
4
import {
5
5
Table ,
@@ -10,70 +10,70 @@ import {
10
10
TableRow ,
11
11
} from "../../../src/components/ui/table"
12
12
13
- interface ProductData {
14
- product_id : number ;
15
- category_id : number ;
16
- user_id : number ;
17
- name : string ;
18
- description : string ;
19
- image : string ;
20
- created_at : string ;
21
- total_revenue : number ;
22
- total_cost : number ;
23
- total_quantity_sold : number ;
24
- total_profit : number ;
25
- average_stock : number ;
26
- sales_data : {
27
- date : string ;
28
- price : number ;
29
- quantity_sold : number ;
30
- revenue : number ;
31
- cost : number ;
32
- profit : number ;
33
- } [ ] ;
34
- profit_margin : number ;
35
- average_price : number ;
36
- stock_turnover_rate : number ;
37
- is_profitable : boolean ;
38
- profit_per_unit : number ;
39
- }
13
+ // interface ProductData {
14
+ // product_id: number;
15
+ // category_id: number;
16
+ // user_id: number;
17
+ // name: string;
18
+ // description: string;
19
+ // image: string;
20
+ // created_at: string;
21
+ // total_revenue: number;
22
+ // total_cost: number;
23
+ // total_quantity_sold: number;
24
+ // total_profit: number;
25
+ // average_stock: number;
26
+ // sales_data: {
27
+ // date: string;
28
+ // price: number;
29
+ // quantity_sold: number;
30
+ // revenue: number;
31
+ // cost: number;
32
+ // profit: number;
33
+ // }[];
34
+ // profit_margin: number;
35
+ // average_price: number;
36
+ // stock_turnover_rate: number;
37
+ // is_profitable: boolean;
38
+ // profit_per_unit: number;
39
+ // }
40
40
41
- interface ApiResponse {
42
- count : number ;
43
- next : string | null ;
44
- previous : string | null ;
45
- results : ProductData [ ] ;
46
- }
41
+ // interface ApiResponse {
42
+ // count: number;
43
+ // next: string | null;
44
+ // previous: string | null;
45
+ // results: ProductData[];
46
+ // }
47
47
48
48
const TopProducts = ( ) => {
49
49
50
50
// const [productData, setProductData] = useState<ProductData[]>([]);
51
- const [ isLoading , setIsLoading ] = useState ( true ) ;
52
- const [ error , setError ] = useState < string | null > ( null ) ;
51
+ // const [isLoading, setIsLoading] = useState(true);
52
+ // const [error, setError] = useState<string | null>(null);
53
53
54
- useEffect ( ( ) => {
55
- const fetchData = async ( ) => {
56
- try {
57
- const response = await axios . get < ApiResponse > ( 'https://renergy-hub-django-backend.onrender.com/api/v1/financial/analytics/top-profit' , { withCredentials :true } ) ;
58
- console . log ( response . data . results ) ;
59
- } catch ( err ) {
60
- setError ( 'Failed to fetch product data.' ) ;
61
- console . error ( err ) ;
62
- } finally {
63
- setIsLoading ( false ) ;
64
- }
65
- } ;
54
+ // useEffect(() => {
55
+ // const fetchData = async () => {
56
+ // try {
57
+ // const response = await axios.get<ApiResponse>('https://renergy-hub-django-backend.onrender.com/api/v1/financial/analytics/top-profit',{withCredentials:true});
58
+ // console.log(response.data.results);
59
+ // } catch (err) {
60
+ // setError('Failed to fetch product data.');
61
+ // console.error(err);
62
+ // } finally {
63
+ // setIsLoading(false);
64
+ // }
65
+ // };
66
66
67
- fetchData ( ) ;
68
- } , [ ] ) ;
67
+ // fetchData();
68
+ // }, []);
69
69
70
- if ( isLoading ) {
71
- return < div className = "w-8 h-8 border-b-2 border-gray-900 rounded-full animate-spin mx-auto my-auto" > </ div > ;
72
- }
70
+ // if (isLoading) {
71
+ // return <div className="w-8 h-8 border-b-2 border-gray-900 rounded-full animate-spin mx-auto my-auto"></div>;
72
+ // }
73
73
74
- if ( error ) {
75
- return < div > Error: { error } </ div > ;
76
- }
74
+ // if (error) {
75
+ // return <div>Error: {error}</div>;
76
+ // }
77
77
78
78
return (
79
79
< div className = "max-w-[95%] h-auto mx-auto my-auto overflow-y-scroll overflow-x-scroll bg-white rounded-md" >
0 commit comments