Skip to content

Commit

Permalink
promote: staging to production
Browse files Browse the repository at this point in the history
  • Loading branch information
gurusainath authored Jun 14, 2023
2 parents 49f19c2 + c3aa1cb commit 02111d7
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 214 deletions.
2 changes: 1 addition & 1 deletion apiserver/runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.11.3
python-3.11.4
29 changes: 17 additions & 12 deletions apps/app/components/account/email-code-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type EmailCodeFormValues = {
token?: string;
};

export const EmailCodeForm = ({ onSuccess }: any) => {
export const EmailCodeForm = ({ handleSignIn }: any) => {
const [codeSent, setCodeSent] = useState(false);
const [codeResent, setCodeResent] = useState(false);
const [isCodeResending, setIsCodeResending] = useState(false);
Expand Down Expand Up @@ -66,18 +66,23 @@ export const EmailCodeForm = ({ onSuccess }: any) => {

const handleSignin = async (formData: EmailCodeFormValues) => {
setIsLoading(true);
await authenticationService.magicSignIn(formData).catch((error) => {
setIsLoading(false);
setToastAlert({
title: "Oops!",
type: "error",
message: error?.response?.data?.error ?? "Enter the correct code to sign in",
});
setError("token" as keyof EmailCodeFormValues, {
type: "manual",
message: error.error,
await authenticationService
.magicSignIn(formData)
.then((response) => {
handleSignIn(response);
})
.catch((error) => {
setIsLoading(false);
setToastAlert({
title: "Oops!",
type: "error",
message: error?.response?.data?.error ?? "Enter the correct code to sign in",
});
setError("token" as keyof EmailCodeFormValues, {
type: "manual",
message: error?.error,
});
});
});
};

const emailOld = getValues("email");
Expand Down
12 changes: 7 additions & 5 deletions apps/app/components/account/github-login-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export const GithubLoginButton: FC<GithubLoginButtonProps> = (props) => {
} = useRouter();
// states
const [loginCallBackURL, setLoginCallBackURL] = useState(undefined);
const [gitCode, setGitCode] = useState<null | string>(null);

useEffect(() => {
if (code) {
if (code && !gitCode) {
setGitCode(code.toString());
handleSignIn(code.toString());
}
}, [code, handleSignIn]);
}, [code, gitCode, handleSignIn]);

useEffect(() => {
const origin =
Expand All @@ -33,12 +35,12 @@ export const GithubLoginButton: FC<GithubLoginButtonProps> = (props) => {
}, []);

return (
<div className="w-full px-1">
<div className="w-full flex justify-center items-center px-[3px]">
<Link
href={`https://github.com/login/oauth/authorize?client_id=${NEXT_PUBLIC_GITHUB_ID}&redirect_uri=${loginCallBackURL}&scope=read:user,user:email`}
>
<button className="flex w-full items-center justify-center gap-3 rounded-md border border-brand-base p-2 text-sm font-medium text-brand-secondary duration-300 hover:bg-brand-surface-2">
<Image src={githubImage} height={22} width={22} color="#000" alt="GitHub Logo" />
<button className="flex w-full items-center justify-center gap-3 rounded border border-brand-base p-2 text-sm font-medium text-brand-secondary duration-300 hover:bg-brand-surface-2">
<Image src={githubImage} height={20} width={20} color="#000" alt="GitHub Logo" />
<span>Sign In with Github</span>
</button>
</Link>
Expand Down
6 changes: 5 additions & 1 deletion apps/app/components/account/google-login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ export const GoogleLoginButton: FC<IGoogleLoginButton> = (props) => {
return (
<>
<Script src="https://accounts.google.com/gsi/client" async defer onLoad={loadScript} />
<div className="overflow-hidden rounded" id="googleSignInButton" ref={googleSignInButton} />
<div
className="overflow-hidden rounded w-full flex justify-center items-center"
id="googleSignInButton"
ref={googleSignInButton}
/>
</>
);
};
2 changes: 1 addition & 1 deletion apps/app/components/onboarding/invite-members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ICurrentUserResponse, IUser } from "types";
import { MultiInput, PrimaryButton, SecondaryButton } from "components/ui";

type Props = {
setStep: React.Dispatch<React.SetStateAction<number>>;
setStep: React.Dispatch<React.SetStateAction<number | null>>;
workspace: any;
user: ICurrentUserResponse | undefined;
};
Expand Down
2 changes: 1 addition & 1 deletion apps/app/components/onboarding/user-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const defaultValues: Partial<IUser> = {

type Props = {
user?: IUser;
setStep: React.Dispatch<React.SetStateAction<number>>;
setStep: React.Dispatch<React.SetStateAction<number | null>>;
setUserRole: React.Dispatch<React.SetStateAction<string | null>>;
};

Expand Down
2 changes: 1 addition & 1 deletion apps/app/components/onboarding/workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { PrimaryButton } from "components/ui";
import { getFirstCharacters, truncateText } from "helpers/string.helper";

type Props = {
setStep: React.Dispatch<React.SetStateAction<number>>;
setStep: React.Dispatch<React.SetStateAction<number | null>>;
setWorkspace: React.Dispatch<React.SetStateAction<any>>;
user: ICurrentUserResponse | undefined;
};
Expand Down
15 changes: 14 additions & 1 deletion apps/app/components/workspace/create-workspace-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { mutate } from "swr";
import { Controller, useForm } from "react-hook-form";
// services
import workspaceService from "services/workspace.service";
import userService from "services/user.service";
// hooks
import useToast from "hooks/use-toast";
// ui
Expand Down Expand Up @@ -77,7 +78,7 @@ export const CreateWorkspaceForm: React.FC<Props> = ({
message: "Workspace created successfully.",
});
mutate<IWorkspace[]>(USER_WORKSPACES, (prevData) => [res, ...(prevData ?? [])]);
onSubmit(res);
updateLastWorkspaceIdUnderUSer(res);
})
.catch((err) => {
console.error(err);
Expand All @@ -93,6 +94,18 @@ export const CreateWorkspaceForm: React.FC<Props> = ({
});
};

// update last_workspace_id
const updateLastWorkspaceIdUnderUSer = (workspace: any) => {
userService
.updateUser({ last_workspace_id: workspace.id })
.then((res) => {
onSubmit(workspace);
})
.catch((err) => {
console.log(err);
});
};

useEffect(
() => () => {
// when the component unmounts set the default values to whatever user typed in
Expand Down
1 change: 1 addition & 0 deletions apps/app/hooks/use-user-auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
mutate,
} = useSWR<ICurrentUserResponse>(CURRENT_USER, () => userService.currentUser(), {
refreshInterval: 0,
shouldRetryOnError: false,
});

useEffect(() => {
Expand Down
13 changes: 7 additions & 6 deletions apps/app/pages/[workspaceSlug]/analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ const Analytics = () => {
useEffect(() => {
if (!workspaceSlug) return;

trackEventServices.trackAnalyticsEvent(
{ workspaceSlug: workspaceSlug?.toString() },
"WORKSPACE_SCOPE_AND_DEMAND_ANALYTICS",
user
);
}, [workspaceSlug]);
if (user && workspaceSlug)
trackEventServices.trackAnalyticsEvent(
{ workspaceSlug: workspaceSlug?.toString() },
"WORKSPACE_SCOPE_AND_DEMAND_ANALYTICS",
user
);
}, [user, workspaceSlug]);

return (
<WorkspaceAuthorizationLayout
Expand Down
78 changes: 49 additions & 29 deletions apps/app/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,69 +30,91 @@ const HomePage: NextPage = () => {
const handleGoogleSignIn = async ({ clientId, credential }: any) => {
try {
if (clientId && credential) {
mutateUser(
await authenticationService.socialAuth({
medium: "google",
credential,
clientId,
})
);
const socialAuthPayload = {
medium: "google",
credential,
clientId,
};
const response = await authenticationService.socialAuth(socialAuthPayload);
if (response && response?.user) mutateUser();
} else {
throw Error("Cant find credentials");
}
} catch (error) {
} catch (error: any) {
console.log(error);
setToastAlert({
title: "Error signing in!",
type: "error",
message: "Something went wrong. Please try again later or contact the support team.",
message:
error?.error ||
"Something went wrong. Please try again later or contact the support team.",
});
}
};

const handleGithubSignIn = async (credential: string) => {
try {
if (process.env.NEXT_PUBLIC_GITHUB_ID && credential) {
mutateUser(
await authenticationService.socialAuth({
medium: "github",
credential,
clientId: process.env.NEXT_PUBLIC_GITHUB_ID,
})
);
const socialAuthPayload = {
medium: "github",
credential,
clientId: process.env.NEXT_PUBLIC_GITHUB_ID,
};
const response = await authenticationService.socialAuth(socialAuthPayload);
if (response && response?.user) mutateUser();
} else {
throw Error("Cant find credentials");
}
} catch (error) {
} catch (error: any) {
console.log(error);
setToastAlert({
title: "Error signing in!",
type: "error",
message: "Something went wrong. Please try again later or contact the support team.",
message:
error?.error ||
"Something went wrong. Please try again later or contact the support team.",
});
}
};

const handleEmailPasswordSignIn = async (response: any) => {
try {
if (response) {
mutateUser();
}
} catch (error) {
if (response) mutateUser();
} catch (error: any) {
console.log(error);
setToastAlert({
title: "Error signing in!",
type: "error",
message: "Something went wrong. Please try again later or contact the support team.",
message:
error?.error ||
"Something went wrong. Please try again later or contact the support team.",
});
}
};

const handleEmailCodeSignIn = async (response: any) => {
try {
if (response) mutateUser();
} catch (error: any) {
console.log(error);
setToastAlert({
title: "Error signing in!",
type: "error",
message:
error?.error ||
"Something went wrong. Please try again later or contact the support team.",
});
}
};

return (
<DefaultLayout>
{isLoading ? (
<div className="grid h-screen place-items-center">
<Spinner />
<div className="flex flex-col gap-3 w-full h-screen justify-center items-center">
<div>
<Spinner />
</div>
{/* <div className="text-gray-500">Validating authentication</div> */}
</div>
) : (
<div className="flex h-screen w-full items-center justify-center overflow-auto">
Expand All @@ -108,16 +130,14 @@ const HomePage: NextPage = () => {
<div className="flex flex-col rounded-[10px] bg-brand-base shadow-md">
{parseInt(process.env.NEXT_PUBLIC_ENABLE_OAUTH || "0") ? (
<>
<EmailCodeForm />
<EmailCodeForm handleSignIn={handleEmailCodeSignIn} />
<div className="flex flex-col items-center justify-center gap-3 border-t border-brand-base py-5 px-5">
<GoogleLoginButton handleSignIn={handleGoogleSignIn} />
<GithubLoginButton handleSignIn={handleGithubSignIn} />
</div>
</>
) : (
<>
<EmailPasswordForm handleSignIn={handleEmailPasswordSignIn} />
</>
<EmailPasswordForm handleSignIn={handleEmailPasswordSignIn} />
)}
</div>
</div>
Expand Down
Loading

2 comments on commit 02111d7

@vercel
Copy link

@vercel vercel bot commented on 02111d7 Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

plane – ./apps/app

plane-theta.vercel.app
plane-plane.vercel.app
plane-git-master-plane.vercel.app
app.plane.so

@vercel
Copy link

@vercel vercel bot commented on 02111d7 Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

plane-hot-fix – ./apps/app

plane-hot-fix.vercel.app
plane-hot-fix-plane.vercel.app
plane-hot-fix-git-hot-fix-plane.vercel.app

Please sign in to comment.