use leptos::*;
use crate::backend::data::User;
use crate::backend::user::DeleteUser;
use crate::components::data_form::QuestionDialog;
use crate::components::modal_box::DialogOpener;
use crate::locales::trl;

#[component]
pub fn user_delete(user: ReadSignal<User>, opener: DialogOpener) -> impl IntoView {
    let del_user = create_server_action::<DeleteUser>();

    view! {
        <QuestionDialog opener=opener action=del_user title="Delete user">
            <input type="hidden" prop:value={move || user.get().id()} name="id"/>
            <div>{trl("Are you sure you want to delete user ")}{move || user.get().full_name}"?"</div>
        </QuestionDialog>
    }
}