Change login route page to be register/login page
This commit is contained in:
parent
d123320797
commit
d87b702a9d
|
@ -14,7 +14,9 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const resp = await fetch("/api/auth/login", {
|
const url =
|
||||||
|
selected == "login" ? "/api/auth/login" : "/api/auth/register";
|
||||||
|
const resp = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
@ -34,12 +36,31 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let selected = $state("login");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Toasts />
|
<Toasts />
|
||||||
<div class="flex justify-center items-center min-h-screen bg-gray-100">
|
<div class="flex justify-center items-center min-h-screen bg-gray-100">
|
||||||
<div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md">
|
<div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md">
|
||||||
<h1 class="text-2xl font-bold text-center mb-6">Login</h1>
|
<div class="toggle-container">
|
||||||
|
<!-- Toggle Button -->
|
||||||
|
<div class="toggle">
|
||||||
|
<button
|
||||||
|
class:active={selected === "login"}
|
||||||
|
class="toggle-option"
|
||||||
|
onclick={() => (selected = "login")}
|
||||||
|
>
|
||||||
|
Login
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class:active={selected === "register"}
|
||||||
|
class="toggle-option"
|
||||||
|
onclick={() => (selected = "register")}
|
||||||
|
>
|
||||||
|
Register
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{#if error}
|
{#if error}
|
||||||
<p class="text-red-500 text-center mb-4">{error}</p>
|
<p class="text-red-500 text-center mb-4">{error}</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -68,12 +89,50 @@
|
||||||
placeholder="••••••••"
|
placeholder="••••••••"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<div class="flex flex-row justify-center">
|
||||||
type="submit"
|
<button
|
||||||
class="w-full bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 rounded-md focus:outline-none focus:ring focus:ring-blue-300"
|
type="submit"
|
||||||
>
|
class="submit-btn w-2/4 bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 rounded-md focus:outline-none focus:ring focus:ring-blue-300"
|
||||||
Login
|
>
|
||||||
</button>
|
{selected == "login" ? "Login" : "Register"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.toggle-container {
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
border: 2px solid #ccc;
|
||||||
|
border-radius: 9999px;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-option {
|
||||||
|
flex: 1;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: #f3f4f6; /* Default gray */
|
||||||
|
transition:
|
||||||
|
background-color 0.3s,
|
||||||
|
color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-option.active {
|
||||||
|
background-color: #3b82f6; /* Blue when selected */
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit-btn {
|
||||||
|
border-radius: 9999px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user