Add loading spinner for email and domain page
This commit is contained in:
@@ -8,6 +8,7 @@ import { api } from "~/trpc/react";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { StatusIndicator } from "./status-indicator";
|
import { StatusIndicator } from "./status-indicator";
|
||||||
import { DomainStatusBadge } from "./domain-badge";
|
import { DomainStatusBadge } from "./domain-badge";
|
||||||
|
import Spinner from "@unsend/ui/src/spinner";
|
||||||
|
|
||||||
export default function DomainsList() {
|
export default function DomainsList() {
|
||||||
const domainsQuery = api.domain.domains.useQuery();
|
const domainsQuery = api.domain.domains.useQuery();
|
||||||
@@ -15,7 +16,14 @@ export default function DomainsList() {
|
|||||||
return (
|
return (
|
||||||
<div className="mt-10">
|
<div className="mt-10">
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
{!domainsQuery.isLoading && domainsQuery.data?.length ? (
|
{domainsQuery.isLoading ? (
|
||||||
|
<div className="flex justify-center mt-10">
|
||||||
|
<Spinner
|
||||||
|
className="w-6 h-6 mx-auto"
|
||||||
|
innerSvgClass="stroke-primary"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : domainsQuery.data?.length ? (
|
||||||
domainsQuery.data?.map((domain) => (
|
domainsQuery.data?.map((domain) => (
|
||||||
<DomainItem key={domain.id} domain={domain} />
|
<DomainItem key={domain.id} domain={domain} />
|
||||||
))
|
))
|
||||||
|
@@ -30,6 +30,7 @@ import {
|
|||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
} from "@unsend/ui/src/select";
|
} from "@unsend/ui/src/select";
|
||||||
|
import Spinner from "@unsend/ui/src/spinner";
|
||||||
|
|
||||||
/* Stupid hydrating error. And I so stupid to understand the stupid NextJS docs */
|
/* Stupid hydrating error. And I so stupid to understand the stupid NextJS docs */
|
||||||
const DynamicSheetWithNoSSR = dynamic(
|
const DynamicSheetWithNoSSR = dynamic(
|
||||||
@@ -104,7 +105,16 @@ export default function EmailsList() {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{emailsQuery.data?.emails.length ? (
|
{emailsQuery.isLoading ? (
|
||||||
|
<TableRow className="h-32">
|
||||||
|
<TableCell colSpan={4} className="text-center py-4">
|
||||||
|
<Spinner
|
||||||
|
className="w-6 h-6 mx-auto"
|
||||||
|
innerSvgClass="stroke-primary"
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
) : emailsQuery.data?.emails.length ? (
|
||||||
emailsQuery.data?.emails.map((email) => (
|
emailsQuery.data?.emails.map((email) => (
|
||||||
<TableRow
|
<TableRow
|
||||||
key={email.id}
|
key={email.id}
|
||||||
@@ -128,7 +138,7 @@ export default function EmailsList() {
|
|||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<TableRow className="h-32">
|
<TableRow className="h-32">
|
||||||
<TableCell colSpan={4} className="text-center">
|
<TableCell colSpan={4} className="text-center py-4">
|
||||||
No emails found
|
No emails found
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { cn } from "..";
|
||||||
|
|
||||||
export const Spinner: React.FC<React.SVGProps<SVGSVGElement>> = (props) => {
|
export const Spinner: React.FC<
|
||||||
|
React.SVGProps<SVGSVGElement> & { innerSvgClass?: string }
|
||||||
|
> = (props) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
version="1.1"
|
version="1.1"
|
||||||
@@ -15,7 +18,7 @@ export const Spinner: React.FC<React.SVGProps<SVGSVGElement>> = (props) => {
|
|||||||
<g
|
<g
|
||||||
strokeWidth="200"
|
strokeWidth="200"
|
||||||
strokeLinecap="round"
|
strokeLinecap="round"
|
||||||
className="stroke-primary-foreground"
|
className={cn("stroke-primary-foreground", props.innerSvgClass)}
|
||||||
fill="none"
|
fill="none"
|
||||||
id="spinner"
|
id="spinner"
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user