Leptos updated to 0.5
This commit is contained in:
+4
-12
@@ -2,16 +2,12 @@ use crate::backend::data::Company;
|
||||
use leptos::*;
|
||||
|
||||
#[server(GetCompany, "/api", "Url", "get_company")]
|
||||
pub async fn get_company(cx: Scope) -> Result<Company, ServerFnError> {
|
||||
pub async fn get_company() -> Result<Company, ServerFnError> {
|
||||
use crate::backend::AppData;
|
||||
use actix_web::web::Data;
|
||||
use leptos_actix::extract;
|
||||
|
||||
let pool = extract(
|
||||
cx,
|
||||
|data: Data<AppData>| async move { data.db_pool().clone() },
|
||||
)
|
||||
.await?;
|
||||
let pool = extract(|data: Data<AppData>| async move { data.db_pool().clone() }).await?;
|
||||
|
||||
let cmp = sqlx::query_as::<_, Company>("SELECT * FROM company")
|
||||
.fetch_one(&pool)
|
||||
@@ -21,16 +17,12 @@ pub async fn get_company(cx: Scope) -> Result<Company, ServerFnError> {
|
||||
}
|
||||
|
||||
#[server(UpdateCompany, "/api", "Url", "update_company")]
|
||||
pub async fn update_company(cx: Scope, company: Company) -> Result<(), ServerFnError> {
|
||||
pub async fn update_company(company: Company) -> Result<(), ServerFnError> {
|
||||
use crate::backend::AppData;
|
||||
use actix_web::web::Data;
|
||||
use leptos_actix::extract;
|
||||
|
||||
let pool = extract(
|
||||
cx,
|
||||
|data: Data<AppData>| async move { data.db_pool().clone() },
|
||||
)
|
||||
.await?;
|
||||
let pool = extract(|data: Data<AppData>| async move { data.db_pool().clone() }).await?;
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE company SET name = $1, street = $2, house_number = $3, zip_code = $4, city = $5 \
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Validate)]
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Validate, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
pub struct Company {
|
||||
id: i32,
|
||||
|
||||
Reference in New Issue
Block a user