From ca24591d9d0a4edaa3e3a30d42df3704811d16e0 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Wed, 28 May 2025 15:43:50 +0200 Subject: [PATCH] work --- .gitignore | 2 + Cargo.lock | 10 +++++ Cargo.toml | 1 + Containerfile | 6 +-- assets/tailwind.css | 2 - src/api.rs | 81 ++++-------------------------------- src/main.rs | 26 ++++++++++-- src/page/item_detail.rs | 8 ++-- src/page/items.rs | 7 +++- src/page/locations.rs | 92 ++++++++++++++++++++++++++++++++++++++--- src/page/supply.rs | 17 +++++--- src/page/transaction.rs | 30 +++++++++++--- 12 files changed, 177 insertions(+), 105 deletions(-) delete mode 100644 assets/tailwind.css diff --git a/.gitignore b/.gitignore index 80aab8e..bb71fb0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ # These are backup files generated by rustfmt **/*.rs.bk + +/assets/tailwind.css diff --git a/Cargo.lock b/Cargo.lock index dc09c7b..5d990f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,6 +378,7 @@ dependencies = [ "bardecoder", "base64", "dioxus", + "dioxus-material-icons", "dioxus-sdk", "gloo-timers", "image", @@ -1194,6 +1195,15 @@ dependencies = [ "tracing-wasm", ] +[[package]] +name = "dioxus-material-icons" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf38d89d3100bb3dbe38c7c08eef9d87fb81fcec49a4e33ead63fdcf4e67f01" +dependencies = [ + "dioxus", +] + [[package]] name = "dioxus-mobile" version = "0.6.2" diff --git a/Cargo.toml b/Cargo.toml index b04890a..f2d4b5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ serde_json = "1.0.140" dioxus-sdk = { version = "0.6.0", features = ["storage"] } serde = { version = "1.0.219", features = ["derive"] } reqwest = { version = "0.12.15", features = ["json"] } +dioxus-material-icons = "3.0.0" [features] default = ["web"] diff --git a/Containerfile b/Containerfile index 45f595f..50e780d 100644 --- a/Containerfile +++ b/Containerfile @@ -2,8 +2,6 @@ FROM git.hydrar.de/navos/navos:latest as builder RUN pacman-key --init && pacman-key --populate archlinux && pacman-key --populate navos && pacman -Sy --noconfirm -RUN pacman -S --noconfirm tailwindcss-bin rustup - RUN pacman -S --noconfirm --needed \ webkit2gtk-4.1 \ base-devel \ @@ -14,9 +12,9 @@ RUN pacman -S --noconfirm --needed \ appmenu-gtk-module \ libappindicator-gtk3 \ librsvg \ - xdotool + xdotool tailwindcss-bin rustup && pacman -Scc --noconfirm -RUN rustup default nightly +RUN rustup default nightly && rustup target add wasm32-unknown-unknown RUN cargo install dioxus-cli diff --git a/assets/tailwind.css b/assets/tailwind.css deleted file mode 100644 index c18798c..0000000 --- a/assets/tailwind.css +++ /dev/null @@ -1,2 +0,0 @@ -/*! tailwindcss v4.1.7 | MIT License | https://tailwindcss.com */ -@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-green-500:oklch(72.3% .219 149.579);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-500:oklch(55.1% .027 264.364);--color-stone-900:oklch(21.6% .006 56.043);--color-white:#fff;--spacing:.25rem;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--font-weight-bold:700;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.fixed{position:fixed}.static{position:static}.inset-0{inset:calc(var(--spacing)*0)}.right-4{right:calc(var(--spacing)*4)}.bottom-4{bottom:calc(var(--spacing)*4)}.z-40{z-index:40}.col-1{grid-column:1}.mt-auto{margin-top:auto}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-24{height:calc(var(--spacing)*24)}.h-screen{height:100vh}.w-24{width:calc(var(--spacing)*24)}.flex-1{flex:1}.cursor-pointer{cursor:pointer}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.gap-2{gap:calc(var(--spacing)*2)}.gap-4{gap:calc(var(--spacing)*4)}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-x-4>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing)*4)*var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-x-reverse)))}.overflow-auto{overflow:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.border{border-style:var(--tw-border-style);border-width:1px}.bg-blue-500{background-color:var(--color-blue-500)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-green-500{background-color:var(--color-green-500)}.p-2{padding:calc(var(--spacing)*2)}.p-4{padding:calc(var(--spacing)*4)}.p-6{padding:calc(var(--spacing)*6)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.py-1{padding-block:calc(var(--spacing)*1)}.py-2{padding-block:calc(var(--spacing)*2)}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.text-blue-600{color:var(--color-blue-600)}.text-gray-500{color:var(--color-gray-500)}.text-white{color:var(--color-white)}.underline{text-decoration-line:underline}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.grayscale{--tw-grayscale:grayscale(100%);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}@media (hover:hover){.hover\:bg-blue-600:hover{background-color:var(--color-blue-600)}.hover\:bg-gray-300:hover{background-color:var(--color-gray-300)}}}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false} \ No newline at end of file diff --git a/src/api.rs b/src/api.rs index 831e0a9..a394212 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,76 +1,3 @@ -/* -import 'dart:convert'; -import 'package:cdb_ui/pages/supply.dart'; -import 'package:http/http.dart' as http; -import 'package:shared_preferences/shared_preferences.dart'; - -// todo : api errors - -class API { - SharedPreferences? pref; - static final API _instance = API._internal(); - - // cache - List? items; - Map? locations; - Map? flowInfos; - - factory API() { - return _instance; - } - - API._internal(); - - Future init(Function refresh) async { - pref = await SharedPreferences.getInstance(); - instance = pref!.getString("instance") ?? ""; - refresh(); - } - - bool isInit() { - if (pref == null) { - return false; - } - - return pref!.containsKey("token") && pref!.containsKey("instance"); - } - - bool isPrefetched() { - return items != null && locations != null && flowInfos != null; - } - - void save(String instance, String token) { - pref!.setString("instance", instance); - pref!.setString("token", token); - this.instance = instance; - } - - String instance = ""; - - Future getRequest(String url) async { - var resp = await http.get(Uri.parse(url), headers: { - 'Access-Control-Allow-Origin': '*', - 'Content-Type': 'application/json; charset=UTF-8', - 'Token': pref!.getString("token")! - }); - - return utf8.decode(resp.bodyBytes); - } - - Future postRequest(String url, Map data) async { - var resp = await http.post(Uri.parse(url), - headers: { - 'Access-Control-Allow-Origin': '*', - 'Content-Type': 'application/json; charset=UTF-8', - 'Token': pref!.getString("token")! - }, - body: jsonEncode(data)); - - return utf8.decode(resp.bodyBytes); - } -} -*/ - use std::collections::HashMap; use dioxus::signals::Readable; @@ -84,6 +11,14 @@ use reqwest::Client; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; +pub fn get_item(item: &str) -> Option { + crate::API + .read() + .as_ref() + .unwrap() + .get_item(item.to_string()) +} + pub async fn api_get_auth(path: String) -> Result where T: DeserializeOwned, diff --git a/src/main.rs b/src/main.rs index bf85e09..fdefd02 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use api::{Item, Transaction}; use dioxus::prelude::*; +use dioxus_material_icons::{MaterialIcon, MaterialIconStylesheet}; use dioxus_sdk::storage::use_persistent; use qrscan::QRCodeScanPage; use setup::{Credentials, SetupPage}; @@ -69,6 +70,7 @@ fn App() -> Element { document::Link { rel: "icon", href: FAVICON } document::Link { rel: "stylesheet", href: MAIN_CSS } document::Link { rel: "stylesheet", href: TAILWIND_CSS } + MaterialIconStylesheet { } if creds.read().empty() { SetupPage { } @@ -144,19 +146,35 @@ fn Navbar() -> Element { id: "navbar", Link { to: Route::Home {}, - "Home" + div { + class: "flex flex-row gap-2 p-2", + MaterialIcon { name: "home", size: 24 }, + "Home" + } } Link { to: Route::ItemPage { }, - "Items" + div { + class: "flex flex-row gap-2 p-2", + MaterialIcon { name: "category", size: 24 }, + "Items" + } } Link { to: Route::FlowPage { }, - "Flows" + div { + class: "flex flex-row gap-2 p-2", + MaterialIcon { name: "assignment", size: 24 }, + "Flows" + } } Link { to: Route::LocationsPage { }, - "Locations" + div { + class: "flex flex-row gap-2 p-2", + MaterialIcon { name: "map", size: 24 }, + "Locations" + } } } diff --git a/src/page/item_detail.rs b/src/page/item_detail.rs index bad2780..b906106 100644 --- a/src/page/item_detail.rs +++ b/src/page/item_detail.rs @@ -16,7 +16,7 @@ pub fn ItemDetailPage(id: String) -> Element { class: "flex flex-col h-screen", header { - class: "p-4 bg-blue-500 text-white text-lg font-bold", + class: "p-4 text-white text-lg font-bold", {item.name.as_str()} } div { @@ -79,9 +79,9 @@ pub fn ItemDetailPage(id: String) -> Element { Route::SupplyPage { item: item.uuid.clone(), param: SupplyPageParam { - onlyVariants: None, - forcePrice: None, - forceOrigin: None + only_variants: None, + force_price: None, + force_origin: None } } ); diff --git a/src/page/items.rs b/src/page/items.rs index 94c4215..f898c63 100644 --- a/src/page/items.rs +++ b/src/page/items.rs @@ -19,8 +19,11 @@ pub fn ItemPage() -> Element { match &*items.read_unchecked() { Some(items) => { rsx! { - for item in items { - ItemTile { item: item.clone() } + div { + class: "flex flex-col", + for item in items { + ItemTile { item: item.clone() } + } } } }, diff --git a/src/page/locations.rs b/src/page/locations.rs index 4481119..66a7678 100644 --- a/src/page/locations.rs +++ b/src/page/locations.rs @@ -1,19 +1,99 @@ use dioxus::prelude::*; use std::collections::HashMap; -fn build_tree(root: &str, locs: &HashMap) -> Element { - rsx! {} -} - #[component] pub fn LocationsPage() -> Element { let api = crate::API.read(); let locations = use_signal(|| api.as_ref().unwrap().get_locations().clone()); - // TODO : find roots - // build them + let roots: Vec = get_root_locations(&*locations.read()); rsx! { h1 { "Locations" }, + + for l in &roots { + LocationTreeTile { location: l.clone(), locations } + } + } +} + +pub fn get_root_locations(locations: &HashMap) -> Vec { + let mut ret = Vec::new(); + + for (_, v) in locations { + if v.parent.is_none() { + ret.push(v.id.clone()); + } + } + + ret +} + +pub fn get_children_of_loc( + loc: String, + locations: &HashMap, +) -> Vec { + let mut ret = Vec::new(); + + for (_, v) in locations { + if let Some(parent) = &v.parent { + if *parent == loc { + ret.push(v.id.clone()); + } + } + } + + ret +} + +#[component] +pub fn LocationTreeTile( + location: String, + locations: Signal>, +) -> Element { + let mut open = use_signal(|| false); + + // TODO + let children = get_children_of_loc(location.clone(), &*locations.read()); + + rsx! { + p { {location} } + button { + onclick: move |_| { open.set(true); }, + "Expand" + } + + if *open.read() { + for loc in &children { + LocationTreeTile { location: loc.clone(), locations } + } + } + } +} + +#[component] +pub fn LocationPage(location: String) -> Element { + let mut recursive = use_signal(|| true); + + rsx! { + h1 { {location} } + + div { + id: "location-info", + p { "Info" } + } + + input { + r#type: "checkbox", + value: !*recursive.read(), + onclick: move |_| { + let val = *recursive.read(); + recursive.set(!val); + }, + "Show only entries matching this location" + } + + // Transaction List + } } diff --git a/src/page/supply.rs b/src/page/supply.rs index 082dc8b..da50910 100644 --- a/src/page/supply.rs +++ b/src/page/supply.rs @@ -41,7 +41,7 @@ pub fn SupplyPage(item: String, param: SupplyPageParam) -> Element { let origin = use_signal(|| String::new()); - let mut price = use_signal(|| 0.0); + let mut price = use_signal(|| param.force_price.unwrap_or(0.0)); let location = use_signal(|| String::new()); let mut note = use_signal(|| String::new()); @@ -72,7 +72,14 @@ pub fn SupplyPage(item: String, param: SupplyPageParam) -> Element { input { r#type: "number", value: "{price}", - oninput: move |e| price.set(e.value().parse().unwrap()) + disabled: param.force_price.is_some(), + oninput: move |e| { + if let Some(fprice) = param.force_price { + price.set(fprice); + } else { + price.set(e.value().parse().unwrap()) + } + } } }, // Location Dropdown @@ -107,9 +114,9 @@ pub fn SupplyPage(item: String, param: SupplyPageParam) -> Element { #[derive(Clone, PartialEq, Debug, Default, Deserialize, Serialize)] pub struct SupplyPageParam { - pub onlyVariants: Option>, - pub forcePrice: Option, - pub forceOrigin: Option, + pub only_variants: Option>, + pub force_price: Option, + pub force_origin: Option, } impl std::fmt::Display for SupplyPageParam { diff --git a/src/page/transaction.rs b/src/page/transaction.rs index 0ad02d5..f70e464 100644 --- a/src/page/transaction.rs +++ b/src/page/transaction.rs @@ -1,6 +1,7 @@ use dioxus::prelude::*; +use dioxus_material_icons::MaterialIcon; -use crate::Route; +use crate::{api::get_item, Route}; #[component] pub fn TransactionPage(id: String) -> Element { @@ -10,7 +11,6 @@ pub fn TransactionPage(id: String) -> Element { }); rsx! { - match transaction.value()() { Some(transaction) => rsx! { @@ -32,9 +32,9 @@ pub fn TransactionPage(id: String) -> Element { div { id: "col-1", - p { {crate::API.read().as_ref().unwrap().get_item(transaction.item.clone()).unwrap().name.as_str()} } - // TODO : variant name - // timestamp + p { {get_item(&transaction.item).unwrap().name.as_str()} } + p { {get_item(&transaction.item).unwrap().variants.get(&transaction.variant).as_ref().unwrap().name.clone()} } + p { {transaction.timestamp.to_string()} } } }, @@ -45,6 +45,9 @@ pub fn TransactionPage(id: String) -> Element { // price p { {transaction.price.to_string()} }, // origin + if let Some(origin) = &transaction.origin { + IconLabel { icon: "home".to_string(), label: "Origin".to_owned(), value: origin.clone() } + } // location // note @@ -58,3 +61,20 @@ pub fn TransactionPage(id: String) -> Element { } } + +#[component] +pub fn IconLabel(icon: String, label: String, value: String) -> Element { + rsx! { + div { class: "flex items-center space-x-3", + MaterialIcon { + name: icon, + size: 12, + }, + + div { class: "flex flex-col", + span { class: "text-sm font-medium text-gray-700", "{label}" } + span { class: "text-lg font-semibold text-gray-900", "{value}" } + } + } + } +}