Can update a single movement information
This commit is contained in:
parent
9d345b9c42
commit
394fbd50f0
@ -28,6 +28,21 @@ pub async fn get_single(movement: MovementInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(movement.movement()))
|
||||
}
|
||||
|
||||
/// Update a single movement information
|
||||
pub async fn update(
|
||||
auth: AuthExtractor,
|
||||
movement: MovementInPath,
|
||||
req: web::Json<UpdateMovementQuery>,
|
||||
) -> HttpResult {
|
||||
if let Some(err) = req.check_error(auth.user_id()).await? {
|
||||
return Ok(HttpResponse::BadRequest().json(err));
|
||||
}
|
||||
|
||||
movements_service::update(movement.movement().id(), &req).await?;
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
/// Delete a movement
|
||||
pub async fn delete(movement: MovementInPath) -> HttpResult {
|
||||
movements_service::delete(movement.movement().id()).await?;
|
||||
|
@ -139,6 +139,10 @@ async fn main() -> std::io::Result<()> {
|
||||
"/api/movement/{movement_id}",
|
||||
web::get().to(movement_controller::get_single),
|
||||
)
|
||||
.route(
|
||||
"/api/movement/{movement_id}",
|
||||
web::put().to(movement_controller::update),
|
||||
)
|
||||
.route(
|
||||
"/api/movement/{movement_id}",
|
||||
web::delete().to(movement_controller::delete),
|
||||
|
@ -12,13 +12,13 @@ export function AccountWidget(p: { account: Account }): React.ReactElement {
|
||||
height: "1.5em",
|
||||
width: "1.5em",
|
||||
backgroundColor: darkTheme.enabled ? "white" : "black",
|
||||
mask: `url(\"data:image/svg+xml;base64,${toBase64(
|
||||
mask: `url("data:image/svg+xml;base64,${toBase64(
|
||||
new TextEncoder().encode(
|
||||
ServerApi.Config.accounts_types.find(
|
||||
(t) => t.code === p.account.type
|
||||
)!.icon
|
||||
)
|
||||
)}\")`,
|
||||
)}")`,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
@ -59,6 +59,7 @@ export function MoneyNavList(): React.ReactElement {
|
||||
|
||||
{accounts.list.list.map((a) => (
|
||||
<NavLink
|
||||
key={a.id}
|
||||
label={a.name}
|
||||
uri={`/account/${a.id}`}
|
||||
icon={<AccountWidget account={a} />}
|
||||
|
Loading…
x
Reference in New Issue
Block a user