Skip to content

Commit

Permalink
Merge branch 'feature/admin'
Browse files Browse the repository at this point in the history
  • Loading branch information
ad956 committed Aug 5, 2024
2 parents 4b921f7 + 18671f8 commit e0fe4a5
Show file tree
Hide file tree
Showing 4 changed files with 361 additions and 18 deletions.
5 changes: 0 additions & 5 deletions app/(pages)/admin/billing/page.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion app/(pages)/admin/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { TbCurrencyRupee } from "react-icons/tb";
const SidebarConfig = [
{ title: "Dashboard", uri: "", icon: <FiHome /> },
{ title: "Add Admin", uri: "add-admin", icon: <FiUserPlus /> },
{ title: "Billing", uri: "billing", icon: <TbCurrencyRupee /> },
{ title: "Transactions", uri: "transactions", icon: <TbCurrencyRupee /> },
{ title: "Hospitals", uri: "hospitals", icon: <FiHeart /> },
{ title: "Users", uri: "users", icon: <FiUser /> },
{ title: "Reports", uri: "reports", icon: <FiBarChart2 /> },
Expand Down
15 changes: 3 additions & 12 deletions app/(pages)/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ export default function Admin() {
const [recentUsers, setRecentUsers] = useState<RecentUser[]>([]);
const [page, setPage] = useState(1);
const [hasMore, setHasMore] = useState(true);
const [isLoading, setIsLoading] = useState(false);

const observer = useRef<IntersectionObserver | null>(null);
const lastUserElementRef = useCallback(
(node: HTMLDivElement | null) => {
if (isLoading) return;
if (observer.current) observer.current.disconnect();
observer.current = new IntersectionObserver((entries) => {
if (entries[0].isIntersecting && hasMore) {
Expand All @@ -71,7 +69,7 @@ export default function Admin() {
});
if (node) observer.current.observe(node);
},
[isLoading, hasMore]
[hasMore]
);

useEffect(() => {
Expand All @@ -87,8 +85,8 @@ export default function Admin() {
}, [page]);

const fetchRecentUsers = async () => {
if (isLoading || !hasMore) return;
setIsLoading(true);
if (!hasMore) return;

try {
const response = await fetch(
`/api/admin/dashboard/recent-users?page=${page}&limit=10`
Expand All @@ -98,8 +96,6 @@ export default function Admin() {
setHasMore(data.page < data.totalPages);
} catch (error) {
console.error("Error fetching recent users:", error);
} finally {
setIsLoading(false);
}
};

Expand Down Expand Up @@ -189,11 +185,6 @@ export default function Admin() {
<p className="text-sm text-gray-500">{user.timeSince}</p>
</div>
))}
{isLoading && (
<div className="text-center">
<Spinner size="md" />
</div>
)}
</div>
</CardBody>
</Card>
Expand Down
Loading

0 comments on commit e0fe4a5

Please sign in to comment.