This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use serde::de::DeserializeOwned; | |
pub async fn fetch_single_api_response<T: DeserializeOwned>(endpoint: &str) -> reqwest::Result<T> { | |
let result = reqwest::get(endpoint).await?.json::<T>().await?; | |
return Ok(result); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
#[function_component(Home)] | |
pub fn home_function_component() -> Html { | |
... | |
let collections = collections.iter().map(|collection| html! { | |
<div class="col text-center"> | |
<Link<Route> to={Route::Collection {token_address: collection.address.clone()} } classes="img-fluid"> | |
<img src={collection.collection_image_url.clone()} class="img-fluid" width="250" height="250" alt={collection.name.clone()}/> | |
</Link<Route>> | |
<p class="text-white">{collection.name.clone()}</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use route::{switch, Route}; | |
use yew::prelude::*; | |
use yew_router::prelude::*; | |
#[function_component(App)] | |
fn app() -> Html { | |
html! { | |
<BrowserRouter> | |
<Switch<Route> render={switch} /> | |
</BrowserRouter> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::view::home::Home; | |
use yew::prelude::*; | |
use yew_router::prelude::*; | |
#[derive(Clone, Routable, PartialEq)] | |
pub enum Route { | |
#[at("/:token_address")] | |
Collection { token_address: String }, | |
#[at("/")] | |
Home, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::utils::api_utils; | |
use log::error; | |
use model::model::collection::CollectionData; | |
use yew::prelude::*; | |
#[function_component(Home)] | |
pub fn home_function_component() -> Html { | |
let collections = use_state(|| vec![]); | |
{ | |
let collections = collections.clone(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::view::home::Home; | |
#[function_component(App)] | |
fn app() -> Html { | |
html! { | |
<Home /> | |
} | |
} | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use log::info; | |
use yew::prelude::*; | |
#[function_component(App)] | |
fn app() -> Html { | |
html! { | |
<p class="text-white">{ "Rendered" }</p> | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Site</title> | |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous"> | |
<link href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" rel="stylesheet" crossorigin="anonymous"/> | |
<link data-trunk rel="css" href="style.css"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "ui" | |
version = "0.1.0" | |
edition = "2021" | |
[[bin]] | |
name = "ui" | |
path = "src/main.rs" | |
[dependencies] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[tokio::main] | |
pub async fn read() { | |
read_with_cursor_as::<Mint>(MINTS_URL, &MintSaver).await; | |
read_with_cursor_as::<Asset>(ASSETS_URL, &AssetSaver).await; | |
} | |
async fn read_with_cursor_as<T: DeserializeOwned + PaginatedApi>( | |
url: &str, | |
persistable: &dyn Persistable<T>, | |
) { |