Skip to content

Commit 794a9cf

Browse files
committed
Error fixed
1 parent 920074c commit 794a9cf

File tree

1 file changed

+57
-57
lines changed

1 file changed

+57
-57
lines changed

src/pages/vendorcomponents/topProducts.tsx

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useState, useEffect } from 'react';
2-
import axios from 'axios';
1+
// import { useState, useEffect } from 'react';
2+
// import axios from 'axios';
33

44
import {
55
Table,
@@ -10,70 +10,70 @@ import {
1010
TableRow,
1111
} from "../../../src/components/ui/table"
1212

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+
// }
4040

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+
// }
4747

4848
const TopProducts = () => {
4949

5050
// 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);
5353

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+
// };
6666

67-
fetchData();
68-
}, []);
67+
// fetchData();
68+
// }, []);
6969

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+
// }
7373

74-
if (error) {
75-
return <div>Error: {error}</div>;
76-
}
74+
// if (error) {
75+
// return <div>Error: {error}</div>;
76+
// }
7777

7878
return (
7979
<div className="max-w-[95%] h-auto mx-auto my-auto overflow-y-scroll overflow-x-scroll bg-white rounded-md">

0 commit comments

Comments
 (0)