forked from prowler-cloud/prowler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui:profile) add profile card (prowler-cloud#5948)
- Loading branch information
Showing
8 changed files
with
322 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
import { Spacer } from "@nextui-org/react"; | ||
import { redirect } from "next/navigation"; | ||
import React from "react"; | ||
import React, { Suspense } from "react"; | ||
|
||
// import { getUserByMe } from "@/actions/auth/auth"; | ||
import { auth } from "@/auth.config"; | ||
import { getProfileInfo } from "@/actions/auth"; | ||
import { Header } from "@/components/ui"; | ||
import { SkeletonUserInfo } from "@/components/users/profile"; | ||
import { UserInfo } from "@/components/users/profile/user-info"; | ||
import { UserProfileProps } from "@/types"; | ||
|
||
export default async function Profile() { | ||
const session = await auth(); | ||
|
||
if (!session?.user) { | ||
// redirect("/sign-in?returnTo=/profile"); | ||
redirect("/sign-in"); | ||
} | ||
|
||
// const user = await getUserByMe(); | ||
|
||
return ( | ||
<> | ||
<Header title="User Profile" icon="ci:users" /> | ||
<Spacer y={4} /> | ||
<Spacer y={6} /> | ||
<pre>{JSON.stringify(session.user, null, 2)}</pre> | ||
<pre>{JSON.stringify(session.userId, null, 2)}</pre> | ||
<pre>{JSON.stringify(session.tenantId, null, 2)}</pre> | ||
<pre>{JSON.stringify(session, null, 2)}</pre> | ||
<div className="min-h-screen"> | ||
<div className="container mx-auto space-y-8 px-0 py-6"> | ||
<div className="grid grid-cols-12 gap-6"> | ||
<div className="col-span-12 lg:col-span-3"> | ||
<Suspense fallback={<SkeletonUserInfo />}> | ||
<SSRDataUser /> | ||
</Suspense> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
const SSRDataUser = async () => { | ||
const userProfile: UserProfileProps = await getProfileInfo(); | ||
|
||
return ( | ||
<> | ||
<h3 className="mb-4 text-sm font-bold">User Info</h3> | ||
<UserInfo user={userProfile?.data} /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./skeleton-user-info"; | ||
export * from "./user-info"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Card, CardBody, CardHeader, Skeleton } from "@nextui-org/react"; | ||
|
||
export const SkeletonUserInfo = () => { | ||
const rows = 4; | ||
|
||
return ( | ||
<Card> | ||
<CardHeader> | ||
<Skeleton className="h-6 w-1/3 rounded-lg"> | ||
<div className="h-6 bg-default-200"></div> | ||
</Skeleton> | ||
</CardHeader> | ||
<CardBody> | ||
<div className="grid grid-cols-1 gap-4"> | ||
{/* Header Skeleton */} | ||
<div className="grid grid-cols-4 border-b pb-2 text-sm font-semibold"> | ||
<Skeleton className="h-5 w-full rounded-lg"> | ||
<div className="h-5 bg-default-200"></div> | ||
</Skeleton> | ||
<Skeleton className="h-5 w-full rounded-lg"> | ||
<div className="h-5 bg-default-200"></div> | ||
</Skeleton> | ||
<Skeleton className="h-5 w-full rounded-lg"> | ||
<div className="h-5 bg-default-200"></div> | ||
</Skeleton> | ||
<Skeleton className="h-5 w-full rounded-lg"> | ||
<div className="h-5 bg-default-200"></div> | ||
</Skeleton> | ||
</div> | ||
|
||
{/* Row Skeletons */} | ||
{Array.from({ length: rows }).map((_, index) => ( | ||
<div | ||
key={index} | ||
className="grid grid-cols-4 items-center border-b py-2 text-sm" | ||
> | ||
{/* Provider Name */} | ||
<div className="flex items-center space-x-2"> | ||
<Skeleton className="h-5 w-5 rounded-lg"> | ||
<div className="h-5 w-5 bg-default-200"></div> | ||
</Skeleton> | ||
<Skeleton className="h-5 w-1/3 rounded-lg"> | ||
<div className="h-5 bg-default-200"></div> | ||
</Skeleton> | ||
</div> | ||
{/* Percent Passing */} | ||
<Skeleton className="h-5 w-1/4 rounded-lg"> | ||
<div className="h-5 bg-default-200"></div> | ||
</Skeleton> | ||
{/* Failing Checks */} | ||
<Skeleton className="h-5 w-1/4 rounded-lg"> | ||
<div className="h-5 bg-default-200"></div> | ||
</Skeleton> | ||
{/* Total Resources */} | ||
<Skeleton className="h-5 w-1/4 rounded-lg"> | ||
<div className="h-5 bg-default-200"></div> | ||
</Skeleton> | ||
</div> | ||
))} | ||
</div> | ||
</CardBody> | ||
</Card> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
"use client"; | ||
|
||
import { Card, CardBody } from "@nextui-org/react"; | ||
|
||
import { DateWithTime } from "@/components/ui/entities"; | ||
import { UserProfileProps } from "@/types"; | ||
|
||
export const UserInfo = ({ | ||
user, | ||
}: { | ||
user: UserProfileProps["data"] | null; | ||
}) => { | ||
if (!user || !user.attributes) { | ||
return ( | ||
<Card className="dark:bg-prowler-blue-400"> | ||
<CardBody> | ||
<div className="space-y-3"> | ||
<div className="flex items-center justify-between"> | ||
<p className="text-sm font-semibold text-default-600">Name:</p> | ||
<span className="text-sm">-</span> | ||
</div> | ||
<div className="flex items-center justify-between"> | ||
<p className="text-sm font-semibold text-default-600">Email:</p> | ||
<span className="text-sm">-</span> | ||
</div> | ||
<div className="flex items-center justify-between"> | ||
<p className="text-sm font-semibold text-default-600">Company:</p> | ||
<span className="text-sm">-</span> | ||
</div> | ||
<div className="flex items-center justify-between"> | ||
<p className="text-sm font-semibold text-default-600"> | ||
Date Joined: | ||
</p> | ||
<span className="text-sm">-</span> | ||
</div> | ||
</div> | ||
<div className="mt-4 text-center text-sm text-red-600"> | ||
Unable to load user information. | ||
<br /> | ||
Please check your API connection. | ||
</div> | ||
</CardBody> | ||
</Card> | ||
); | ||
} | ||
|
||
const { name, email, company_name, date_joined } = user.attributes; | ||
|
||
return ( | ||
<Card className="dark:bg-prowler-blue-400"> | ||
<CardBody> | ||
<div className="space-y-3"> | ||
<div className="flex items-center justify-between"> | ||
<p className="text-sm font-semibold text-default-600">Name:</p> | ||
<span className="text-sm">{name}</span> | ||
</div> | ||
<div className="flex items-center justify-between"> | ||
<p className="text-sm font-semibold text-default-600">Email:</p> | ||
<span className="text-sm">{email}</span> | ||
</div> | ||
<div className="flex items-center justify-between"> | ||
<p className="text-sm font-semibold text-default-600">Company:</p> | ||
<span className="text-sm">{company_name}</span> | ||
</div> | ||
<div className="flex items-center justify-between"> | ||
<p className="text-sm font-semibold text-default-600"> | ||
Date Joined: | ||
</p> | ||
<span className="text-sm"> | ||
<DateWithTime inline dateTime={date_joined} /> | ||
</span> | ||
</div> | ||
</div> | ||
</CardBody> | ||
</Card> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.