Skip to content

Commit

Permalink
chore: use common components for loading and errors
Browse files Browse the repository at this point in the history
Signed-off-by: guillaume <[email protected]>
  • Loading branch information
gruyaume committed Sep 16, 2024
1 parent 76fbd24 commit c19d8b5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 57 deletions.
30 changes: 2 additions & 28 deletions ui/src/app/certificate_requests/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,9 @@ import { getCertificateRequests } from "../queries"
import { CSREntry } from "../types"
import { useCookies } from "react-cookie"
import { useRouter } from "next/navigation"
import Loading from "../loading"
import Error from "../error"

function Error({ msg }: { msg: string }) {
return (
<caption>
<div className="p-strip">
<div className="row">
<div className="u-align--left">
<p className="p-heading--5">An error occured trying to load certificate requests</p>
<p>{msg}</p>
</div>
</div>
</div>
</caption>
)
}

function Loading() {
return (
<caption>
<div className="p-strip">
<div className="row">
<div className="col-8 col-medium-4 col-small-3">
<p className="p-heading--4 u-no-margin--bottom">Loading...</p>
</div>
</div>
</div>
</caption>
)
}

export default function CertificateRequests() {
const router = useRouter()
Expand Down
11 changes: 11 additions & 0 deletions ui/src/app/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use client"
import { Strip } from "@canonical/react-components";

export default function Error({ msg }: { msg: string }) {
return (
<Strip >
<p className="p-heading--5">An error occured trying to load content</p>
<p>{msg}</p>
</Strip>
)
}
10 changes: 10 additions & 0 deletions ui/src/app/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use client"
import { Strip, Spinner } from "@canonical/react-components";

export default function Loading() {
return (
<Strip >
<Spinner text="Loading..." />
</Strip>
)
}
31 changes: 2 additions & 29 deletions ui/src/app/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,8 @@ import { UserEntry } from "../types"
import { useCookies } from "react-cookie"
import { useRouter } from "next/navigation"
import { UsersTable } from "./table"

function Error({ msg }: { msg: string }) {
return (
<caption>
<div className="p-strip">
<div className="row">
<div className="u-align--left">
<p className="p-heading--5">An error occured trying to load users</p>
<p>{msg}</p>
</div>
</div>
</div>
</caption>
)
}

function Loading() {
return (
<caption>
<div className="p-strip">
<div className="row">
<div className="col-8 col-medium-4 col-small-3">
<p className="p-heading--4 u-no-margin--bottom">Loading...</p>
</div>
</div>
</div>
</caption>
)
}
import Loading from "../loading"
import Error from "../error"

export default function Users() {
const router = useRouter()
Expand Down

0 comments on commit c19d8b5

Please sign in to comment.