::into(&acc));
+ let id = format!("acc-{}", txt);
+ view! {
+
+
+
+
+ }
+}
+
+#[component]
+fn InvForm() -> impl IntoView {
+ view! {
+
+ }
+}
+
fn main() {
console_error_panic_hook::set_once();
leptos::mount::mount_to_body(|| view! {
+
+
+
});
}
diff --git a/src/commands.rs b/src/commands.rs
index d6e13ed..ee27cf3 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -1,12 +1,13 @@
use tauri_sys::Error;
use tauri_sys::core::invoke;
+use crate::types::*;
#[derive(serde::Serialize)]
-pub struct Swap<'a> {
- store: &'a str,
+pub struct Swap {
+ store: Store,
acc: i64,
}
-pub async fn swap(store: &str, acc: i64) -> Result<(), Error> {
+pub async fn swap(store: Store, acc: i64) -> Result<(), Error> {
let args = Swap { store, acc };
invoke("swap", &args).await
}
diff --git a/src/server/mod.rs b/src/server/mod.rs
index 1595f83..56072e3 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -1,8 +1,7 @@
use chrono::offset::Utc;
-use rusqlite::{types::ToSqlOutput, ToSql};
use std::collections::HashMap;
use tokio::sync::Mutex;
-use tauri::{Manager, State};
+use tauri::State;
use crate::types::*;
@@ -61,12 +60,11 @@ pub async fn inventory(
#[tauri::command]
pub async fn swap(
- store: &str,
+ store: Store,
acc: i64,
state: State<'_, Mutex>,
) -> Result<(), ()> {
let state = state.lock().await;
- let store: Store = store.try_into()?;
state.db.execute(
"INSERT INTO swap VALUES (?1, ?2, ?3, ?4, ?5)",
(
diff --git a/src/types.rs b/src/types.rs
index eb4ac68..d774769 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -31,6 +31,19 @@ pub struct VoucherInventory {
pub count: i64,
}
+impl Into for &Store {
+ fn into(self) -> String {
+ String::from(match *self {
+ Store::Aldi => "aldi",
+ Store::Edeka => "edeka",
+ Store::Dm => "dm",
+ Store::Lidl => "lidl",
+ Store::Rewe => "rewe",
+ Store::Tegut => "tegut",
+ })
+ }
+}
+
impl TryFrom<&str> for Store {
type Error = ();
@@ -59,6 +72,15 @@ impl TryFrom<&str> for Account {
}
}
+impl Into for &Account {
+ fn into(self) -> String {
+ String::from(match *self {
+ Account::Sumpf => "sumpf",
+ Account::Heinersyndikat => "hs",
+ })
+ }
+}
+
#[cfg(feature = "server")]
impl ToSql for Store {
fn to_sql(&self) -> rusqlite::Result> {
diff --git a/styles.scss b/styles.scss
index d239b06..645a0ee 100644
--- a/styles.scss
+++ b/styles.scss
@@ -106,7 +106,8 @@ input[type=number] {
}
input[type=radio] {
- height: 60%;
+ width: 100%;
+ height: 7mm;
}
button:hover {