use leptos::prelude::*;

#[component]
pub fn LoginForm() -> impl IntoView {
    let (email, set_email) = signal("".to_string());
    let (password, set_password) = signal("".to_string());

    let handle_submit = move |_| {
        // Placeholder login logic
        web_sys::console::log_1(&"Login attempted".into());
    };

    view! {
        <form on:submit=handle_submit class="space-y-4">
            <div>
                <label for="email" class="block text-sm font-medium text-gray-700">
                    "Email"
                </label>
                <input
                    type="email"
                    id="email"
                    class="mt-1 block w-full border border-gray-300 rounded-md px-3 py-2 text-sm"
                    on:input=move |ev| {
                        set_email.set(event_target_value(&ev));
                    }
                    prop:value=email
                />
            </div>
            <div>
                <label for="password" class="block text-sm font-medium text-gray-700">
                    "Password"
                </label>
                <input
                    type="password"
                    id="password"
                    class="mt-1 block w-full border border-gray-300 rounded-md px-3 py-2 text-sm"
                    on:input=move |ev| {
                        set_password.set(event_target_value(&ev));
                    }
                    prop:value=password
                />
            </div>
            <button
                type="submit"
                class="w-full bg-blue-600 text-white py-2 px-4 rounded-md text-sm font-medium hover:bg-blue-700"
            >
                "Sign In"
            </button>
        </form>
    }
}
