🎨 format oauth provider list
fixing the list format on oauth login.
This commit is contained in:
@ -3,57 +3,42 @@
|
||||
import { Button } from "@heroui/react";
|
||||
import { Icon } from "@iconify/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import getGoogleAuthUrl from "../lib/getGoogleAuthUrl";
|
||||
import getOauthProviderList from "../lib/getOauthProviderList";
|
||||
|
||||
const OAuthProviders = () => {
|
||||
const [UrlOauth, setUrlOauth] = useState("please wait...");
|
||||
const [oauthProvidersList, setOauthProvidersList] = useState<
|
||||
oauthProviders[]
|
||||
>([]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const res = await getGoogleAuthUrl(); // panggil server function
|
||||
setUrlOauth(JSON.stringify(res));
|
||||
const res = (await getOauthProviderList()) as oauthProviders[];
|
||||
setOauthProvidersList(res);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
// set to true if there are other providers coming soon
|
||||
const comingSoonProviders: boolean = true;
|
||||
|
||||
// Provider for third-party auth
|
||||
const oAuthProviders = [
|
||||
{
|
||||
name: "Google",
|
||||
icon: "logos:google-icon",
|
||||
},
|
||||
{
|
||||
name: "Discord",
|
||||
icon: "logos:discord-icon",
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="w-full flex flex-col gap-2 mt-4">
|
||||
{oAuthProviders.map((provider, index) => {
|
||||
return (
|
||||
<Button
|
||||
key={index}
|
||||
className="w-full hover:bg-neutral-800"
|
||||
variant="bordered"
|
||||
startContent={<Icon icon={provider.icon} />}
|
||||
>
|
||||
Continue with {provider.name}
|
||||
</Button>
|
||||
);
|
||||
})}
|
||||
|
||||
<h1>{UrlOauth}</h1>
|
||||
|
||||
{comingSoonProviders && (
|
||||
{oauthProvidersList.length > 0 ? (
|
||||
oauthProvidersList.map((provider, index) => {
|
||||
return (
|
||||
<Button
|
||||
key={index}
|
||||
className="w-full hover:bg-neutral-800"
|
||||
variant="bordered"
|
||||
startContent={<Icon icon={provider.icon} />}
|
||||
>
|
||||
Continue with {provider.name}
|
||||
</Button>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<Button className="w-full" variant="ghost" isDisabled>
|
||||
Other login options will come soon
|
||||
No login options available via third-party providers
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user