diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-08-30 15:15:31 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-08-30 15:15:31 +0530 |
commit | 0d7d20829623b14c8ea5284bc24e63f7c31d61b7 (patch) | |
tree | d918be383306e88e659162f5bd5fc8249de885b6 /src | |
parent | a1b3b7fb92fae98e9f6df7b9d4e3e3b4ff6b1a44 (diff) |
renamed client to customer
Diffstat (limited to 'src')
-rw-r--r-- | src/app/manage/customer/list/address.rs (renamed from src/app/manage/client/list/address.rs) | 6 | ||||
-rw-r--r-- | src/app/manage/customer/list/list_item.rs (renamed from src/app/manage/client/list/list_item.rs) | 10 | ||||
-rw-r--r-- | src/app/manage/customer/list/mod.rs (renamed from src/app/manage/client/list/mod.rs) | 20 | ||||
-rw-r--r-- | src/app/manage/customer/mod.rs (renamed from src/app/manage/client/mod.rs) | 24 | ||||
-rw-r--r-- | src/app/manage/mod.rs | 8 | ||||
-rw-r--r-- | src/app/mod.rs | 6 | ||||
-rw-r--r-- | src/components/navbar/nav.rs | 20 | ||||
-rw-r--r-- | src/models/customer.rs (renamed from src/models/client.rs) | 8 | ||||
-rw-r--r-- | src/models/mod.rs | 2 |
9 files changed, 59 insertions, 45 deletions
diff --git a/src/app/manage/client/list/address.rs b/src/app/manage/customer/list/address.rs index 233de92..8498530 100644 --- a/src/app/manage/client/list/address.rs +++ b/src/app/manage/customer/list/address.rs @@ -17,11 +17,11 @@ use yew::prelude::*; -use crate::models::client; +use crate::models::customer; #[derive(Properties, PartialEq)] pub struct Props { - pub address: client::Address, + pub address: customer::Address, pub title: String, } @@ -29,7 +29,7 @@ pub struct Props { pub fn address(props: &Props) -> Html { html! { - <div class={"client-address"}> + <div class={"customer-address"}> <span class={"title"}>{props.title.clone()}</span> <span>{props.address.address_text.clone()}</span> </div> diff --git a/src/app/manage/client/list/list_item.rs b/src/app/manage/customer/list/list_item.rs index 2e6fed0..26ac51d 100644 --- a/src/app/manage/client/list/list_item.rs +++ b/src/app/manage/customer/list/list_item.rs @@ -17,21 +17,21 @@ use yew::prelude::*; -use crate::models::client; +use crate::models::customer; #[derive(Properties, PartialEq)] pub struct Props { - pub client: client::Client, + pub customer: customer::Customer, pub s_no: usize, } #[function_component(ListItem)] pub fn list_item(props: &Props) -> Html { html! { - <div class={"clients-list-item"}> + <div class={"customers-list-item"}> <span>{props.s_no}</span> - <span>{props.client.name.clone()}</span> - <span>{props.client.gstin.clone()}</span> + <span>{props.customer.name.clone()}</span> + <span>{props.customer.gstin.clone()}</span> <span class={"options"}></span> </div> } diff --git a/src/app/manage/client/list/mod.rs b/src/app/manage/customer/list/mod.rs index 1c00f0a..00beb63 100644 --- a/src/app/manage/client/list/mod.rs +++ b/src/app/manage/customer/list/mod.rs @@ -20,30 +20,30 @@ mod address; use yew::prelude::*; -use crate::models::client; +use crate::models::customer; #[derive(Properties, PartialEq)] pub struct Props { - pub clients: Vec<client::Client>, + pub customers: Vec<customer::Customer>, } -#[function_component(ClientsList)] -pub fn clients_list(props: &Props) -> Html { - let list_items: Html = props.clients +#[function_component(CustomersList)] +pub fn customers_list(props: &Props) -> Html { + let list_items: Html = props.customers .iter() .enumerate() - .map(|(id, c)| html!(<list_item::ListItem key={c.id} s_no={id + 1} client={c.clone()} />)) + .map(|(id, c)| html!(<list_item::ListItem key={c.id} s_no={id + 1} customer={c.clone()} />)) .collect(); html! { - <div class={"clients-list-wrapper"}> - <div class={"clients-list-header"}> + <div class={"customers-list-wrapper"}> + <div class={"customers-list-header"}> <span>{"S. No"}</span> - <span>{"Client Name"}</span> + <span>{"Customer Name"}</span> <span>{"GSTIN"}</span> <span class={"options"}></span> </div> - <div class={"clients-list"}> + <div class={"customers-list"}> {list_items} </div> </div> diff --git a/src/app/manage/client/mod.rs b/src/app/manage/customer/mod.rs index e81f9a5..8f5f6fb 100644 --- a/src/app/manage/client/mod.rs +++ b/src/app/manage/customer/mod.rs @@ -19,13 +19,13 @@ mod list; use yew::prelude::*; -use crate::models::client; +use crate::models::customer; -#[function_component(ManageClientPage)] -pub fn manage_client_page() -> Html { - let mut clients = Vec::new(); +#[function_component(ManageCustomerPage)] +pub fn manage_customer() -> Html { + let mut customers = Vec::new(); - let mut c1: client::Client = client::Client::new(); + let mut c1: customer::Customer = customer::Customer::new(); c1.id = 1; c1.name = "MikunoNaka".to_string(); c1.gstin = "AKSK821KASJ123LJF".to_string(); @@ -38,16 +38,16 @@ pub fn manage_client_page() -> Html { c1.billing_address.state = "State".to_string(); c1.billing_address.postal_code = "121212".to_string(); c1.billing_address.country = "India".to_string(); - let mut c1s1 = client::Address::new(); + let mut c1s1 = customer::Address::new(); c1s1.address_text = "Shipping Address".to_string(); c1s1.city = "City".to_string(); c1s1.state = "State".to_string(); c1s1.postal_code = "121212".to_string(); c1s1.country = "India".to_string(); c1.add_shipping_address(c1s1); - clients.push(c1); + customers.push(c1); - let mut c2: client::Client = client::Client::new(); + let mut c2: customer::Customer = customer::Customer::new(); c2.id = 1; c2.name = "Google Inc.".to_string(); c2.gstin = "AKSK821KA12SJ123LJF".to_string(); @@ -60,7 +60,7 @@ pub fn manage_client_page() -> Html { c2.billing_address.state = "State".to_string(); c2.billing_address.postal_code = "121212".to_string(); c2.billing_address.country = "India".to_string(); - let mut c2s1 = client::Address::new(); + let mut c2s1 = customer::Address::new(); c2s1.address_text = "Address".to_string(); c2s1.city = "City".to_string(); c2s1.state = "State".to_string(); @@ -69,13 +69,13 @@ pub fn manage_client_page() -> Html { c2.add_shipping_address(c2s1); for _ in 0..1000 { - clients.push(c2.clone()); + customers.push(c2.clone()); } html! { - <div id={"manage-client-page"}> + <div id={"manage-customer-page"}> <p>{"To Add: Searching, Viewing, Editing, Deletion, Batch Deletion"}</p> - <list::ClientsList clients={clients}/> + <list::CustomersList customers={customers}/> </div> } } diff --git a/src/app/manage/mod.rs b/src/app/manage/mod.rs index ccaddc6..354d9d3 100644 --- a/src/app/manage/mod.rs +++ b/src/app/manage/mod.rs @@ -15,7 +15,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -pub mod client; +pub mod customer; use yew::prelude::*; use yew_icons::IconId; @@ -28,8 +28,8 @@ pub fn manage_menu_page() -> Html { let page_menu_items = Vec::from([ menu_items::Item { icon: IconId::FontAwesomeSolidUser, - label: String::from("Edit Clients"), - to: Route::ManageClients, + label: String::from("Edit Customers"), + to: Route::ManageCustomers, }, menu_items::Item { icon: IconId::FontAwesomeSolidIndustry, @@ -58,7 +58,7 @@ pub fn manage_menu_page() -> Html { <NavigationMenu> <menu_header::MenuHeader> <h1>{ "Manage OpenBills Data" }</h1> - <p>{ "Here you can add/modify/delete OpenBills data (clients, invoices, etc)" }</p> + <p>{ "Here you can add/modify/delete OpenBills data (customers, invoices, etc)" }</p> </menu_header::MenuHeader> <menu_items::MenuItems items={page_menu_items}/> diff --git a/src/app/mod.rs b/src/app/mod.rs index 68c4d0c..ac4b57f 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -30,8 +30,8 @@ pub enum Route { #[at("/manage")] ManageMenu, - #[at("/manage/clients")] - ManageClients, + #[at("/manage/customers")] + ManageCustomers, #[at("/manage/brands")] ManageBrands, #[at("/manage/items")] @@ -61,7 +61,7 @@ pub fn switch(routes: Route) -> Html { Route::Home => html! {<home::HomePage />}, Route::ManageMenu => html! {<manage::ManageMenuPage />}, - Route::ManageClients => html! {<manage::client::ManageClientPage />}, + Route::ManageCustomers => html! {<manage::customer::ManageCustomerPage />}, Route::ManageBrands => html! {<h1>{ "Edit Brands (To Be Added)" }</h1>}, Route::ManageItems => html! {<h1>{ "Edit Items (To Be Added)" }</h1>}, Route::ManageInvoices => html! {<h1>{ "Edit Invoices (To Be Added)" }</h1>}, diff --git a/src/components/navbar/nav.rs b/src/components/navbar/nav.rs index dd215a0..5249b60 100644 --- a/src/components/navbar/nav.rs +++ b/src/components/navbar/nav.rs @@ -17,6 +17,7 @@ use yew::prelude::*; use yew_router::prelude::*; +use gloo::utils::document; use crate::app::Route; use crate::components::navbar::nav_link::NavLink; @@ -58,8 +59,8 @@ pub fn nav() -> Html { to: Route::Home, }, Link { - label: String::from("Clients"), - to: Route::ManageClients, + label: String::from("Customers"), + to: Route::ManageCustomers, }, Link { label: String::from("Brands"), @@ -76,7 +77,7 @@ pub fn nav() -> Html { ]); let links_html: Html = match current_route { - Route::ManageClients + Route::ManageCustomers | Route::ManageBrands | Route::ManageItems | Route::ManageInvoices => manage_links, @@ -86,6 +87,19 @@ pub fn nav() -> Html { .map(|link| html!(<NavLink label={link.label.clone()} to={link.to.clone()} />)) .collect(); + // set document title + document().set_title(match current_route { + Route::Home => "", + + Route::ManageMenu => "Manage OpenBills Data", + Route::ManageCustomers => "Manage OpenBills Customers", + Route::ManageBrands => "Manage OpenBills Brands", + Route::ManageItems => "Manage OpenBills Items", + Route::ManageInvoices => "Manage OpenBills Invoices", + + _ => "Hello World", + }); + html! { <nav> {links_html} diff --git a/src/models/client.rs b/src/models/customer.rs index a76af70..65bd700 100644 --- a/src/models/client.rs +++ b/src/models/customer.rs @@ -56,7 +56,7 @@ impl Contact { } #[derive(Clone, PartialEq)] -pub struct Client { +pub struct Customer { pub id: u64, pub name: String, pub contact: Contact, @@ -65,9 +65,9 @@ pub struct Client { pub shipping_addresses: Vec<Address>, } -impl Client { - pub fn new() -> Client { - Client { +impl Customer { + pub fn new() -> Customer { + Customer { id: 0, name: String::new(), contact: Contact::new(), diff --git a/src/models/mod.rs b/src/models/mod.rs index 514c03d..74c6b60 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -15,4 +15,4 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -pub mod client; +pub mod customer; |