mod pages;

use yew::prelude::*;
use yew_router::prelude::*;

use pages::cdr::{Cdr};
use pages::did::{DidListComponent};

#[derive(Clone, Routable, PartialEq)]
enum Route {
    #[at("/")]
    Home,
    #[at("/did")]
    Did,
    #[at("/cdr")]
    Cdr,
}

fn switch(routes: Route) -> Html {
    match routes {
        Route::Home => html! {
            <DidListComponent />
         },
        Route::Did => html! {
            <DidListComponent />
        },
        Route::Cdr => html! {
            <Cdr />
        },
    }
}

#[component]
fn App() -> Html {
html! {
    <BrowserRouter>
        <div class="w-full lg:w-3/4 lg:mx-auto p-4 bg-gray-100">
        <div class="navbar bg-base-100 shadow-sm">
            <div class="navbar-start">
            </div>
            <div class="navbar-center lg:flex">
                <ul class="menu menu-horizontal px-1">
                    <li>
                        <Link<Route> to={Route::Home}>{"DID"}</Link<Route>>
                    </li>
                    <li><Link<Route> to={Route::Cdr}>{"CDR"}</Link<Route>></li>
                </ul>
            </div>
            <div class="navbar-end">
            </div>
        </div>
        <Switch<Route> render={switch} />
        </div>
    </BrowserRouter>        

    }
}

fn main() {
    yew::Renderer::<App>::new().render();
}
