-
- {counter.total_value}
-
-
Total Count
-
-
+ {/* Increment Controls */}
+
+
Quick Actions
+
+
+
+
+
+
-
-
-
- {/* Stats Grid */}
-
-
-
{counter.today_value}
-
Today
-
-
-
{counter.week_value}
-
This Week
-
-
-
{counter.month_value}
-
This Month
@@ -234,17 +209,14 @@ export const CounterDetail: React.FC = () => {
className="flex justify-between items-center py-2 px-4 bg-gray-50 rounded-lg"
>
-
0 ? 'bg-green-500' : 'bg-red-500'
- }`} />
-
+
{format(new Date(entry.date), 'MMM dd, yyyy')}
-
+
-
0 ? 'text-green-600' : 'text-red-600'
- }`}>
- {entry.value > 0 ? '+' : ''}{entry.value}
+
+ = 0 ? 'text-green-600' : 'text-red-600'}`}>
+ {entry.value > 0 ? '+' : ''}{entry.value}
+
))}
@@ -253,4 +225,4 @@ export const CounterDetail: React.FC = () => {
);
-};
+};
\ No newline at end of file
diff --git a/frontend/src/components/CreateCounterModal.tsx b/frontend/src/components/CreateCounterModal.tsx
index 549e37c..b0a9650 100644
--- a/frontend/src/components/CreateCounterModal.tsx
+++ b/frontend/src/components/CreateCounterModal.tsx
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { useForm } from 'react-hook-form';
-import { useCounters } from '../hooks/useCounters';
+import { useCountersContext } from '../contexts/CountersContext';
import { CreateCounterRequest } from '../types';
import { X } from 'lucide-react';
@@ -9,7 +9,7 @@ interface CreateCounterModalProps {
}
export const CreateCounterModal: React.FC
= ({ onClose }) => {
- const { createCounter } = useCounters();
+ const { createCounter } = useCountersContext();
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(null);
diff --git a/frontend/src/components/Dashboard.tsx b/frontend/src/components/Dashboard.tsx
index 2be3583..13b754b 100644
--- a/frontend/src/components/Dashboard.tsx
+++ b/frontend/src/components/Dashboard.tsx
@@ -1,12 +1,13 @@
-import React, { useState } from 'react';
-import { useCounters } from '../hooks/useCounters';
+import React, { useState, useEffect } from 'react';
+import { useCountersContext } from '../contexts/CountersContext';
import { useAuth } from '../hooks/useAuth';
import { CreateCounterModal } from './CreateCounterModal';
import { CounterCard } from './CounterCard';
import { Plus, Search, TrendingUp, Calendar, Clock } from 'lucide-react';
export const Dashboard: React.FC = () => {
- const { counters, isLoading, error, searchCounters } = useCounters();
+ console.log('Dashboard: Component rendering...');
+ const { counters, isLoading, error, searchCounters, version, incrementCounter, deleteCounter } = useCountersContext();
const { isAuthenticated } = useAuth();
const [showCreateModal, setShowCreateModal] = useState(false);
const [searchQuery, setSearchQuery] = useState('');
@@ -16,6 +17,11 @@ export const Dashboard: React.FC = () => {
searchCounters(query);
};
+ useEffect(() => {
+ console.log('Dashboard: Counters changed:', counters, 'version:', version);
+ }, [counters, version]);
+
+ console.log('Dashboard: Current counters:', counters, 'version:', version);
const totalCounters = counters?.length || 0;
const totalValue = counters?.reduce((sum, counter) => sum + counter.total_value, 0) || 0;
const todayValue = counters?.reduce((sum, counter) => sum + counter.today_value, 0) || 0;
@@ -41,6 +47,7 @@ export const Dashboard: React.FC = () => {
}