From dbea9ae70810b640fd8bad4294f11b50cbbf65ea Mon Sep 17 00:00:00 2001 From: Priyobroto Kar Date: Thu, 12 Sep 2024 23:37:15 +0530 Subject: [PATCH] feat(platform): Add loading skeleton in the secrets page --- .../(main)/project/[project]/@secret/page.tsx | 34 +++++++++++++++++++ apps/platform/src/components/ui/skeleton.tsx | 18 ++++++++++ 2 files changed, 52 insertions(+) create mode 100644 apps/platform/src/components/ui/skeleton.tsx diff --git a/apps/platform/src/app/(main)/project/[project]/@secret/page.tsx b/apps/platform/src/app/(main)/project/[project]/@secret/page.tsx index 8919cbf7..5061bf8e 100644 --- a/apps/platform/src/app/(main)/project/[project]/@secret/page.tsx +++ b/apps/platform/src/app/(main)/project/[project]/@secret/page.tsx @@ -28,14 +28,17 @@ import { TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' +import { Skeleton } from '@/components/ui/skeleton' extend(relativeTime) function SecretPage(): React.JSX.Element { const [allSecrets, setAllSecrets] = useState() + const [isLoading, setIsLoading] = useState(true) const pathname = usePathname() useEffect(() => { + setIsLoading(true) Secrets.getAllSecretbyProjectId(pathname.split('/')[2]) .then((data) => { setAllSecrets(data) @@ -44,8 +47,21 @@ function SecretPage(): React.JSX.Element { // eslint-disable-next-line no-console -- we need to log the error console.error(error) }) + .finally(() => { + setIsLoading(false) + }) }, [pathname]) + if (isLoading) { + return ( +
+ + + +
+ ) + } + return ( +
+
+ + +
+
+ + + +
+
+ + ) +} + export default SecretPage diff --git a/apps/platform/src/components/ui/skeleton.tsx b/apps/platform/src/components/ui/skeleton.tsx new file mode 100644 index 00000000..e2b6f938 --- /dev/null +++ b/apps/platform/src/components/ui/skeleton.tsx @@ -0,0 +1,18 @@ +import { cn } from '@/lib/utils' + +function Skeleton({ + className, + ...props +}: React.HTMLAttributes): React.JSX.Element { + return ( +
+ ) +} + +export { Skeleton }