-- orders/view.wo — the confirmation page and the orders table.
-- Markup-first, one HTML line per statement; see product_list/view.wo
-- for the convention and the story-37 endgame.
use html
pub class OrderOk {
name: Text
qty: Int
total: Float
fn render() -> Text {
let h = "
";
h = h .. "
Order placed
";
h = h .. "
${self.qty} × ${esc(self.name)} — total € ${self.total}
";
h = h .. "
See all orders · Keep shopping
";
h = h .. "
";
return h;
}
}
pub class OrderRow {
name: Text
qty: Int
total: Float
status: Text
fn render() -> Text {
let h = "";
h = h .. "| ${esc(self.name)} | ";
h = h .. "${self.qty} | ";
h = h .. "€ ${self.total} | ";
h = h .. "${esc(self.status)} | ";
h = h .. "
";
return h;
}
}
pub class OrdersPage {
rows: Text
fn render() -> Text {
let h = "Orders
";
if self.rows == "" {
h = h .. "No orders yet — go buy something.
";
return h;
}
h = h .. "";
h = h .. "| Product | Qty | Total | Status |
";
h = h .. "${self.rows}";
h = h .. "
";
return h;
}
}