diff --git a/src/app/gpushed/cli-login/page.tsx b/src/app/gpushed/cli-login/page.tsx index 25c9691..e954084 100644 --- a/src/app/gpushed/cli-login/page.tsx +++ b/src/app/gpushed/cli-login/page.tsx @@ -10,8 +10,7 @@ import { Suspense, useEffect, useState } from 'react'; import { useSearchParams } from 'next/navigation'; -import { Box } from '@mui/material'; -import CheckCircleIcon from '@mui/icons-material/CheckCircle'; +import { Box, CircularProgress } from '@mui/material'; import AuthHeader from '@/app/components/auth-header'; import LoadingSpinner from '@/app/components/loading-spinner'; import { GPUSHED_ENDPOINT } from '@/app/constants'; @@ -70,51 +69,100 @@ function CliLoginContent() { return ; } - const button = - 'px-8 py-4 rounded-lg font-medium transition-all text-lg w-full text-center bg-pink-500 text-white hover:bg-pink-600 disabled:opacity-60'; + // Same card and controls as /login, so approving reads as part of signing in. + const primaryButtonClass = + 'w-full flex items-center justify-center gap-2 py-4 rounded-lg font-medium transition-all ' + + 'bg-pink-500 text-white hover:bg-pink-600 disabled:opacity-50 disabled:cursor-not-allowed ' + + 'disabled:hover:bg-pink-500'; - return ( + const card = (children: React.ReactNode) => ( - -
- {state === 'approved' ? ( -
- -
-

gpushed is signed in

-

Head back to your terminal; you can close this tab.

-
-
- ) : !code ? ( -
-

No sign-in code

-

- Run gpushed login in your terminal; it opens this page with its code. -

-
- ) : ( -
-
-

Sign in to gpushed?

-

- Approve only if your terminal shows this code{email && <> and you meant to sign in as {email}}. -

-
-
{code}
- {state === 'error' &&

{error}

} - -

- Didn't run gpushed login? Close this tab; nothing is signed in. -

-
- )} -
+ +
+ + {children} + +
); + + if (state === 'approved') { + return card( + <> +

gpushed is signed in

+

+ Head back to your terminal; you can close this tab. +

+ + ); + } + + if (!code) { + return card( + <> +

No sign-in code

+

+ Run gpushed login in your terminal; it opens this page with its code. +

+ + ); + } + + // The code in the same boxes /login uses for emailed codes, dash between groups. + const [first, second] = code.split('-'); + const boxes = (group: string) => + Array.from(group ?? '').map((ch, i) => ( + + {ch} + + )); + + return card( + <> +

Sign in to gpushed

+

+ Approve only if your terminal shows this code + {email && <> and you meant to sign in as {email}}. +

+ + + {boxes(first)} + – + {boxes(second)} + + + {state === 'error' && ( + +

{error}

+
+ )} + + + + +

+ Didn't run gpushed login? Close this tab; nothing is signed in. +

+
+ + ); } export default function GpushedCliLogin() {