34 lines
833 B
TypeScript
34 lines
833 B
TypeScript
import Users from "@/app/features/pages/admin/users/users";
|
|
|
|
export default async function BackOfficeUsersPage() {
|
|
const baseUrl =
|
|
process.env.NEXT_PUBLIC_BASE_URL || process.env.VERCEL_URL
|
|
? `https://${process.env.VERCEL_URL}`
|
|
: "http://localhost:3000";
|
|
|
|
let users = [];
|
|
|
|
try {
|
|
const res = await fetch(`${baseUrl}/api/dashboard/admin/users`, {
|
|
// cache: "no-store", // optional: disable SSR caching if needed
|
|
});
|
|
|
|
if (!res.ok) {
|
|
// If the API responds with 500/404/etc., log and bail gracefully
|
|
console.error(
|
|
`Failed to fetch users: ${res.status} ${res.statusText}`
|
|
);
|
|
} else {
|
|
users = await res.json();
|
|
}
|
|
} catch (error) {
|
|
console.error("Error fetching users:", error);
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<Users users={users} />
|
|
</div>
|
|
);
|
|
}
|