diff --git a/app/client/src/modules/home/components/admin/components/users/users.component.tsx b/app/client/src/modules/home/components/admin/components/users/users.component.tsx index b002add..b61d36e 100644 --- a/app/client/src/modules/home/components/admin/components/users/users.component.tsx +++ b/app/client/src/modules/home/components/admin/components/users/users.component.tsx @@ -1,31 +1,71 @@ import { useAdmin } from "shared/hooks"; -import React from "react"; +import React, { useMemo } from "react"; +import { cn, getCensoredEmail } from "shared/utils"; +import dayjs from "dayjs"; + //@ts-ignore import styles from "./users.module.scss"; -import { cn, getCensoredEmail } from "shared/utils"; export const UsersComponent = () => { const { users } = useAdmin(); + const verifiedUsers = useMemo( + () => users.filter(($user) => $user.verified), + [users], + ); + const today = dayjs(Date.now()); + + const temporalUsers = useMemo( + () => + users + .filter(($user) => !$user.verified) + .map(($user) => { + const expireAt = dayjs($user.createdAt).add(1, "day"); + const remainingMinutes = expireAt.diff(today, "minutes"); + + return { + ...$user, + remainingTime: `${Math.floor(remainingMinutes / 60)} hours ${remainingMinutes % 60} minutes`, + }; + }), + [users, today], + ); + return (
-

Users ({users.length})

-
- {users.map((user) => ( -
- - - - - - -
- ))} +
+

Users ({verifiedUsers.length})

+
+ {verifiedUsers.map((user) => ( +
+ + + + + + +
+ ))} +
+
+
+

Temp Users ({temporalUsers.length})

+
+ {temporalUsers.map((user) => ( +
+ + + + +
{user.remainingTime} remaining
+
+ ))} +
); diff --git a/app/client/src/shared/types/user.types.ts b/app/client/src/shared/types/user.types.ts index 20b4f7c..831c142 100644 --- a/app/client/src/shared/types/user.types.ts +++ b/app/client/src/shared/types/user.types.ts @@ -5,4 +5,5 @@ export type User = { email: string; admin?: boolean; otp?: boolean; + verified?: boolean; }; diff --git a/app/server/src/modules/api/v3/admin/users.request.ts b/app/server/src/modules/api/v3/admin/users.request.ts index 1de8902..4aa8f4f 100644 --- a/app/server/src/modules/api/v3/admin/users.request.ts +++ b/app/server/src/modules/api/v3/admin/users.request.ts @@ -26,6 +26,7 @@ export const usersGetRequest: RequestType = { admin: Boolean(await System.admins.get(account.accountId)), otp: await System.otp.isOTPVerified(account.accountId), createdAt: account.createdAt, + verified: account.verified, })), ) ).sort((userA: any, userB: any) =>