minor fix

This commit is contained in:
daniel31x13
2023-12-07 12:41:27 -05:00
parent a6a9402425
commit 8786f8b5fe
+36 -26
View File
@@ -5,21 +5,22 @@ import { signIn } from "next-auth/react";
import Link from "next/link"; import Link from "next/link";
import { useState, FormEvent } from "react"; import { useState, FormEvent } from "react";
import { toast } from "react-hot-toast"; import { toast } from "react-hot-toast";
import {getLogins} from './api/v1/logins' import { getLogins } from "./api/v1/logins";
import {InferGetServerSidePropsType} from "next"; import { InferGetServerSidePropsType } from "next";
interface FormData { interface FormData {
username: string; username: string;
password: string; password: string;
} }
export const getServerSideProps = (() => { export const getServerSideProps = () => {
const availableLogins = getLogins(); const availableLogins = getLogins();
return {props: {availableLogins}} return { props: { availableLogins } };
}); };
export default function Login({
export default function Login({availableLogins} : InferGetServerSidePropsType<typeof getServerSideProps>) { availableLogins,
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
const [submitLoader, setSubmitLoader] = useState(false); const [submitLoader, setSubmitLoader] = useState(false);
const [form, setForm] = useState<FormData>({ const [form, setForm] = useState<FormData>({
@@ -66,23 +67,28 @@ export default function Login({availableLogins} : InferGetServerSidePropsType<ty
} }
function displayLoginCredential() { function displayLoginCredential() {
if (availableLogins.credentialsEnabled === 'true') { if (availableLogins.credentialsEnabled === "true") {
return (<><p className="text-3xl text-black dark:text-white text-center font-extralight"> return (
<>
<p className="text-3xl text-black dark:text-white text-center font-extralight">
Enter your credentials Enter your credentials
</p> </p>
<hr className="border-1 border-sky-100 dark:border-neutral-700"/> <hr className="border-1 border-sky-100 dark:border-neutral-700" />
<div> <div>
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1"> <p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
Username Username
{availableLogins.emailEnabled === 'true' ? " or Email" : undefined} {availableLogins.emailEnabled === "true"
? " or Email"
: undefined}
</p> </p>
<TextInput <TextInput
autoFocus={true} autoFocus={true}
placeholder="johnny" placeholder="johnny"
value={form.username} value={form.username}
className="bg-white" className="bg-base-100"
onChange={(e) => setForm({...form, username: e.target.value})}/> onChange={(e) => setForm({ ...form, username: e.target.value })}
/>
</div> </div>
<div className="w-full"> <div className="w-full">
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1"> <p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
@@ -93,9 +99,10 @@ export default function Login({availableLogins} : InferGetServerSidePropsType<ty
type="password" type="password"
placeholder="••••••••••••••" placeholder="••••••••••••••"
value={form.password} value={form.password}
className="bg-white" className="bg-base-100"
onChange={(e) => setForm({...form, password: e.target.value})}/> onChange={(e) => setForm({ ...form, password: e.target.value })}
{availableLogins.emailEnabled === 'true' && ( />
{availableLogins.emailEnabled === "true" && (
<div className="w-fit ml-auto mt-1"> <div className="w-fit ml-auto mt-1">
<Link <Link
href={"/forgot"} href={"/forgot"}
@@ -106,35 +113,38 @@ export default function Login({availableLogins} : InferGetServerSidePropsType<ty
</div> </div>
)} )}
</div> </div>
<SubmitButton <AccentSubmitButton
type="submit" type="submit"
label="Login" label="Login"
className=" w-full text-center" className=" w-full text-center"
loading={submitLoader}/></> loading={submitLoader}
) />
</>
);
} }
} }
function displayLoginExternalButton() { function displayLoginExternalButton() {
const Buttons: any = []; const Buttons: any = [];
availableLogins.buttonAuths.forEach((value, index) => { availableLogins.buttonAuths.forEach((value, index) => {
Buttons.push(<SubmitButton key={index} Buttons.push(
<AccentSubmitButton
key={index}
type="button" type="button"
onClick={() => loginUserButton(value.method)} onClick={() => loginUserButton(value.method)}
label={`Sign in with ${value.name}`} label={`Sign in with ${value.name}`}
className=" w-full text-center" className=" w-full text-center"
loading={submitLoader} loading={submitLoader}
/>); />
);
}); });
return (Buttons); return Buttons;
} }
function displayRegistration() { function displayRegistration() {
if (availableLogins.registrationDisabled !== 'true') { if (availableLogins.registrationDisabled !== "true") {
return ( return (
<div className="flex items-baseline gap-1 justify-center"> <div className="flex items-baseline gap-1 justify-center">
<p className="w-fit text-gray-500 dark:text-gray-400"> <p className="w-fit text-gray-500 dark:text-gray-400">New here?</p>
New here?
</p>
<Link <Link
href={"/register"} href={"/register"}
className="block text-black dark:text-white font-semibold" className="block text-black dark:text-white font-semibold"