Skip to content

Commit a621deb

Browse files
committed
fix: Align pnpm setup with packageManager and fix Recharts tooltip typing
1 parent 10c05e0 commit a621deb

2 files changed

Lines changed: 50 additions & 24 deletions

File tree

.github/workflows/deploy-storybook.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ jobs:
2626

2727
- name: Install pnpm
2828
uses: pnpm/action-setup@v4
29-
with:
30-
version: 10.10.0
3129

3230
- name: Setup Node
3331
uses: actions/setup-node@v4

src/pages/Professor/ProfessorAnalyticsPage.tsx

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ import {
1818
import { useProfessorAnalytics } from '../../hooks/useProfessor.ts';
1919
import { formatCurrency, toAmount } from '../../lib/currency';
2020

21+
type MonthlyRevenuePoint = {
22+
month: string;
23+
revenue: number;
24+
sales: number;
25+
};
26+
2127
const ProfessorAnalyticsPage = () => {
2228
const { data: analyticsData, isLoading } = useProfessorAnalytics();
2329

@@ -26,26 +32,27 @@ const ProfessorAnalyticsPage = () => {
2632
const totalEarningsInCents = analyticsData?.totalEarningsInCents ?? 0;
2733
const totalSales = analyticsData?.totalSales ?? 0;
2834

29-
// Transformar datos mensuales para el gráfico
30-
const monthlyRevenueData =
35+
const monthNames = [
36+
'Ene',
37+
'Feb',
38+
'Mar',
39+
'Abr',
40+
'May',
41+
'Jun',
42+
'Jul',
43+
'Ago',
44+
'Sep',
45+
'Oct',
46+
'Nov',
47+
'Dic',
48+
];
49+
50+
const monthlyRevenueData: MonthlyRevenuePoint[] =
3151
analyticsData?.monthlyEarnings?.map((item) => {
32-
// Convertir formato "2025-10" a nombre de mes
33-
const [, monthNum] = item.month.split('-');
34-
const monthNames = [
35-
'Ene',
36-
'Feb',
37-
'Mar',
38-
'Abr',
39-
'May',
40-
'Jun',
41-
'Jul',
42-
'Ago',
43-
'Sep',
44-
'Oct',
45-
'Nov',
46-
'Dic',
47-
];
48-
const monthName = monthNames[parseInt(monthNum) - 1];
52+
const parts = item.month.split('-');
53+
const monthNum = parts[1] ?? '01';
54+
const monthIndex = Math.max(0, Math.min(11, parseInt(monthNum, 10) - 1));
55+
const monthName = monthNames[monthIndex] ?? monthNum;
4956

5057
return {
5158
month: monthName,
@@ -69,6 +76,7 @@ const ProfessorAnalyticsPage = () => {
6976
)}
7077
</CardHeader>
7178
</Card>
79+
7280
<Card>
7381
<CardHeader>
7482
<CardDescription>Estudiantes totales</CardDescription>
@@ -81,6 +89,7 @@ const ProfessorAnalyticsPage = () => {
8189
)}
8290
</CardHeader>
8391
</Card>
92+
8493
<Card>
8594
<CardHeader>
8695
<CardDescription>Cursos publicados</CardDescription>
@@ -91,6 +100,7 @@ const ProfessorAnalyticsPage = () => {
91100
)}
92101
</CardHeader>
93102
</Card>
103+
94104
<Card>
95105
<CardHeader>
96106
<CardDescription>Ventas totales</CardDescription>
@@ -108,6 +118,7 @@ const ProfessorAnalyticsPage = () => {
108118
<CardTitle>Ingresos Mensuales</CardTitle>
109119
<CardDescription>Tus ingresos de los últimos meses</CardDescription>
110120
</CardHeader>
121+
111122
<CardContent>
112123
{isLoading ? (
113124
<div className="h-[300px] bg-slate-200 rounded animate-pulse"></div>
@@ -128,8 +139,24 @@ const ProfessorAnalyticsPage = () => {
128139
border: '1px solid #e2e8f0',
129140
borderRadius: '0.5rem',
130141
}}
131-
formatter={(value: number, name: string) => {
132-
if (name === 'revenue') {
142+
formatter={(
143+
value: number | string | Array<number | string> | undefined,
144+
name: string | number | undefined
145+
) => {
146+
const safeName = String(name ?? '');
147+
148+
if (value === undefined) {
149+
return ['-', safeName === 'sales' ? 'Ventas' : safeName];
150+
}
151+
152+
if (Array.isArray(value)) {
153+
return [
154+
value,
155+
safeName === 'sales' ? 'Ventas' : safeName,
156+
];
157+
}
158+
159+
if (safeName === 'revenue' && typeof value === 'number') {
133160
return [
134161
'$' +
135162
value.toLocaleString('es-AR', {
@@ -139,7 +166,8 @@ const ProfessorAnalyticsPage = () => {
139166
'Ingresos',
140167
];
141168
}
142-
return [value, name === 'sales' ? 'Ventas' : name];
169+
170+
return [value, safeName === 'sales' ? 'Ventas' : safeName];
143171
}}
144172
/>
145173
<Legend />

0 commit comments

Comments
 (0)