Skip to content

Commit 2a662fc

Browse files
committed
fix: resolve pre-existing dashboard console errors
- AdminProfile.jsx: remove non-existent updated_at column from tickets query, use created_at for both select and order (fixes 400 Bad Request) - AdminUsers.jsx: wrap user_requests fetch in try/catch to silently handle 404 when table doesn't exist; profile-based fallback still shows pending users
1 parent d11a60f commit 2a662fc

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

Frontend/src/admin/pages/AdminProfile.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ const AdminProfile = () => {
7878
try {
7979
const { data, error } = await supabase
8080
.from('tickets')
81-
.select('id, subject, status, created_at, updated_at')
81+
.select('id, subject, status, created_at')
8282
.eq('company', adminProfile.company)
83-
.order('updated_at', { ascending: false })
83+
.order('created_at', { ascending: false })
8484
.limit(5);
8585

8686
if (error) throw error;
@@ -89,7 +89,7 @@ const AdminProfile = () => {
8989
id: t.id,
9090
action: `Ticket ${t.status?.toUpperCase() || 'UPDATED'}`,
9191
target: `#TKT-${t.id.slice(0, 4)}`,
92-
timestamp: new Date(t.updated_at || t.created_at).toLocaleString(),
92+
timestamp: new Date(t.created_at).toLocaleString(),
9393
status: "Success"
9494
}));
9595
setActivityLog(formatted);

Frontend/src/admin/pages/AdminUsers.jsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,21 @@ const AdminUsers = () => {
114114
// 2. Fetch PENDING entities
115115
let allPending = [];
116116
if (activeCompanyId) {
117-
const { data: reqData, error: reqError } = await supabase
118-
.from('user_requests')
119-
.select(`
120-
id, user_id, company_id, status, created_at,
121-
user:profiles!user_id (id, full_name, email, company, profile_picture, status)
122-
`)
123-
.eq('company_id', activeCompanyId)
124-
.eq('status', 'pending')
125-
.order('created_at', { ascending: false });
126-
127-
if (!reqError && reqData) allPending = [...reqData];
117+
try {
118+
const { data: reqData, error: reqError } = await supabase
119+
.from('user_requests')
120+
.select(`
121+
id, user_id, company_id, status, created_at,
122+
user:profiles!user_id (id, full_name, email, company, profile_picture, status)
123+
`)
124+
.eq('company_id', activeCompanyId)
125+
.eq('status', 'pending')
126+
.order('created_at', { ascending: false });
127+
128+
if (!reqError && reqData) allPending = [...reqData];
129+
} catch (_) {
130+
// user_requests table may not exist — profile-based fallback below handles pending users
131+
}
128132
}
129133

130134
// Path B: Direct profile lookup (Ensure Anjali is visible even if request row failed)

0 commit comments

Comments
 (0)