| [a4ca79c] | 1 | mod db;
|
|---|
| 2 | mod commands;
|
|---|
| 3 | mod models;
|
|---|
| 4 | use db::create_pool;
|
|---|
| 5 | use sqlx::PgPool;
|
|---|
| 6 | use tauri::Manager;
|
|---|
| 7 | use commands::auth::ActiveSessions;
|
|---|
| 8 | use std::collections::HashMap;
|
|---|
| 9 | use std::sync::Mutex;
|
|---|
| 10 | use commands::auth::login;
|
|---|
| 11 |
|
|---|
| 12 | use commands::product::{
|
|---|
| 13 | get_products,
|
|---|
| 14 | get_products_by_category
|
|---|
| 15 | };
|
|---|
| 16 |
|
|---|
| 17 | use commands::category::{
|
|---|
| 18 | get_categories,
|
|---|
| 19 | create_category,
|
|---|
| 20 | update_category,
|
|---|
| 21 | delete_category
|
|---|
| 22 | };
|
|---|
| 23 |
|
|---|
| 24 | use commands::table::{
|
|---|
| 25 | get_tables,
|
|---|
| 26 | reserve_table,
|
|---|
| 27 | cancel_reservation
|
|---|
| 28 | };
|
|---|
| 29 |
|
|---|
| 30 | use commands::order::{
|
|---|
| 31 | create_order,
|
|---|
| 32 | get_order_total,
|
|---|
| 33 | get_active_order,
|
|---|
| 34 | pay_order,
|
|---|
| 35 | update_order_quantity,
|
|---|
| 36 | delete_order_item
|
|---|
| 37 | };
|
|---|
| 38 |
|
|---|
| 39 | use commands::order_item::{
|
|---|
| 40 | add_order_item,
|
|---|
| 41 | get_order_items
|
|---|
| 42 | };
|
|---|
| 43 |
|
|---|
| 44 | use commands::payment::create_payment;
|
|---|
| 45 |
|
|---|
| 46 | use commands::invoice::{
|
|---|
| 47 | create_invoice,
|
|---|
| 48 | get_invoice
|
|---|
| 49 | };
|
|---|
| 50 |
|
|---|
| 51 | use commands::inventory::{
|
|---|
| 52 | get_inventory,
|
|---|
| 53 | get_low_stock,
|
|---|
| 54 | restock_product
|
|---|
| 55 | };
|
|---|
| 56 |
|
|---|
| 57 | use commands::report::{
|
|---|
| 58 | today_sales,
|
|---|
| 59 | today_orders,
|
|---|
| 60 | best_product,
|
|---|
| 61 | z_report,
|
|---|
| 62 | employee_performance,
|
|---|
| 63 | search_orders
|
|---|
| 64 | };
|
|---|
| 65 |
|
|---|
| 66 | use commands::admin::{
|
|---|
| 67 | add_product,
|
|---|
| 68 | update_product,
|
|---|
| 69 | delete_product,
|
|---|
| 70 | update_product_price
|
|---|
| 71 | };
|
|---|
| 72 |
|
|---|
| 73 | use commands::employees::{
|
|---|
| 74 | get_employees,
|
|---|
| 75 | get_roles,
|
|---|
| 76 | add_employee,
|
|---|
| 77 | update_employee_role,
|
|---|
| 78 | reset_employee_pin,
|
|---|
| 79 | toggle_employee,
|
|---|
| 80 | delete_employee
|
|---|
| 81 | };
|
|---|
| 82 | use commands::window::{
|
|---|
| 83 | minimize_window,
|
|---|
| 84 | maximize_window,
|
|---|
| 85 | unmaximize_window,
|
|---|
| 86 | is_maximized,
|
|---|
| 87 | close_window
|
|---|
| 88 | };
|
|---|
| 89 | use commands::kitchen::{get_kitchen_orders, mark_kitchen_order_ready};
|
|---|
| 90 | use commands::settings::{get_settings, update_settings};
|
|---|
| 91 |
|
|---|
| 92 | #[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|---|
| 93 | pub fn run() {
|
|---|
| 94 | tauri::Builder::default()
|
|---|
| 95 | .invoke_handler(
|
|---|
| 96 | tauri::generate_handler![
|
|---|
| 97 | login,
|
|---|
| 98 |
|
|---|
| 99 | get_products,
|
|---|
| 100 | get_products_by_category,
|
|---|
| 101 | get_categories,
|
|---|
| 102 | create_category,
|
|---|
| 103 | update_category,
|
|---|
| 104 | delete_category,
|
|---|
| 105 | get_settings,
|
|---|
| 106 | update_settings,
|
|---|
| 107 | get_tables,
|
|---|
| 108 | reserve_table,
|
|---|
| 109 | cancel_reservation,
|
|---|
| 110 | delete_employee,
|
|---|
| 111 | create_order,
|
|---|
| 112 | get_order_total,
|
|---|
| 113 | get_active_order,
|
|---|
| 114 | pay_order,
|
|---|
| 115 |
|
|---|
| 116 | add_order_item,
|
|---|
| 117 | get_order_items,
|
|---|
| 118 | update_order_quantity,
|
|---|
| 119 | delete_order_item,
|
|---|
| 120 |
|
|---|
| 121 | create_payment,
|
|---|
| 122 |
|
|---|
| 123 | create_invoice,
|
|---|
| 124 | get_invoice,
|
|---|
| 125 |
|
|---|
| 126 | get_inventory,
|
|---|
| 127 | get_low_stock,
|
|---|
| 128 | restock_product,
|
|---|
| 129 | get_kitchen_orders,
|
|---|
| 130 | mark_kitchen_order_ready,
|
|---|
| 131 | today_sales,
|
|---|
| 132 | today_orders,
|
|---|
| 133 | best_product,
|
|---|
| 134 | z_report,
|
|---|
| 135 | employee_performance,
|
|---|
| 136 | search_orders,
|
|---|
| 137 |
|
|---|
| 138 | add_product,
|
|---|
| 139 | update_product,
|
|---|
| 140 | delete_product,
|
|---|
| 141 | update_product_price,
|
|---|
| 142 |
|
|---|
| 143 | get_employees,
|
|---|
| 144 | get_roles,
|
|---|
| 145 | add_employee,
|
|---|
| 146 | update_employee_role,
|
|---|
| 147 | reset_employee_pin,
|
|---|
| 148 | toggle_employee,
|
|---|
| 149 | minimize_window,
|
|---|
| 150 | maximize_window,
|
|---|
| 151 | unmaximize_window,
|
|---|
| 152 | is_maximized,
|
|---|
| 153 | close_window,
|
|---|
| 154 |
|
|---|
| 155 | ]
|
|---|
| 156 | )
|
|---|
| 157 | .setup(|app: &mut tauri::App| {
|
|---|
| 158 | let pool: PgPool = tauri::async_runtime::block_on(async {
|
|---|
| 159 | create_pool().await
|
|---|
| 160 | });
|
|---|
| 161 | app.manage(ActiveSessions(Mutex::new(HashMap::new())));
|
|---|
| 162 | app.manage(pool);
|
|---|
| 163 |
|
|---|
| 164 | println!("Database connected!");
|
|---|
| 165 |
|
|---|
| 166 | if std::env::args().any(|a| a == "--kitchen-window") {
|
|---|
| 167 | tauri::WebviewWindowBuilder::new(
|
|---|
| 168 | app,
|
|---|
| 169 | "kitchen",
|
|---|
| 170 | tauri::WebviewUrl::App("index.html?mode=kitchen".into()),
|
|---|
| 171 | )
|
|---|
| 172 | .title("Кујна")
|
|---|
| 173 | .fullscreen(true)
|
|---|
| 174 | .decorations(false)
|
|---|
| 175 | .build()?;
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | Ok(())
|
|---|
| 179 | })
|
|---|
| 180 | .run(tauri::generate_context!())
|
|---|
| 181 | .expect("error while running tauri");
|
|---|
| 182 | } |
|---|