({
onTimeout,
}: AuthInProgressProps)
| 16 | } |
| 17 | |
| 18 | export function AuthInProgress({ |
| 19 | onTimeout, |
| 20 | }: AuthInProgressProps): React.JSX.Element { |
| 21 | const [timedOut, setTimedOut] = useState(false); |
| 22 | |
| 23 | useKeypress( |
| 24 | (key) => { |
| 25 | if (key.name === 'escape' || (key.ctrl && key.name === 'c')) { |
| 26 | onTimeout(); |
| 27 | } |
| 28 | }, |
| 29 | { isActive: true }, |
| 30 | ); |
| 31 | |
| 32 | useEffect(() => { |
| 33 | const timer = setTimeout(() => { |
| 34 | setTimedOut(true); |
| 35 | onTimeout(); |
| 36 | }, 180000); |
| 37 | |
| 38 | return () => clearTimeout(timer); |
| 39 | }, [onTimeout]); |
| 40 | |
| 41 | return ( |
| 42 | <Box |
| 43 | borderStyle="round" |
| 44 | borderColor={Colors.Gray} |
| 45 | flexDirection="column" |
| 46 | padding={1} |
| 47 | width="100%" |
| 48 | > |
| 49 | {timedOut ? ( |
| 50 | <Text color={Colors.AccentRed}> |
| 51 | Authentication timed out. Please try again. |
| 52 | </Text> |
| 53 | ) : ( |
| 54 | <Box> |
| 55 | <Text> |
| 56 | <Spinner type="dots" /> Waiting for auth... (Press ESC or CTRL+C to |
| 57 | cancel) |
| 58 | </Text> |
| 59 | </Box> |
| 60 | )} |
| 61 | </Box> |
| 62 | ); |
| 63 | } |
nothing calls this directly
no test coverage detected