Skip to content

Commit

Permalink
feat: add loading page
Browse files Browse the repository at this point in the history
  • Loading branch information
daoleno committed Dec 25, 2023
1 parent 16f79b3 commit d951590
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 35 deletions.
5 changes: 0 additions & 5 deletions dashboard/app/analytic/[name]/page.tsx

This file was deleted.

5 changes: 5 additions & 0 deletions dashboard/app/analytics/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Loader } from "@/components/loader"

export default function Loading() {
return <Loader />
}
5 changes: 5 additions & 0 deletions dashboard/app/apps/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Loader } from "@/components/loader"

export default function Loading() {
return <Loader />
}
5 changes: 5 additions & 0 deletions dashboard/app/profile/[id]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Loader } from "@/components/loader"

export default function Loading() {
return <Loader />
}
5 changes: 5 additions & 0 deletions dashboard/app/profiles/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Loader } from "@/components/loader"

export default function Loading() {
return <Loader />
}
5 changes: 5 additions & 0 deletions dashboard/app/publication/[id]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Loader } from "@/components/loader"

export default function Loading() {
return <Loader />
}
5 changes: 5 additions & 0 deletions dashboard/app/publications/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Loader } from "@/components/loader"

export default function Loading() {
return <Loader />
}
21 changes: 21 additions & 0 deletions dashboard/components/loader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Loader2 } from "lucide-react"

import { cn } from "@/lib/utils"

interface LoadingProps {
fixed?: boolean
}

export function Loader({ fixed = true }: LoadingProps) {
return (
<div
className={cn(
"bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center space-x-2 bg-opacity-50",
fixed ? "fixed" : "my-7"
)}
>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
Loading...
</div>
)
}
21 changes: 0 additions & 21 deletions dashboard/components/loading.tsx

This file was deleted.

21 changes: 13 additions & 8 deletions dashboard/components/profiles-table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Suspense } from "react"

import { Profile } from "@/app/api/profiles/getProfiles"

import { profileColumns } from "./data-table/columns"
import { DataTable } from "./data-table/data-table"
import { DataTableLoading } from "./data-table/data-table-loading"

interface ProfilesTableProps {
data: Profile[]
Expand All @@ -20,14 +23,16 @@ export default async function ProfilesTable({
}: ProfilesTableProps) {
return (
<div className="my-3 flex-1 flex-col gap-3 md:flex">
<DataTable
columns={profileColumns}
data={data}
pageCount={pageCount}
totalCount={totalCount}
showToolbar={showToolbar}
showPagination={showPagination}
/>
<Suspense fallback={<DataTableLoading columnCount={6} rowCount={10} />}>
<DataTable
columns={profileColumns}
data={data}
pageCount={pageCount}
totalCount={totalCount}
showToolbar={showToolbar}
showPagination={showPagination}
/>
</Suspense>
</div>
)
}
3 changes: 2 additions & 1 deletion dashboard/components/publications-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { type Publication } from "@/app/api/publications/getPublications"

import { publicationColumns } from "./data-table/columns"
import { DataTable } from "./data-table/data-table"
import { DataTableLoading } from "./data-table/data-table-loading"

interface PublicationsTableProps {
title: string
Expand All @@ -25,7 +26,7 @@ export default async function PublicationsTable({
return (
<div className="my-3 flex-1 flex-col gap-3 md:flex">
<h2 className="p-3 text-3xl font-bold tracking-tight">{title}</h2>
<Suspense fallback={<div>Loading...</div>}>
<Suspense fallback={<DataTableLoading columnCount={6} rowCount={10} />}>
<DataTable
columns={publicationColumns}
data={data}
Expand Down

0 comments on commit d951590

Please sign in to comment.