From 2ea5bf80aaec12f3153ab0574ec7d847ce51ef7f Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Thu, 9 Apr 2026 09:13:18 +0200 Subject: [PATCH] feat: add undo button in DimensionsView for pending changes --- AGENTS.md | 96 +++++-------------------------- src/App.tsx | 1 + src/components/DimensionsView.tsx | 14 ++++- 3 files changed, 28 insertions(+), 83 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index def1ac1..dcb150d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,7 +15,7 @@ npm run clean # Remove dist folder npm run lint # TypeScript type check only (tsc --noEmit) ``` -Note: This project does not have a separate test framework configured. To add tests, consider installing Vitest or Jest. +Note: No test framework configured. To add tests, install Vitest or Jest. --- @@ -27,10 +27,8 @@ Note: This project does not have a separate test framework configured. To add te - Keep components focused and modular - Use meaningful variable and function names -### Imports - -**Order (top to bottom):** -1. React imports (`react`) +### Imports (order top to bottom) +1. React (`react`) 2. External libraries (`lucide-react`, `xlsx`, etc.) 3. Internal components (`./components/...`) 4. Internal lib/utils (`./lib/...`) @@ -44,19 +42,16 @@ import { cn } from '../lib/utils'; ``` ### TypeScript Conventions - - Use explicit types for props and function parameters - Use `any` sparingly; prefer union types or interfaces - Define column indices in a centralized `COLUMNS` object (see `src/types.ts`) ```typescript -// Good interface ProductDescriptionsProps { data: ExcelRow[]; onEdit: (index: number) => void; } -// Good - centralized constants export const COLUMNS = { ARTICLE_NO: 0, ARTICLE_NAME: 2, @@ -76,119 +71,58 @@ export const COLUMNS = { | Types | PascalCase | `TabType`, `SortDirection` | ### React Patterns - - Destructure props in function signature - Use `useMemo` for expensive computations - Use `useCallback` for event handlers passed to child components - Keep `useState` calls at the top of component -```typescript -export function ProductDescriptions({ data, onEdit }: ProductDescriptionsProps) { - const [activeTab, setActiveTab] = useState('all'); - const [search, setSearch] = useState(''); - - const filteredData = useMemo(() => { - // expensive computation - }, [data, activeTab, search]); -} -``` - ### Error Handling - - Use TypeScript's type system for runtime safety - Use optional chaining (`?.`) and nullish coalescing (`??`) - Validate file uploads with proper type checks -```typescript -const file = e.target.files?.[0]; -if (!file) return; - -// Validate Excel data -if (data.length > 0) { - const rawHeaders = data[0]; - const rawRows = data.slice(1); -} -``` - ### UI/Styling - - Use Tailwind CSS for all styling - Use `cn()` utility from `lib/utils` for conditional classes - Follow existing color scheme (slate, blue, green, red for status) - Use `lucide-react` for icons -- Keep responsive design in mind ```typescript -import { cn } from '../lib/utils'; - - + {isPending && ( + + )}