This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, useCallback } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { useCounters } from '../hooks/useCounters';
|
||||
import { useAuth } from '../hooks/useAuth';
|
||||
import { CounterWithStats, CounterEntry } from '../types';
|
||||
import { countersAPI } from '../services/api';
|
||||
import { ArrowLeft, Plus, Minus, Edit, Trash2, Calendar, TrendingUp } from 'lucide-react';
|
||||
import { ArrowLeft, Plus, Minus, Trash2, Calendar } from 'lucide-react';
|
||||
import { format } from 'date-fns';
|
||||
|
||||
export const CounterDetail: React.FC = () => {
|
||||
@@ -19,13 +19,7 @@ export const CounterDetail: React.FC = () => {
|
||||
const [isIncrementing, setIsIncrementing] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (id) {
|
||||
loadCounterData();
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
const loadCounterData = async () => {
|
||||
const loadCounterData = useCallback(async () => {
|
||||
if (!id) return;
|
||||
|
||||
setIsLoading(true);
|
||||
@@ -95,7 +89,13 @@ export const CounterDetail: React.FC = () => {
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
}, [id, isAuthenticated]);
|
||||
|
||||
useEffect(() => {
|
||||
if (id) {
|
||||
loadCounterData();
|
||||
}
|
||||
}, [id, loadCounterData]);
|
||||
|
||||
const handleIncrement = async (value: number) => {
|
||||
if (!counter) return;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useCounters } from '../hooks/useCounters';
|
||||
import { useAuth } from '../hooks/useAuth';
|
||||
import { CreateCounterModal } from './CreateCounterModal';
|
||||
|
||||
Reference in New Issue
Block a user