-
- {/* Decorative images */}
-

-

-

-

+ {/* ===== Background Glows ===== */}
+
+
+
+
+
+
+
+
- {/* Main container */}
-
-
- {/* LEFT SIDE */}
-
+ {/* Logo */}
+
+

- p-5 lg:inline-flex lg:max-w-[835px]
- xl:-ms-28 ltr:xl:skew-x-[14deg] rtl:xl:skew-x-[-14deg]"
+
+ Create Your SocialBuddy Account
+
+
+
+ {/* Register Form */}
+
+
+ {/* Footer link */}
+
+ Already have an account?{' '}
+
-
-
- {/* Centered Image */}
-
-

-
-
-
- {/* RIGHT SIDE */}
-
-
- {/* Triple Logos */}
-
- {/* Logo 1 */}
-
-

-
-
- {/* Logo 2 */}
-
-

-
-
- {/* Logo 3 */}
-
-

-
-
-
-
-
-
-
- {/* signup Section */}
-
-
-
- Sign Up
-
-
- Enter your email and password to register
-
-
-
- {/* Register Form */}
-
-
- {/* Divider */}
-
-
-
- or
-
-
-
- {/* Social Icons */}
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
-
-
- {/* Login link */}
-
- Already have an account?
-
- SIGN IN
-
-
-
-
- {/* Footer text */}
-
- © {new Date().getFullYear()}. Data4Autos All Rights Reserved.
-
-
+ SIGN IN
+
);
-};
-
-export default CoverRegister;
+}
diff --git a/app/(defaults)/page.tsx b/app/(defaults)/page.tsx
index 3c765d6..9ff7913 100644
--- a/app/(defaults)/page.tsx
+++ b/app/(defaults)/page.tsx
@@ -6,7 +6,76 @@ export const metadata: Metadata = {
};
const Sales = () => {
- return
starter page
;
+ return (
+
+
+ {/* ================= BACKGROUND GLOWS (FROM UserModule) ================= */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* ================= PAGE CONTENT ================= */}
+
+
+
+
+
+
+
+ {/* Title */}
+
+ Sales Admin
+
+
+
+
+
+
+
+
+ );
};
export default Sales;
diff --git a/app/api/users/[id]/roue.ts b/app/api/users/[id]/roue.ts
new file mode 100644
index 0000000..8ffd11b
--- /dev/null
+++ b/app/api/users/[id]/roue.ts
@@ -0,0 +1,48 @@
+import { NextResponse } from 'next/server';
+
+const API_BASE = 'https://api.socialbuddy.co/api/users';
+
+const normalizeUser = (u: any) => ({
+ userid: u._id,
+ name: u.name,
+ email: u.email,
+ mobile: u.mobileNumber,
+ role: u.role,
+ createdAt: u.createdAt,
+});
+
+// GET by id
+export async function GET(
+ _req: Request,
+ { params }: { params: { id: string } }
+) {
+ const res = await fetch(`${API_BASE}/${params.id}`);
+ const data = await res.json();
+ return NextResponse.json(normalizeUser(data));
+}
+
+// UPDATE (admin)
+export async function PUT(
+ req: Request,
+ { params }: { params: { id: string } }
+) {
+ const body = await req.json();
+
+ const res = await fetch(`${API_BASE}/${params.id}`, {
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(body),
+ });
+
+ const data = await res.json();
+ return NextResponse.json(normalizeUser(data));
+}
+
+// DELETE (admin)
+export async function DELETE(
+ _req: Request,
+ { params }: { params: { id: string } }
+) {
+ await fetch(`${API_BASE}/${params.id}`, { method: 'DELETE' });
+ return NextResponse.json({ success: true });
+}
diff --git a/app/api/users/route.ts b/app/api/users/route.ts
new file mode 100644
index 0000000..6851cd4
--- /dev/null
+++ b/app/api/users/route.ts
@@ -0,0 +1,57 @@
+import { NextResponse } from 'next/server';
+
+const API_BASE = 'https://api.socialbuddy.co/api/users';
+
+const normalizeUser = (u: any) => ({
+ userid: u._id,
+ name: u.name,
+ email: u.email,
+ mobileNumber:
+ u.mobileNumber ||
+ u.mobile ||
+ u.phone ||
+ u.phonenumber ||
+ '',
+ role: u.role,
+});
+
+// GET users
+export async function GET() {
+ const res = await fetch(API_BASE, {
+ credentials: 'include',
+ });
+ const data = await res.json();
+ return NextResponse.json(data.map(normalizeUser));
+}
+
+// ✅ ADD USER (ADMIN ONLY)
+export async function POST(req: Request) {
+ const body = await req.json();
+
+ const res = await fetch(`${API_BASE}/create`, {
+ method: 'POST',
+
+ // REQUIRED
+ credentials: 'include',
+
+ headers: {
+ 'Content-Type': 'application/json',
+
+ // THIS LINE IS WHY ADD USER WAS FAILING
+ Cookie: req.headers.get('cookie') || '',
+ },
+
+ body: JSON.stringify(body),
+ });
+
+ if (!res.ok) {
+ const error = await res.text();
+ return NextResponse.json(
+ { error },
+ { status: res.status }
+ );
+ }
+
+ const data = await res.json();
+ return NextResponse.json(normalizeUser(data));
+}
diff --git a/components/auth/components-auth-forgot-form.tsx b/components/auth/components-auth-forgot-form.tsx
index c3d8a60..569636b 100644
--- a/components/auth/components-auth-forgot-form.tsx
+++ b/components/auth/components-auth-forgot-form.tsx
@@ -2,6 +2,7 @@
import React, { useState } from "react";
import axios from "axios";
+import { Mail } from "lucide-react";
export default function ForgotPasswordForm() {
const [email, setEmail] = useState("");
@@ -12,12 +13,16 @@ export default function ForgotPasswordForm() {
e.preventDefault();
setLoading(true);
setMessage("");
+
try {
- const res = await axios.post("https://ebay.backend.data4autos.com/api/auth/forgot-password", { email });
+ await axios.post(
+ "https://ebay.backend.data4autos.com/api/auth/forgot-password",
+ { email }
+ );
setMessage("✅ We’ve emailed you a reset code / link. Enter it below.");
- } catch (err: any) {
+ } catch (err) {
console.error(err);
- setMessage("Something went wrong. Try again.");
+ setMessage("❌ Something went wrong. Try again.");
} finally {
setLoading(false);
}
@@ -25,27 +30,59 @@ export default function ForgotPasswordForm() {
return (
);
-}
+}
\ No newline at end of file
diff --git a/components/auth/components-auth-login-form.tsx b/components/auth/components-auth-login-form.tsx
index ce0fe72..830c025 100644
--- a/components/auth/components-auth-login-form.tsx
+++ b/components/auth/components-auth-login-form.tsx
@@ -1,148 +1,217 @@
'use client';
+
import React, { useState } from 'react';
import { useRouter, useSearchParams } from 'next/navigation';
import IconLockDots from '@/components/icon/icon-lock-dots';
import IconMail from '@/components/icon/icon-mail';
+import Link from 'next/link';
+import { Eye, EyeOff } from 'lucide-react';
+import { FcGoogle } from 'react-icons/fc';
const ComponentsAuthLoginForm = () => {
const router = useRouter();
const searchParams = useSearchParams();
const nextUrl = searchParams.get('next') || '/';
- const [email, setEmail] = useState('');
- const [password, setPassword] = useState('');
+ const [formData, setFormData] = useState({
+ email: '',
+ password: '',
+ });
const [loading, setLoading] = useState(false);
const [err, setErr] = useState
(null);
const [msg, setMsg] = useState(null);
+ const [showPassword, setShowPassword] = useState(false);
+
+ const handleChange = (e: React.ChangeEvent) => {
+ const { name, value } = e.target;
+ setFormData((prev) => ({ ...prev, [name]: value }));
+ };
const submitForm = async (e: React.FormEvent) => {
e.preventDefault();
setErr(null);
setMsg(null);
- if (!email || !password) {
+ if (!formData.email || !formData.password) {
setErr('Please enter email and password.');
return;
}
setLoading(true);
try {
- // ✅ Call your Next.js API (same origin), which sets d4a_uid, d4a_session, d4a_exp cookies
- const res = await fetch('https://ebay.backend.data4autos.com/api/auth/login', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- // credentials not required for same-origin, but harmless:
- credentials: 'same-origin',
- body: JSON.stringify({ email, password }),
- });
+ // ✅ SAME backend logic as your old working code
+ const res = await fetch(
+ 'https://ebay.backend.data4autos.com/api/auth/login',
+ {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'same-origin',
+ body: JSON.stringify(formData),
+ }
+ );
const contentType = res.headers.get('content-type') || '';
- const data = contentType.includes('application/json') ? await res.json() : await res.text();
- console.log("data data", data)
- try {
- console.log('data:', data.store);
- sessionStorage.setItem('USERID', data.userid);
- sessionStorage.setItem('EBAYSTOREID', data.store.urlPath);
- localStorage.setItem('data4auto_uid', data.userid);
- localStorage.setItem('d4a_email', data.email);
- data?.payment?.stripeSessionId && localStorage.setItem('payment_session', data?.payment?.stripeSessionId);
-
- console.log('set sessionStorage USERID');
- } catch {
- console.log('no sessionStorage');
- }
+ const data =
+ contentType.includes('application/json')
+ ? await res.json()
+ : await res.text();
if (!res.ok) {
- throw new Error((typeof data === 'object' && (data?.message || data?.error)) || `Login failed (${res.status})`);
+ throw new Error(
+ (typeof data === 'object' &&
+ (data?.message || data?.error)) ||
+ `Login failed (${res.status})`
+ );
}
- // (DEV ONLY) quick check that cookies were set:
- if (process.env.NODE_ENV !== 'production') {
- try {
- const who = await fetch('/api/debug/whoami', { cache: 'no-store' }).then((r) => r.json());
- console.log('whoami:', who);
+ // ✅ Preserve existing storage behavior
+ try {
+ sessionStorage.setItem('USERID', data.userid);
+ sessionStorage.setItem('EBAYSTOREID', data.store?.urlPath);
+ localStorage.setItem('data4auto_uid', data.userid);
+ localStorage.setItem('d4a_email', data.email);
- } catch { }
- }
+ data?.payment?.stripeSessionId &&
+ localStorage.setItem(
+ 'payment_session',
+ data.payment.stripeSessionId
+ );
+ } catch {}
setMsg('Login successful!');
setTimeout(() => router.push(nextUrl), 500);
} catch (e: any) {
- setErr(e?.message || 'Something went wrong. Please try again.');
+ setErr(e?.message || 'Login failed');
} finally {
setLoading(false);
}
};
return (
-