2023-03-20 20:37:16 +00:00
|
|
|
use jl_types::domain::{project::Project, media::Media};
|
2023-03-15 23:40:56 +00:00
|
|
|
use yew::prelude::*;
|
2023-03-16 17:16:22 +00:00
|
|
|
use yew_router::prelude::use_navigator;
|
|
|
|
|
|
|
|
use crate::routes::main_router::Route;
|
|
|
|
|
2023-03-15 23:40:56 +00:00
|
|
|
|
|
|
|
#[function_component(ProjectCard)]
|
2023-03-20 20:37:16 +00:00
|
|
|
pub fn project_card(props: &ProjectCardProps) -> Html {
|
2023-03-16 17:16:22 +00:00
|
|
|
let navigator = use_navigator().unwrap();
|
2023-03-20 20:37:16 +00:00
|
|
|
let project_id = props.project.id.clone();
|
2023-03-16 17:16:22 +00:00
|
|
|
let project_view_cb = Callback::from(move |_|{
|
2023-03-20 20:37:16 +00:00
|
|
|
navigator.push(&Route::Details { project_id });
|
2023-03-16 17:16:22 +00:00
|
|
|
});
|
2023-03-20 20:37:16 +00:00
|
|
|
let cover_image_url;
|
|
|
|
if let Some(first_media) = props.project.media.media_list.get(0) {
|
|
|
|
cover_image_url = match first_media {
|
|
|
|
Media::Photo(url) => url.clone(),
|
|
|
|
Media::Video(_) => String::new(),
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cover_image_url = String::new()
|
|
|
|
}
|
2023-03-15 23:40:56 +00:00
|
|
|
html!{
|
2023-03-16 17:16:22 +00:00
|
|
|
<div class={"project-search-result-card"} onclick={project_view_cb}>
|
2023-03-20 20:37:16 +00:00
|
|
|
<img src={cover_image_url} alt={"project image"} class={"project-search-result-card-picture"}/>
|
2023-03-16 17:16:22 +00:00
|
|
|
|
|
|
|
<div class={"project-search-result-card-title"}>
|
|
|
|
{"Suites by refa Piantini"}
|
|
|
|
</div>
|
|
|
|
<div class={"project-search-result-card-location"}>
|
|
|
|
{"Apartamento en Piantini, Santo Domingo"}
|
|
|
|
</div>
|
|
|
|
<div class={"project-search-result-card-price"}>
|
|
|
|
{"Desde RD$1,000,000.00"}
|
|
|
|
</div>
|
|
|
|
<div class={"project-search-result-card-details-container"}>
|
|
|
|
<div class={"project-search-result-card-details-item"}>
|
|
|
|
<i class="fa-solid fa-ruler-vertical"></i>
|
|
|
|
<div>{"80-300m²"}</div>
|
|
|
|
</div>
|
|
|
|
<div class={"project-search-result-card-details-item"}>
|
|
|
|
<i class="fa-solid fa-hand-holding-hand"></i>
|
|
|
|
<div>{"Nuevo"}</div>
|
|
|
|
</div>
|
|
|
|
<div class={"project-search-result-card-details-item"}>
|
|
|
|
<i class="fa-regular fa-calendar-check"></i>
|
|
|
|
<div>{"8/2025"}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-03-15 23:40:56 +00:00
|
|
|
}
|
2023-03-20 20:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Properties, PartialEq, Eq, PartialOrd, Ord)]
|
|
|
|
pub struct ProjectCardProps {
|
|
|
|
pub project: Project
|
2023-03-15 23:40:56 +00:00
|
|
|
}
|