use leptos::*;
use crate::backend::data::ResProperty;
use crate::backend::property::DeleteProperty;
use crate::components::data_form::QuestionDialog;
use crate::components::modal_box::DialogOpener;
use crate::locales::trl;

#[component]
pub fn property_delete(property: ReadSignal<ResProperty>, opener: DialogOpener) -> impl IntoView {
    let del_property = create_server_action::<DeleteProperty>();

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