...

/

Create a List Page

Create a List Page

Learn to create a page to list products.

We'll cover the following...

Initial setup

We need a new page to list our products saved in the database. For that, we first need some structs to handle the list.

Press + to interact
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Product {
pub id: i32,
pub name: String,
pub cost: f64,
pub active: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProductVariant {
pub id: i32,
pub variant_id: i32,
pub product_id: i32,
pub value: Option<String>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Variant {
pub id: i32,
pub name: String,
}
type ProductList = Vec<(Product, Vec<(ProductVariant, Variant)>)>;

We ...