Vatsal12345678 commited on
Commit
c06a7c4
·
verified ·
1 Parent(s): 62afa00

and a table for this year's software cost with all different softwares

Browse files
Files changed (2) hide show
  1. index.html +19 -2
  2. script.js +14 -1
index.html CHANGED
@@ -51,14 +51,31 @@
51
  <p id="most-expensive" class="text-3xl font-bold text-gray-800">-</p>
52
  </div>
53
  </div>
54
-
55
  <div class="mt-12 bg-white p-6 rounded-xl shadow-md">
56
  <h3 class="text-lg font-medium text-gray-800 mb-4">Yearly Spend Breakdown</h3>
57
  <div class="h-64">
58
  <canvas id="yearly-chart"></canvas>
59
  </div>
60
  </div>
61
- </main>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  <custom-footer></custom-footer>
64
 
 
51
  <p id="most-expensive" class="text-3xl font-bold text-gray-800">-</p>
52
  </div>
53
  </div>
 
54
  <div class="mt-12 bg-white p-6 rounded-xl shadow-md">
55
  <h3 class="text-lg font-medium text-gray-800 mb-4">Yearly Spend Breakdown</h3>
56
  <div class="h-64">
57
  <canvas id="yearly-chart"></canvas>
58
  </div>
59
  </div>
60
+
61
+ <div class="mt-8 bg-white p-6 rounded-xl shadow-md">
62
+ <h3 class="text-lg font-medium text-gray-800 mb-4">This Year's Software Costs</h3>
63
+ <div class="overflow-x-auto">
64
+ <table class="min-w-full divide-y divide-gray-200">
65
+ <thead class="bg-gray-50">
66
+ <tr>
67
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Software</th>
68
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
69
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Cost (SGD)</th>
70
+ </tr>
71
+ </thead>
72
+ <tbody id="current-year-table" class="bg-white divide-y divide-gray-200">
73
+ <!-- Table rows will be populated by JavaScript -->
74
+ </tbody>
75
+ </table>
76
+ </div>
77
+ </div>
78
+ </main>
79
 
80
  <custom-footer></custom-footer>
81
 
script.js CHANGED
@@ -101,10 +101,23 @@ const totalSpend = softwareData.reduce((sum, item) => sum + item.cost, 0);
101
  }
102
  }
103
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  // View toggle functionality
106
  document.getElementById('yearly-view').addEventListener('click', function() {
107
- // In a real app, this would filter the table by year
108
  alert('Yearly view would show aggregated data by year');
109
  });
110
 
 
101
  }
102
  }
103
  });
104
+ // Populate current year's software table
105
+ const currentYearTable = document.getElementById('current-year-table');
106
+ const currentYearItems = softwareData.filter(item => item.year === currentYear);
107
+
108
+ currentYearItems.forEach(item => {
109
+ const row = document.createElement('tr');
110
+ row.innerHTML = `
111
+ <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${item.software}</td>
112
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.date}</td>
113
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.cost.toLocaleString('en-SG', {minimumFractionDigits: 2, maximumFractionDigits: 2})}</td>
114
+ `;
115
+ currentYearTable.appendChild(row);
116
+ });
117
 
118
  // View toggle functionality
119
  document.getElementById('yearly-view').addEventListener('click', function() {
120
+ // In a real app, this would filter the table by year
121
  alert('Yearly view would show aggregated data by year');
122
  });
123