basic frontend #3

Merged
alexandvvvvv merged 14 commits from feature/base into main 2025-10-03 16:25:14 +00:00
3 changed files with 12 additions and 13 deletions
Showing only changes of commit 5cde4bf00a - Show all commits

View File

@@ -24,8 +24,8 @@ WORKDIR /app/frontend
# Copy package files # Copy package files
COPY frontend/package*.json ./ COPY frontend/package*.json ./
# Install dependencies # Install dependencies (including dev dependencies for build)
RUN npm ci --only=production RUN npm ci
# Copy source code # Copy source code
COPY frontend/ ./ COPY frontend/ ./

View File

@@ -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 { useParams, useNavigate } from 'react-router-dom';
import { useCounters } from '../hooks/useCounters'; import { useCounters } from '../hooks/useCounters';
import { useAuth } from '../hooks/useAuth'; import { useAuth } from '../hooks/useAuth';
import { CounterWithStats, CounterEntry } from '../types'; import { CounterWithStats, CounterEntry } from '../types';
import { countersAPI } from '../services/api'; 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'; import { format } from 'date-fns';
export const CounterDetail: React.FC = () => { export const CounterDetail: React.FC = () => {
@@ -19,13 +19,7 @@ export const CounterDetail: React.FC = () => {
const [isIncrementing, setIsIncrementing] = useState(false); const [isIncrementing, setIsIncrementing] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
useEffect(() => { const loadCounterData = useCallback(async () => {
if (id) {
loadCounterData();
}
}, [id]);
const loadCounterData = async () => {
if (!id) return; if (!id) return;
setIsLoading(true); setIsLoading(true);
@@ -95,7 +89,13 @@ export const CounterDetail: React.FC = () => {
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
}; }, [id, isAuthenticated]);
useEffect(() => {
if (id) {
loadCounterData();
}
}, [id, loadCounterData]);
const handleIncrement = async (value: number) => { const handleIncrement = async (value: number) => {
if (!counter) return; if (!counter) return;

View File

@@ -1,5 +1,4 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import { useCounters } from '../hooks/useCounters'; import { useCounters } from '../hooks/useCounters';
import { useAuth } from '../hooks/useAuth'; import { useAuth } from '../hooks/useAuth';
import { CreateCounterModal } from './CreateCounterModal'; import { CreateCounterModal } from './CreateCounterModal';