Fix UI
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import dataService from '@/lib/data-service';
|
||||
"use client";
|
||||
import { fetchData } from "@/lib/data-service";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -13,7 +13,6 @@ import { Label } from "@/components/ui/label";
|
||||
export default function LoginPage() {
|
||||
const [username, setUsername] = useState(""); // ✅ Fixed incorrect state name
|
||||
const [password, setPassword] = useState("");
|
||||
const [rememberMe, setRememberMe] = useState(false); // ✅ Fixed missing state
|
||||
const [error, setError] = useState("");
|
||||
const router = useRouter();
|
||||
|
||||
@@ -21,18 +20,14 @@ export default function LoginPage() {
|
||||
e.preventDefault();
|
||||
setError("");
|
||||
|
||||
const res = await dataService.fetchData("https://internal-api.inboxi.ng/api/auth/login", {
|
||||
const res = await fetchData("https://internal-api.inboxi.ng/api/auth/login", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username, password }),
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
console.log(data);
|
||||
|
||||
document.cookie = `Authorization=${data.token}; path=/; Secure; SameSite=Strict; max-age=604800`;
|
||||
|
||||
if (res.token) {
|
||||
document.cookie = `Authorization=${res.token}; path=/; Secure; SameSite=Strict; max-age=604800`;
|
||||
router.push("/dashboard");
|
||||
} else {
|
||||
const data = await res.json();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import dataService from '@/lib/data-service';
|
||||
"use client";
|
||||
|
||||
import { fetchData } from "@/lib/data-service";
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Image from "next/image";
|
||||
@@ -22,17 +21,19 @@ export default function RegisterPage() {
|
||||
setError("");
|
||||
setLoading(true);
|
||||
|
||||
const res = await dataService.fetchData("https://internal-api.inboxi.ng/api/auth/register", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username, password, invitationCode }),
|
||||
});
|
||||
const res = await fetchData(
|
||||
"https://internal-api.inboxi.ng/api/auth/register",
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username, password, invitationCode }),
|
||||
}
|
||||
);
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
if (res.ok) {
|
||||
const data = await res;
|
||||
|
||||
if (res) {
|
||||
console.log("Registered successfully:", data);
|
||||
|
||||
router.push("/login");
|
||||
} else {
|
||||
setError(data.error || "Registration failed");
|
||||
@@ -45,8 +46,12 @@ export default function RegisterPage() {
|
||||
<div className="flex items-center justify-center min-h-screen bg-gray-100 dark:bg-[#0F0F12]">
|
||||
<div className="w-full max-w-md p-8 space-y-8 bg-white dark:bg-[#1F1F23] rounded-xl shadow-lg">
|
||||
<div className="text-center">
|
||||
<h2 className="mt-6 text-3xl font-bold text-gray-900 dark:text-white">Create an Account</h2>
|
||||
<p className="mt-2 text-sm text-gray-600 dark:text-gray-400">Sign up to start selling</p>
|
||||
<h2 className="mt-6 text-3xl font-bold text-gray-900 dark:text-white">
|
||||
Create an Account
|
||||
</h2>
|
||||
<p className="mt-2 text-sm text-gray-600 dark:text-gray-400">
|
||||
Sign up to start selling
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{error && <p className="text-red-500 text-sm text-center">{error}</p>}
|
||||
@@ -100,11 +105,14 @@ export default function RegisterPage() {
|
||||
|
||||
<p className="mt-6 text-sm text-center text-gray-600 dark:text-gray-400">
|
||||
Already have an account?{" "}
|
||||
<Link href="/login" className="text-blue-600 hover:underline dark:text-blue-400">
|
||||
<Link
|
||||
href="/login"
|
||||
className="text-blue-600 hover:underline dark:text-blue-400"
|
||||
>
|
||||
Sign in
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user