# Phase 5: DashboardView.vue - Major Refactoring 🚀
**Priority:** 🔥 CRITICAL - Biggest impact
**Duration:** 24-32 hours
**Status:** ⏸️ Not Started
**Risk Level:** ⚠️ VERY HIGH
---
## Obiective
1. **Reduce 2,010 lines → 300 lines** - 85% reduction (1,710 lines eliminated)
2. **Replace custom CSS with global patterns** - Use Phase 2-4 work
3. **Consolidate responsive breakpoints** - 4 breakpoints → 1
4. **Eliminate table duplication** - Use tables.css
5. **MAINTAIN IDENTICAL FUNCTIONALITY** - Zero breaking changes
---
## RISK MITIGATION
**⚠️ THIS IS THE MOST CRITICAL PHASE**
**Mitigation Strategies:**
1. **Full backup before starting**
2. **Incremental changes with commits**
3. **Test after every section**
4. **Playwright snapshots before/after each step**
5. **Real device testing mandatory**
6. **Rollback plan ready**
---
## Current State Analysis
**File:** `src/views/DashboardView.vue`
**Total lines:** 4,010
**CSS lines:** 2,010 (lines 787-2797)
**CSS percentage:** 50% of file
### CSS Breakdown:
| Section | Lines | Can Delete? | Replacement |
|---------|-------|-------------|-------------|
| Dashboard header | 50 | ✅ Yes | dashboard.css `.page-header` |
| Section headers | 100 | ✅ Yes | dashboard.css `.section-header` |
| Card containers | 80 | ✅ Yes | cards.css (Phase 4) |
| Table styles | 400 | ✅ Yes | tables.css |
| Stats/metrics | 200 | ✅ Yes | dashboard.css metrics |
| Loading spinner | 40 | ✅ Yes | interactive.css |
| Breakdowns | 120 | ✅ Yes | dashboard.css breakdowns |
| Animations | 60 | ✅ Yes | animations.css |
| Responsive (4 breakpoints) | 600 | ⚠️ Partial | Consolidate to 1 |
| Component-specific | 360 | ❌ Keep | Unique logic |
| **TOTAL** | **2,010** | **1,650** | **~300 remain** |
---
## Task Breakdown (28 tasks)
### 1. Preparation & Backup (2 tasks)
#### Task 1.1: Full Backup
**Status:** ⏸️ | **Est:** 10 min
```bash
# Create backup
cp src/views/DashboardView.vue src/views/DashboardView.vue.phase5.backup
# Commit current state
git add .
git commit -m "chore: Backup DashboardView before Phase 5 refactoring"
# Create restore script
cat > /tmp/restore-dashboard.sh <<'EOF'
#!/bin/bash
cp src/views/DashboardView.vue.phase5.backup src/views/DashboardView.vue
echo "DashboardView restored from backup"
EOF
chmod +x /tmp/restore-dashboard.sh
```
**Acceptance Criteria:**
- [ ] Backup file created
- [ ] Committed to git
- [ ] Restore script ready
---
#### Task 1.2: Detailed CSS Analysis
**Status:** ⏸️ | **Est:** 30 min
**Analyze all 2,010 CSS lines:**
```bash
# Extract CSS section
sed -n '787,2797p' src/views/DashboardView.vue > /tmp/dashboard-css-analysis.css
# Count by pattern
grep -c "\.dashboard-" /tmp/dashboard-css-analysis.css
grep -c "\.section-" /tmp/dashboard-css-analysis.css
grep -c "@media" /tmp/dashboard-css-analysis.css
```
**Document:**
- [ ] All class names used
- [ ] Media query breakpoints
- [ ] Duplicate patterns
- [ ] Component-specific needs
**Acceptance Criteria:**
- [ ] Full CSS inventory
- [ ] Deletion plan documented
- [ ] Keep list documented
---
### 2. Page Structure Refactoring (4 tasks)
#### Task 2.1: Convert Page Header
**Status:** ⏸️ | **Est:** 45 min
**BEFORE (template lines ~50-70):**
```vue
```
**AFTER:**
```vue
```
**DELETE CSS (lines 789-840):**
```css
/* DELETE - now in dashboard.css */
.dashboard-header {
text-align: center;
margin-bottom: var(--space-lg);
/* ... */
}
.dashboard-title {
font-size: 2.5rem;
/* ... */
}
.dashboard-subtitle {
/* ... */
}
```
**Test:**
- [ ] Header renders identically
- [ ] Icon displays
- [ ] Company name shows
**Acceptance Criteria:**
- [ ] Template updated
- [ ] ~50 lines CSS deleted
- [ ] Visual identical
---
#### Task 2.2: Convert Section Headers
**Status:** ⏸️ | **Est:** 1 hour
**Find all section headers (~4-5 instances):**
```vue
```
**AFTER:**
```vue
```
**DELETE CSS (~100 lines):**
```css
/* DELETE - dashboard.css provides these */
.dashboard-section {
background: var(--color-bg);
border: 1px solid var(--color-border);
/* ... */
}
.section-header {
display: flex;
justify-content: space-between;
/* ... */
}
.section-title {
font-size: var(--text-xl);
/* ... */
}
.section-controls {
/* ... */
}
```
**Test each section:**
- [ ] Vânzări section
- [ ] Achiziții section
- [ ] Trezorerie section
- [ ] Clienți section
- [ ] Furnizori section
**Acceptance Criteria:**
- [ ] All sections use global pattern
- [ ] ~100 lines deleted
- [ ] Layout identical
---
#### Task 2.3: Simplify Container Layout
**Status:** ⏸️ | **Est:** 30 min
**DELETE:**
```css
/* DELETE - use containers.css */
.dashboard-container {
max-width: 1400px;
margin: 0 auto;
padding: var(--space-xl);
}
.dashboard-content {
display: flex;
flex-direction: column;
gap: var(--space-xl);
}
```
**REPLACE with:**
```vue
```
**Acceptance Criteria:**
- [ ] Container uses global class
- [ ] ~30 lines deleted
- [ ] Width/padding correct
---
#### Task 2.4: Remove Card Container Duplicates
**Status:** ⏸️ | **Est:** 30 min
**Already using card components from Phase 4:**
```vue
```
**DELETE any card wrapper CSS:**
```css
/* DELETE - cards handle their own styling */
.metrics-container {
/* ... */
}
.card-wrapper {
/* ... */
}
```
**Acceptance Criteria:**
- [ ] Cards render from Phase 4
- [ ] No wrapper CSS needed
- [ ] ~80 lines deleted
---
### 3. Table Styles Replacement (3 tasks)
#### Task 3.1: Replace Dashboard Tables
**Status:** ⏸️ | **Est:** 2 hours
**BEFORE:**
```vue
```
**AFTER:**
```vue
```
**DELETE CSS (lines 899-1300 - ~400 lines!):**
```css
/* DELETE ALL - tables.css provides */
.dashboard-table {
width: 100%;
border-collapse: collapse;
/* ... 400 lines ... */
}
.dashboard-table th {
/* ... */
}
.dashboard-table td {
/* ... */
}
.dashboard-table tbody tr:hover {
/* ... */
}
/* ... many more table rules ... */
```
**Test tables:**
- [ ] Vânzări table
- [ ] Achiziții table
- [ ] Recent transactions table
- [ ] All styling correct
- [ ] Hover effects work
- [ ] Responsive behavior
**Acceptance Criteria:**
- [ ] All tables use tables.css
- [ ] ~400 lines deleted
- [ ] Tables look identical
---
#### Task 3.2: Add Table Utilities
**Status:** ⏸️ | **Est:** 20 min
**Use utility classes:**
```vue
{{ value }} |
{{ status }} |
{{ number }} |
```
**Acceptance Criteria:**
- [ ] Numeric values right-aligned
- [ ] Status centered
- [ ] Numbers use monospace
---
#### Task 3.3: Test Table Responsiveness
**Status:** ⏸️ | **Est:** 30 min
**Mobile behavior:**
- [ ] Tables scroll horizontally on mobile
- [ ] Headers sticky
- [ ] Touch-friendly row height
**Acceptance Criteria:**
- [ ] Tables work on mobile
- [ ] No layout breaks
- [ ] Usable on small screens
---
### 4. Stats & Metrics (3 tasks)
#### Task 4.1: Use Metric Card Patterns
**Status:** ⏸️ | **Est:** 1 hour
**Already done in Phase 4:**
```vue
```
**DELETE any remaining stat CSS:**
```css
/* DELETE - card components handle this */
.stat-display {
/* ... */
}
.stat-value {
/* ... */
}
.stat-label {
/* ... */
}
```
**Acceptance Criteria:**
- [ ] All stats use metric cards
- [ ] ~200 lines deleted
- [ ] Displays identical
---
#### Task 4.2: Remove Duplicate Trends
**Status:** ⏸️ | **Est:** 20 min
**DELETE:**
```css
/* DELETE - interactive.css provides */
.trend-up {
color: var(--color-success);
}
.trend-down {
color: var(--color-error);
}
```
**USE:**
```vue
+15%
```
**Acceptance Criteria:**
- [ ] All trends use global classes
- [ ] ~30 lines deleted
---
#### Task 4.3: Test All Metrics
**Status:** ⏸️ | **Est:** 30 min
- [ ] All metric values display correctly
- [ ] Trend indicators show
- [ ] Charts render
- [ ] Breakdowns expand
---
### 5. Responsive Consolidation (6 tasks)
**CRITICAL: Currently 4 separate breakpoints (600 lines total)**
#### Task 5.1: Audit Responsive Rules
**Status:** ⏸️ | **Est:** 1 hour
**Current breakpoints:**
```css
@media (max-width: 1200px) { /* 166 lines */ }
@media (max-width: 1024px) { /* 143 lines */ }
@media (max-width: 768px) { /* 224 lines */ }
@media (max-width: 480px) { /* 245 lines */ }
```
**Analyze:**
- [ ] What's different at each breakpoint?
- [ ] Which rules are duplicate?
- [ ] Which can use global responsive CSS?
- [ ] Which are truly component-specific?
**Acceptance Criteria:**
- [ ] All breakpoint rules documented
- [ ] Consolidation plan created
---
#### Task 5.2: Extract Global Responsive to CSS
**Status:** ⏸️ | **Est:** 1 hour
**Add to dashboard.css:**
```css
/* Dashboard responsive rules */
@media (max-width: 768px) {
.metrics-row {
grid-template-columns: 1fr;
}
.section-header {
flex-direction: column;
align-items: flex-start;
}
.page-title {
font-size: var(--text-2xl);
}
}
```
**Acceptance Criteria:**
- [ ] Common responsive rules in global CSS
- [ ] Apply to all dashboard views
---
#### Task 5.3: Consolidate to Single Breakpoint
**Status:** ⏸️ | **Est:** 2 hours
**BEFORE (4 breakpoints):**
```css
@media (max-width: 1200px) {
.dashboard-grid {
grid-template-columns: repeat(3, 1fr);
}
}
@media (max-width: 1024px) {
.dashboard-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 768px) {
.dashboard-grid {
grid-template-columns: 1fr;
}
/* ... 200 more lines ... */
}
@media (max-width: 480px) {
/* ... 245 lines ... */
}
```
**AFTER (1 breakpoint):**
```css
@media (max-width: 768px) {
/* Only truly component-specific mobile rules */
.dashboard-specific-class {
/* Component-specific adjustment */
}
}
```
**Acceptance Criteria:**
- [ ] 4 breakpoints → 1 breakpoint
- [ ] ~500 lines deleted
- [ ] Responsive behavior identical
---
#### Task 5.4: Test Desktop Breakpoints
**Status:** ⏸️ | **Est:** 30 min
**Test at:**
- [ ] 1920x1080 (Full HD)
- [ ] 1366x768 (Laptop)
- [ ] 1280x720 (Small desktop)
**Acceptance Criteria:**
- [ ] Layout adapts correctly
- [ ] No horizontal scroll
- [ ] All content visible
---
#### Task 5.5: Test Tablet
**Status:** ⏸️ | **Est:** 30 min
**Test at:**
- [ ] 768x1024 (iPad portrait)
- [ ] 1024x768 (iPad landscape)
**Acceptance Criteria:**
- [ ] Cards adapt to width
- [ ] Tables usable
- [ ] Touch targets adequate
---
#### Task 5.6: Test Mobile (CRITICAL)
**Status:** ⏸️ | **Est:** 1 hour
**Test at:**
- [ ] 375x667 (iPhone SE)
- [ ] 414x896 (iPhone 11)
- [ ] 360x640 (Android)
**Real device testing:**
- [ ] Test on actual iPhone
- [ ] Test on actual Android
- [ ] Virtual keyboard doesn't break layout
- [ ] Scrolling smooth
**Acceptance Criteria:**
- [ ] Perfect mobile experience
- [ ] No layout breaks
- [ ] All features accessible
---
### 6. Loading & Animations (3 tasks)
#### Task 6.1: Replace Loading Spinner
**Status:** ⏸️ | **Est:** 15 min
**DELETE:**
```css
/* DELETE - interactive.css provides */
.loading-spinner {
width: 40px;
height: 40px;
/* ... */
}
@keyframes spin {
to { transform: rotate(360deg); }
}
```
**USE:**
```vue
```
**Acceptance Criteria:**
- [ ] ~40 lines deleted
- [ ] Spinner looks identical
---
#### Task 6.2: Use Global Animations
**Status:** ⏸️ | **Est:** 15 min
**DELETE:**
```css
/* DELETE - animations.css provides */
@keyframes slideDown {
/* ... */
}
@keyframes fadeIn {
/* ... */
}
```
**USE:**
```vue
...
...
```
**Acceptance Criteria:**
- [ ] ~20 lines deleted
- [ ] Animations work
---
#### Task 6.3: Test Loading States
**Status:** ⏸️ | **Est:** 15 min
- [ ] Initial load shows spinner
- [ ] Data fetching shows loading
- [ ] Transitions smooth
---
### 7. Testing & Validation (5 tasks)
#### Task 7.1: Playwright Visual Regression
**Status:** ⏸️ | **Est:** 1 hour
**CRITICAL TEST:**
```bash
# Capture before Phase 5
npm run test:e2e -- tests/e2e/dashboard/ --update-snapshots
# After each major change, compare
npm run test:e2e -- tests/e2e/dashboard/
# Review differences
npm run test:e2e:report
```
**Acceptance Criteria:**
- [ ] Zero unexpected differences
- [ ] All snapshots match
- [ ] Any differences approved
---
#### Task 7.2: Desktop Testing (All Sizes)
**Status:** ⏸️ | **Est:** 1 hour
**Resolutions:**
- [ ] 1920x1080
- [ ] 1600x900
- [ ] 1366x768
- [ ] 1280x1024
**Check:**
- [ ] Grid layouts
- [ ] Card displays
- [ ] Tables
- [ ] Charts
- [ ] Spacing
**Acceptance Criteria:**
- [ ] Perfect on all desktop sizes
- [ ] No layout shifts
---
#### Task 7.3: Tablet Testing
**Status:** ⏸️ | **Est:** 45 min
- [ ] iPad portrait (768x1024)
- [ ] iPad landscape (1024x768)
- [ ] Surface (1366x768)
**Acceptance Criteria:**
- [ ] Responsive layout works
- [ ] Touch interactions smooth
---
#### Task 7.4: Mobile Testing (Real Devices)
**Status:** ⏸️ | **Est:** 1 hour
**Test on real devices:**
- [ ] iPhone (any model)
- [ ] Android phone
**Test all features:**
- [ ] Dashboard loads
- [ ] Cards display
- [ ] Tables scroll
- [ ] Charts tap/zoom
- [ ] Breakdowns expand
- [ ] Filters work
- [ ] Virtual keyboard doesn't break
**Acceptance Criteria:**
- [ ] 100% functional on mobile
- [ ] No usability issues
---
#### Task 7.5: Measure Reduction
**Status:** ⏸️ | **Est:** 15 min
**Measure:**
```bash
# Before
wc -l src/views/DashboardView.vue.phase5.backup
# CSS lines: 2,010
# After
wc -l src/views/DashboardView.vue
# Expected total: ~2,300 (4,010 - 1,710)
# Count CSS lines in scoped section
sed -n '/^