Skip to content

Commit

Permalink
fix: browser login.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
35C4n0r committed Dec 3, 2024
1 parent 9293499 commit f30fead
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions source/commands/login.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { Text } from 'ink';
import { type infer as zInfer, object, string } from 'zod';
import { option } from 'pastel';
Expand Down Expand Up @@ -39,30 +39,33 @@ export default function Login({ options: { key, workspace } }: Props) {
const [organization, setOrganization] = useState<string>('');
const [environment, setEnvironment] = useState<string>('');

const onEnvironmentSelectSuccess = async (
organisation: ActiveState,
_project: ActiveState,
environment: ActiveState,
secret: string,
) => {
setOrganization(organisation.label);
setEnvironment(environment.label);
await saveAuthToken(secret);
setState('done');
process.exit(1);
};
const onEnvironmentSelectSuccess = useCallback(
async (
organisation: ActiveState,
_project: ActiveState,
environment: ActiveState,
secret: string,
) => {
setOrganization(organisation.label);
setEnvironment(environment.label);
await saveAuthToken(secret);
setState('done');
process.exit(1);
},
[],
);

useEffect(() => {
if (error) {
process.exit(1);
}
}, [error]);

const onLoginSuccess = (accessToken: string, cookie: string) => {
const onLoginSuccess = useCallback((accessToken: string, cookie: string) => {
setAccessToken(accessToken);
setCookie(cookie);
setState('env');
};
}, []);

return (
<>
Expand Down

0 comments on commit f30fead

Please sign in to comment.