Files
tilbudgivern/_archive/IMPLEMENTATION_PLAN.md
alexpolo1 eb03213f16 oprydning
2025-11-26 12:36:27 +00:00

341 lines
11 KiB
Markdown

# Implementation Plan - Tilbudgivern System Fixes
**Dato**: 14. November 2025
**Basis**: FIX_LISTE_NOV_14.md (1388 linjer, 36 punkter)
**Status**: Investigation afsluttet ✅ - Klar til implementation
---
## 🎯 Executive Summary
**Total arbejde identificeret**: 45-60 timer
**Kritiske issues**: 4 (Velux, GraphQL, Ordrestyring, .env)
**Allerede implementeret**: 5 features (PDF, Auto-save, Sort, History backend, Mobile CSS)
**Delvist implementeret**: 6 features (Search, Excel, Notifications, Filtering, Analytics, Bulk import)
**Mangler helt**: 5 features (Dark mode, Keyboard, Bulk ops, API routing fix)
**Kræver afklaring**: 10 spørgsmål
---
## 🚦 PRIORITERET IMPLEMENTATION PLAN
### FASE 1: KRITISKE FIXES (Højeste prioritet)
**Total estimat**: 7-10 timer
**Business impact**: System stabilitet + core funktionalitet
#### 1.1 GraphQL Pagination Crashes (PM2 30 restarts/82min)
- **Prioritet**: 🔴 KRITISK
- **Estimat**: 2-3 timer
- **Impact**: System ustabilitet - crashes hver 3. minut
- **Løsning**:
- Grep ALL `graphqlClient.request()` calls i unified-server.js (11,548 linjer)
- Add pagination validation: `limit: Math.min(limit || 100, 200)`
- Test GraphQL endpoints: /analytics/kpis, /analytics/cases
- **Files**: `backend/unified-server.js` - grep for graphqlClient
- **Success criteria**: PM2 0 restarts i 24 timer
#### 1.2 Velux Produkter Missing (0 i database)
- **Prioritet**: 🔴 KRITISK
- **Estimat**: 4-6 timer
- **Impact**: Kunder kan ikke søge/bestille Velux produkter
- **Løsning**:
- **Option A**: Import fra Stark prisbog (CSV/API)
- **Option B**: Manuel indtastning top 20 Velux SKUs
- Opret supplier_id=52 for Stark
- Import 100-150 Velux vinduer + tilbehør
- **Files**: `database/materials`, `backend/src/services/starkImportService.js`
- **TODO**: Hvilken kilde er tilgængelig? Stark CSV? API? Manual entry?
#### 1.3 Ordrestyring Integration Error
- **Prioritet**: 🔴 KRITISK
- **Estimat**: 1-2 timer
- **Impact**: "Hent fra Ordrestyring" button fejler
- **Løsning**:
- Fix line 9490: `ordrestyringService is not defined`
- Import service eller fix GraphQL query
- Test customer sync fra ordrestyring_local database
- **Files**: `backend/unified-server.js` line 9490
- **Success criteria**: Customer sync fungerer fra UI
#### 1.4 Security: .env Missing (Hardcoded Credentials)
- **Prioritet**: 🔴 KRITISK (Security)
- **Estimat**: 30 minutter
- **Impact**: Credentials exposed i kode (REDACTED_PASSWORD, REDACTED_AUTH)
- **Løsning**:
- Create `.env.example` template
- Document all variables: DB_HOST, DB_USER, DB_PASS, OPENAI_API_KEY, etc.
- Update README with environment setup instructions
- **Files**: Create `.env.example`, update `README.md`
---
### FASE 2: QUICK WINS (Lav effort, høj synlighed)
**Total estimat**: 1-2 timer
**Business impact**: Hurtig fremgang, brugervenlighedsforbed
ringer
#### 2.1 Fix Port Documentation (3001→3000)
- **Estimat**: 5 minutter
- **Løsning**: Update README.md line ~20: Change port 3001 → 3000
- **Files**: `README.md`
#### 2.2 Rename "Projektnavn" → "Navn" (Point 19)
- **Estimat**: 5-10 minutter
- **Løsning**: ProjectCreation.js line 489 - rename label
- **Files**: `frontend/src/components/ProjectCreation.js`
#### 2.3 Auto-save Interval (3 sec → 30 sec?)
- **Estimat**: 15-30 minutter
- **Løsning**: GeometryInput.js line 475 - change `3000``30000`
- **Files**: `frontend/src/components/GeometryInput.js`
- **TODO**: Confirm user wants 30-second auto-save vs 3-second debounce
#### 2.4 API Routing Fix (Catch-all interference)
- **Estimat**: 1-2 timer
- **Løsning**: Add API 404 handler BEFORE catch-all at line 11508
- **Files**: `backend/unified-server.js` line 11508-11514
---
### FASE 3: JANNICKS UI/UX FIXES (15 punkter)
**Total estimat**: 10-15 timer
**Business impact**: Brugeroplevelse forbedring
**Kræver afklaringer først** (~5-7 spørgsmål):
1. **Point 8 (Beskrivelse)**: Hvilket beskrivelse-felt skal flyttes? (multiple found)
2. **Point 10 (Dropdown filter)**: Hvor skal det være? (ingen lokation)
3. **Point 6 (Felter skævt)**: Hvilke specifikke felter? (9 alignment issues found)
4. **Point 7 (Tilbage-knap)**: Hvilken side? (18 back buttons exist)
5. **Point 13 (Kunde edit)**: CustomerSearch.js line 325-375 exists - bug eller feature?
**Kan fixes direkte**:
- Point 5: Opgavetype missing - 1 time
- Point 9: Tilbud navn wrapping - 30 min CSS
- Point 11: Sagsnummer display - 1 time
- Point 12: Kategorier fra DB - 2-3 timer
- Point 14: Ordrestyring button - depends on 1.3 fix
- Point 15: Kunde delete removal - 10 min
- Point 19: Projektnavn rename - 5 min (quick win)
---
### FASE 4: FEATURE AKTIVERING (Already implemented)
**Total estimat**: 3-5 timer
**Business impact**: Aktivér eksisterende funktionalitet
#### 4.1 Aktiver Notifications (notistack)
- **Estimat**: 1-2 timer
- **Status**: Library installeret men ikke brugt
- **Løsning**:
- Wrap App.js med `<SnackbarProvider>`
- Create useNotification hook
- Replace alert() calls i 10-15 komponenter
- **Files**: `frontend/src/App.js`, create `frontend/src/hooks/useNotification.js`
#### 4.2 History UI (Backend ready)
- **Estimat**: 3-4 timer
- **Status**: Database + API endpoints exists
- **Løsning**:
- Create PriceHistory.js component
- Install recharts for timeline visualization
- Add "📊 Se Prishistorik" button i MaterialsList
- **Files**: Create `frontend/src/components/PriceHistory.js`
---
### FASE 5: FEATURE FORBEDRINGER
**Total estimat**: 10-15 timer
**Business impact**: Performance + usability
#### 5.1 Search Optimization (FULLTEXT indexes)
- **Estimat**: 2-3 timer
- **Impact**: 10-100x faster search
- **Løsning**:
- Add MySQL FULLTEXT indexes på materials, customers, projects
- Update LIKE queries → MATCH AGAINST
- Create migration file
- **Files**: New migration, `backend/unified-server.js` search endpoints
#### 5.2 Excel Import (XLSX parser)
- **Estimat**: 2-3 timer
- **Status**: CSV works, XLSX missing
- **Løsning**:
- Install `xlsx` library
- Create /api/pricing/excel-import endpoint
- Add UI button "📊 Importer Excel"
- Create template file
- **Files**: `backend/src/routes/uploads.js`, `MaterialsList.js`
#### 5.3 Mobile Testing
- **Estimat**: 2-3 timer
- **Status**: Responsive CSS exists
- **Løsning**:
- Test on actual devices (iPhone, Android, iPad)
- Chrome DevTools mobile simulation
- Fix touch targets, text sizes, scroll issues
- **Files**: Various CSS files
#### 5.4 Dropdown Sort Standardization
- **Estimat**: 1-2 timer
- **Status**: Partial - ProjectCreation done, others missing UI
- **Løsning**:
- Add sortBy dropdown to MaterialsList, PlanningDashboard
- Standardize sort options: Navn, Dato, Pris, Kategori
- **Files**: `MaterialsList.js`, `PlanningDashboard.js`
---
### FASE 6: NYE FEATURES (Not implemented)
**Total estimat**: 15-25 timer
**Business impact**: New capabilities
#### 6.1 Bulk Operations
- **Estimat**: 3-4 timer
- **Løsning**:
- Multi-select checkboxes i CompletedQuotes, MaterialsList
- Bulk actions: Archive, Export, Delete
- Backend bulk endpoints
- **Files**: `CompletedQuotes.js`, `MaterialsList.js`, `unified-server.js`
#### 6.2 Advanced Filtering
- **Estimat**: 2-3 timer
- **Løsning**:
- Date range picker
- Price range sliders
- Customer search filter
- Created by filter
- **Files**: `CompletedQuotes.js` add filter panel
#### 6.3 Analytics Expansion
- **Estimat**: 4-5 timer
- **Løsning**:
- Install recharts
- Add 4-5 charts (line, bar, pie, area)
- Date range selector
- Export to PDF
- **Files**: `AnalyticsDashboard.js`, `frontend/package.json`
#### 6.4 Dark Mode
- **Estimat**: 2-3 timer
- **Løsning**:
- Create theme.js with light/dark themes
- Add ThemeProvider + toggle button
- Update CSS to use theme variables
- **Files**: Create `frontend/src/theme.js`, update `App.js`
#### 6.5 Keyboard Shortcuts
- **Estimat**: 1-2 timer
- **Løsning**:
- Create useKeyboardShortcuts hook
- Add Ctrl+S (save), Ctrl+N (new), Ctrl+F (search), Escape (cancel)
- Shortcut help dialog (press ?)
- **Files**: Create `frontend/src/hooks/useKeyboardShortcuts.js`
---
### FASE 7: DATA INTEGRITY
**Total estimat**: 5-10 timer
**Business impact**: Data quality + completeness
#### 7.1 Fix Missing Prices (18/62 materials = 29%)
- **Estimat**: Varies (1-4 timer)
- **Options**:
- A: Bygma re-import (2-3 timer)
- B: Manual price UI (3-4 timer)
- C: Default averages (1-2 timer)
- **TODO**: Hvilken approach?
#### 7.2 Bulk Material Import (62 → 500+)
- **Estimat**: Varies (1-6 timer)
- **Options**:
- Bygma Prof prisbog: 1-2 timer (re-run existing import)
- Stark import: 4-6 timer (create new parser)
- Excel template: 2-3 timer (use Point 5.2 solution)
- **TODO**: Prioritize sources?
---
## ❓ CLARIFICATION QUESTIONS (10 total)
1. **Velux import**: Stark CSV tilgængelig? API? Manual entry acceptable?
2. **Auto-save**: 3 sekunder debounce eller 30 sekunder periodic?
3. **Beskrivelse felt**: Hvilket specifikt felt skal flyttes?
4. **Dropdown filter**: Hvor skal det være? (ingen lokation i Jannicks email)
5. **Felter alignment**: Hvilke specifikke felter er problemet?
6. **Tilbage-knap**: Hvilken side mangler den? (18 exists)
7. **Complexity removal**: Hvorfor fjerne? Bruges i cost calculations
8. **Missing prices**: Bygma import? Manual UI? Default averages?
9. **Bulk import**: Prioriter Bygma, Stark, eller Excel?
10. **Feature priority**: Dark mode, keyboard, bulk ops - hvilke først?
---
## 📊 ANBEFALEDE PRIORITERING
### ANBEFALING 1: START MED STABILITET
**Uge 1** (7-10 timer):
- ✅ GraphQL pagination fix (2-3h) - Stop crashes
- ✅ Ordrestyring integration (1-2h) - Fix critical button
- ✅ .env security (30min) - Security best practice
- ✅ Quick wins (1-2h) - Show progress
### ANBEFALING 2: DEREFTER VELUX + UI
**Uge 2** (10-15 timer):
- ✅ Velux import (4-6h) - Critical user need
- ✅ Afklar Jannicks 5-7 spørgsmål
- ✅ Fix top 5 UI issues (5-8h)
### ANBEFALING 3: AKTIVÉR FEATURES
**Uge 3** (8-12 timer):
- ✅ Notifications aktivering (1-2h)
- ✅ Search optimization (2-3h)
- ✅ Excel import (2-3h)
- ✅ Mobile testing (2-3h)
- ✅ History UI (3-4h)
### ANBEFALING 4: NYE FEATURES (Optional)
**Uge 4+** (15-25 timer):
- Advanced filtering (2-3h)
- Bulk operations (3-4h)
- Analytics expansion (4-5h)
- Dark mode (2-3h)
- Keyboard shortcuts (1-2h)
- Bulk material import (varies)
---
## 🎯 SUCCESS METRICS
**System Stabilitet**:
- ✅ PM2 zero restarts i 24 timer
- ✅ Alle critical endpoints returnerer JSON (ikke HTML)
- ✅ No hardcoded credentials
**User Experience**:
- ✅ Velux search returns results
- ✅ "Hent fra Ordrestyring" button works
- ✅ Notifications vises for alle actions
- ✅ Mobile responsive tested på 3+ devices
**Data Quality**:
- ✅ 100% materials har priser (0% missing)
- ✅ 500+ materials i database (fra 62)
- ✅ Price history synlig i UI
**Performance**:
- ✅ Search responds <1 sekund (fra 3-5 sek med LIKE)
- FULLTEXT indexes 3 tables
- GraphQL queries validated
---
## 📝 NEXT STEPS
1. **Review denne plan** med bruger/stakeholders
2. **Besvar 10 clarification questions**
3. **Godkend prioritering** (følg anbefaling eller tilpas)
4. **Start FASE 1** (Kritiske fixes - 7-10 timer)
5. **Daily progress updates** via FIX_LISTE_NOV_14.md
**Ready to start?** 🚀