feat: add admin dashboard and core API routes with Docker configuration
This commit is contained in:
@@ -46,9 +46,7 @@ const DashboardContent = () => {
|
||||
|
||||
const fetchBusiness = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/businesses/me', {
|
||||
headers: { 'x-user-id': user.id }
|
||||
});
|
||||
const res = await fetch('/api/businesses/me');
|
||||
const data = await res.json();
|
||||
if (data && !data.error) {
|
||||
setBusiness(data);
|
||||
@@ -77,26 +75,9 @@ const DashboardContent = () => {
|
||||
// Fetch unread messages count
|
||||
const fetchUnreadCount = async () => {
|
||||
if (!user || !isMounted) return;
|
||||
|
||||
// If user has no id, try to find it via email (Session Reconciliation)
|
||||
let effectiveUserId = user.id;
|
||||
if (!effectiveUserId || effectiveUserId === 'undefined' || effectiveUserId === 'null') {
|
||||
try {
|
||||
const res = await fetch(`/api/users/profile?email=${encodeURIComponent(user.email)}`);
|
||||
const data = await res.json();
|
||||
if (data.id) {
|
||||
effectiveUserId = data.id;
|
||||
// Note: Ideally we'd update the global user object here too
|
||||
} else {
|
||||
return; // Can't count without ID
|
||||
}
|
||||
} catch (e) { return; }
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/messages/unread', {
|
||||
headers: { 'x-user-id': effectiveUserId }
|
||||
});
|
||||
const res = await fetch('/api/messages/unread');
|
||||
const data = await res.json();
|
||||
if (!data.error) {
|
||||
setUnreadCount(data.count);
|
||||
|
||||
Reference in New Issue
Block a user