Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/dashboard/app/auth/oauth-button.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"use client";

import type { PropsWithChildren } from "react";
import type { ComponentProps } from "react";

type Props = {
onClick: () => Promise<unknown>;
};
export const OAuthButton: React.FC<PropsWithChildren<Props>> = ({ onClick, children }) => {
type ButtonElementProps = ComponentProps<"button">;

export const OAuthButton: React.FC<ButtonElementProps> = ({ onClick, disabled, children }) => {
return (
<button
type="button"
className="relative flex items-center justify-center h-10 gap-2 px-4 text-sm font-semibold text-white duration-500 border rounded-lg bg-white/10 hover:bg-white hover:text-black border-white/10"
disabled={disabled}
className="relative flex items-center justify-center h-10 gap-2 px-4 text-sm font-semibold text-white duration-500 border rounded-lg bg-white/10 enabled:hover:bg-white enabled:hover:text-black border-white/10 disabled:opacity-50 disabled:cursor-not-allowed"
onClick={onClick}
>
{children}
Expand Down
16 changes: 12 additions & 4 deletions apps/dashboard/app/auth/sign-in/oauth-signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { toast } from "@/components/ui/toaster";
import { useSignIn } from "@clerk/nextjs";
import type { OAuthStrategy } from "@clerk/types";
import * as React from "react";
import { useIsClient } from "usehooks-ts";
import { OAuthButton } from "../oauth-button";
import { LastUsed, useLastUsed } from "./last_used";

export const OAuthSignIn: React.FC = () => {
const isClient = useIsClient();
const [isLoading, setIsLoading] = React.useState<OAuthStrategy | null>(null);
const { signIn, isLoaded: signInLoaded } = useSignIn();
const [lastUsed, setLastUsed] = useLastUsed();
Expand All @@ -35,21 +37,27 @@ export const OAuthSignIn: React.FC = () => {

return (
<div className="flex flex-col gap-2">
<OAuthButton onClick={() => oauthSignIn("oauth_github")}>
<OAuthButton
disabled={isLoading === "oauth_github"}
onClick={() => oauthSignIn("oauth_github")}
>
{isLoading === "oauth_github" ? (
<Loading className="w-6 h-6" />
) : (
<GitHub className="w-6 h-6" />
)}
GitHub {lastUsed === "github" ? <LastUsed /> : null}
GitHub {isClient && lastUsed === "github" ? <LastUsed /> : null}
</OAuthButton>
<OAuthButton onClick={() => oauthSignIn("oauth_google")}>
<OAuthButton
disabled={isLoading === "oauth_google"}
onClick={() => oauthSignIn("oauth_google")}
>
{isLoading === "oauth_google" ? (
<Loading className="w-6 h-6" />
) : (
<Google className="w-6 h-6" />
)}
Google {lastUsed === "google" ? <LastUsed /> : null}
Google {isClient && lastUsed === "google" ? <LastUsed /> : null}
</OAuthButton>
</div>
);
Expand Down