rupertavery's picture
Add Total account value
ab9146c verified
// Main application script
document.addEventListener('DOMContentLoaded', function() {
// Initialize tooltips
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// Sample data for demonstration
const birthdays = [
{ name: "Sarah Johnson", date: "Today" },
{ name: "Michael Chen", date: "Tomorrow" }
];
// Account value auto-update simulation
function updateAccountValue() {
const baseValue = 124870.45;
const fluctuation = (Math.random() - 0.5) * 1000;
const newValue = baseValue + fluctuation;
const changePercent = ((newValue - baseValue) / baseValue * 100).toFixed(2);
const valueElement = document.querySelector('.text-3xl.font-bold.text-blue-600');
const changeElement = document.querySelector('.text-sm.text-gray-500');
if (valueElement && changeElement) {
valueElement.textContent = `${newValue.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`;
changeElement.textContent = `${changePercent >= 0 ? '+' : ''}${changePercent}% this month`;
changeElement.className = `text-sm ${changePercent >= 0 ? 'text-green-500' : 'text-red-500'}`;
}
}
document.querySelector('[data-feather="refresh-cw"]')?.addEventListener('click', updateAccountValue);
// Simulate real-time updates every 30 seconds
setInterval(updateAccountValue, 30000);
console.log("CRM Dashboard initialized");
});