diff --git a/frontends/nextjs/src/components/level5/tabs/power-transfer/PowerTransferTab.tsx b/frontends/nextjs/src/components/level5/tabs/power-transfer/PowerTransferTab.tsx index 20a91aba2..3f8157ed6 100644 --- a/frontends/nextjs/src/components/level5/tabs/power-transfer/PowerTransferTab.tsx +++ b/frontends/nextjs/src/components/level5/tabs/power-transfer/PowerTransferTab.tsx @@ -1,15 +1,11 @@ 'use client' import { useEffect, useState } from 'react' -import { Button } from '@/components/ui' -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui' -import { ScrollArea } from '@/components/ui' -import { Badge } from '@/components/ui' -import { Separator } from '@/components/ui' -import { Alert, AlertDescription } from '@/components/ui' -import { Crown, ArrowsLeftRight } from '@phosphor-icons/react' +import { ArrowsLeftRight } from '@phosphor-icons/react' +import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Separator } from '@/components/ui' import type { PowerTransferRequest, User } from '@/lib/level-types' import { fetchPowerTransferRequests } from '@/lib/api/power-transfers' +import { CriticalActionNotice, TransferHistory, UserSelectionList } from './sections' interface PowerTransferTabProps { currentUser: User @@ -18,12 +14,6 @@ interface PowerTransferTabProps { refreshSignal?: number } -const STATUS_VARIANTS: Record = { - accepted: 'default', - pending: 'secondary', - rejected: 'destructive', -} - export function PowerTransferTab({ currentUser, allUsers, @@ -35,9 +25,7 @@ export function PowerTransferTab({ const [isLoadingRequests, setIsLoadingRequests] = useState(true) const [requestError, setRequestError] = useState(null) - const highlightedUsers = allUsers.filter( - (u) => u.id !== currentUser.id && u.role !== 'supergod' - ) + const highlightedUsers = allUsers.filter((u) => u.id !== currentUser.id && u.role !== 'supergod') useEffect(() => { let isActive = true @@ -69,22 +57,6 @@ export function PowerTransferTab({ } }, [refreshSignal]) - const sortedRequests = [...requests].sort((a, b) => b.createdAt - a.createdAt) - - const formatDate = (timestamp: number) => { - return new Date(timestamp).toLocaleString() - } - - const formatExpiry = (expiresAt: number) => { - const diff = expiresAt - Date.now() - if (diff <= 0) { - return 'Expired' - } - const minutes = Math.floor(diff / 60000) - const seconds = Math.floor((diff % 60000) / 1000) - return `${minutes}m ${seconds}s remaining` - } - const getUserLabel = (userId: string) => { const user = allUsers.find((u) => u.id === userId) return user ? user.username : userId @@ -100,97 +72,22 @@ export function PowerTransferTab({ -
-
- -
-

Critical Action

-

- This action cannot be undone. Only one Super God can exist at a time. After transfer, - you will have God-level access only. -

-
-
-
+ -
-

Select User to Transfer Power To:

- -
- {highlightedUsers.map((user) => ( - setSelectedUserId(user.id)} - > - -
-
-

{user.username}

-

{user.email}

-
- - {user.role} - -
-
-
- ))} -
-
-
+ -
-
-

Recent transfers

- {isLoadingRequests && ( - Refreshing... - )} -
- - {requestError && ( - - {requestError} - - )} - - -
- {sortedRequests.length === 0 && !isLoadingRequests ? ( -

No transfer history available.

- ) : ( - sortedRequests.map((request) => ( - - -
- - Transfer to {getUserLabel(request.toUserId)} - - - Requested by {getUserLabel(request.fromUserId)} - -
- - {request.status.charAt(0).toUpperCase() + request.status.slice(1)} - -
- -

Created: {formatDate(request.createdAt)}

-

Expires: {formatDate(request.expiresAt)}

-

{formatExpiry(request.expiresAt)}

-
-
- )) - )} -
-
-
+