Skip to content

Commit 4229a32

Browse files
committed
Add Day page with Today's Summary and Cash Management sub-tabs
- Created new Day page at top of navigation - Today's Summary shows: purchases, sales, expenses, labor cost, quantities - Added Payment Summary with cash/online received/paid and total cash flow - Added Due Summary: due received, due paid, due to receive, due to pay - Added Item-wise Purchase and Sale Details sorted by popularity - Moved Cash Management under Day page as sub-tab - Fixed toast z-index to show above auth screen - Fixed Reports NaN issue with null safety - Fixed user approval check on page refresh - Fixed items import to refresh table view
1 parent 0e81a33 commit 4229a32

13 files changed

Lines changed: 658 additions & 53 deletions

File tree

www/css/toast.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
font-size: 14px;
1111
font-weight: 500;
1212
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
13-
z-index: 10000;
13+
z-index: 100000;
1414
opacity: 0;
1515
transition: all 0.3s ease;
1616
pointer-events: none;

www/firebaseConfig.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ const APP_ENV = getEnvironment();
4242
// Development: 'dev_items', 'dev_purchases', etc.
4343
const COLLECTION_PREFIX = APP_ENV === 'production' ? '' : 'dev_';
4444

45-
// Collections that should NOT be prefixed (shared between dev and prod)
46-
// - users: Keep same user roles/permissions in dev
47-
const SHARED_COLLECTIONS = ['users'];
45+
// All collections are now prefixed in dev mode (no shared collections)
46+
// This keeps dev and prod data completely separate
4847

4948
console.log(`🔧 App Environment: ${APP_ENV} | Collection Prefix: "${COLLECTION_PREFIX}"`);
5049

@@ -64,13 +63,7 @@ window.APP_ENV = APP_ENV;
6463
window.COLLECTION_PREFIX = COLLECTION_PREFIX;
6564

6665
// Helper function to get prefixed collection name
67-
// Some collections are shared (not prefixed) between dev and prod
68-
window.getCollection = (name) => {
69-
if (SHARED_COLLECTIONS.includes(name)) {
70-
return name; // No prefix for shared collections
71-
}
72-
return COLLECTION_PREFIX + name;
73-
};
66+
window.getCollection = (name) => COLLECTION_PREFIX + name;
7467

7568
// Show environment indicator in UI (for development only)
7669
if (APP_ENV !== 'production') {

www/js/auth/authentication.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,19 @@ const AuthManager = {
173173
const name = document.getElementById('registerName').value.trim();
174174
const email = document.getElementById('registerEmail').value.trim();
175175
const password = document.getElementById('registerPassword').value;
176-
const role = document.getElementById('registerRole').value;
176+
const confirmPassword = document.getElementById('registerConfirmPassword')?.value;
177+
const role = 'staff'; // Default role for new registrations - can be changed by admin
177178

178179
if (!name || !email || !password) {
179180
UIManager.showToast('Please fill all fields');
180181
return;
181182
}
182183

184+
if (confirmPassword && password !== confirmPassword) {
185+
UIManager.showToast('Passwords do not match');
186+
return;
187+
}
188+
183189
if (password.length < 6) {
184190
UIManager.showToast('Password must be at least 6 characters');
185191
return;

www/js/main.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { UsersManager } from './modules/users.js';
2020
import { FinanceManager } from './modules/finance.js';
2121
import { AnalyticsManager } from './modules/analytics.js';
2222
import { CashManagementManager } from './modules/cash-management.js';
23+
import { DayManager } from './modules/day.js';
2324
import { AuditService } from './services/audit.js';
2425

2526
// Import template loader utility
@@ -101,8 +102,33 @@ async function loadUserDataAndInitialize() {
101102
const userDoc = await firebase.firestore().collection(window.getCollection ? window.getCollection('users') : 'users').doc(userId).get();
102103
if (userDoc.exists) {
103104
const userData = userDoc.data();
105+
106+
// Check if user is approved
107+
if (userData.status === 'pending') {
108+
await firebase.auth().signOut();
109+
UIManager.hideLoading();
110+
UIManager.showToast('Your account is pending approval. Please wait for admin approval.');
111+
document.getElementById('authScreen').style.display = 'flex';
112+
return;
113+
}
114+
115+
if (userData.status === 'rejected') {
116+
await firebase.auth().signOut();
117+
UIManager.hideLoading();
118+
UIManager.showToast('Your account has been rejected. Please contact admin.');
119+
document.getElementById('authScreen').style.display = 'flex';
120+
return;
121+
}
122+
104123
AppState.userRole = userData.role || 'staff';
105124
AppState.userName = userData.name || 'User';
125+
} else {
126+
// User document doesn't exist
127+
await firebase.auth().signOut();
128+
UIManager.hideLoading();
129+
UIManager.showToast('User account not found. Please register.');
130+
document.getElementById('authScreen').style.display = 'flex';
131+
return;
106132
}
107133
}
108134

@@ -530,6 +556,14 @@ window.app = {
530556
init: () => AnalyticsManager.init()
531557
},
532558

559+
// Day (Today's Summary + Cash Management)
560+
day: {
561+
init: () => DayManager.init(),
562+
showSubTab: (tab) => DayManager.showSubTab(tab),
563+
loadTodayData: () => DayManager.loadTodayData(),
564+
filterTransactions: () => DayManager.filterTransactions()
565+
},
566+
533567
// Cash Management
534568
cashManagement: {
535569
init: () => CashManagementManager.init(),

0 commit comments

Comments
 (0)