use std::any::Any;

use axum::response::{IntoResponse, Response};
use askama::Template;
use askama_web::WebTemplate;

#[derive(Template, WebTemplate)]
#[template(path = "404.html")]
pub struct NotFoundTemplate;

#[derive(Template, WebTemplate)]
#[template(path = "500.html")]
pub struct InternalErrorTemplate {
  pub email: &'static str,
}

pub async fn not_found() -> NotFoundTemplate {
  NotFoundTemplate
}

pub async fn internal_error_page() -> InternalErrorTemplate {
  InternalErrorTemplate {
    email: crate::constants::CONTACT_EMAIL,
  }
}

pub fn internal_error(_panic: Box<dyn Any + Send>) -> Response {
  InternalErrorTemplate {
    email: crate::constants::CONTACT_EMAIL,
  }
  .into_response()
}
