fix: wallet panic
This commit is contained in:
parent
e5e6d5cddb
commit
a08552338b
4 changed files with 46 additions and 13 deletions
|
@ -180,11 +180,19 @@
|
||||||
(text "{% if product.method != \"ManualMail\" -%} {{ product.method.AutoMail }} {%- endif %}")))
|
(text "{% if product.method != \"ManualMail\" -%} {{ product.method.AutoMail }} {%- endif %}")))
|
||||||
(button (str (text "general:action.save")))))
|
(button (str (text "general:action.save")))))
|
||||||
|
|
||||||
(a
|
(div
|
||||||
("class" "button secondary")
|
("class" "flex gap_2")
|
||||||
("href" "/product/{{ product.id }}")
|
(a
|
||||||
(icon (text "arrow-left"))
|
("class" "button secondary")
|
||||||
(str (text "general:action.back"))))
|
("href" "/product/{{ product.id }}")
|
||||||
|
(icon (text "arrow-left"))
|
||||||
|
(str (text "general:action.back")))
|
||||||
|
|
||||||
|
(button
|
||||||
|
("class" "lowered red")
|
||||||
|
("onclick" "delete_product()")
|
||||||
|
(icon (text "trash"))
|
||||||
|
(str (text "general:action.delete")))))
|
||||||
|
|
||||||
(script
|
(script
|
||||||
(text "async function update_title_from_form(e) {
|
(text "async function update_title_from_form(e) {
|
||||||
|
@ -339,6 +347,27 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function delete_product() {
|
||||||
|
if (
|
||||||
|
!(await trigger(\"atto::confirm\", [
|
||||||
|
\"Are you sure you would like to do this?\",
|
||||||
|
]))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch(\"/api/v1/products/{{ product.id }}\", {
|
||||||
|
method: \"DELETE\",
|
||||||
|
})
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((res) => {
|
||||||
|
trigger(\"atto::toast\", [
|
||||||
|
res.ok ? \"success\" : \"error\",
|
||||||
|
res.message,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
globalThis.mirror_use_automail = () => {
|
globalThis.mirror_use_automail = () => {
|
||||||
const use_automail = document.getElementById(\"use_automail\").checked;
|
const use_automail = document.getElementById(\"use_automail\").checked;
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ pub async fn update_price_request(
|
||||||
None => return Json(Error::NotAllowed.into()),
|
None => return Json(Error::NotAllowed.into()),
|
||||||
};
|
};
|
||||||
|
|
||||||
if req.price < 25 {
|
if req.price < 25 && req.price != 0 {
|
||||||
return Json(
|
return Json(
|
||||||
Error::MiscError(
|
Error::MiscError(
|
||||||
"Price is too low, please use a price of 25 coins or more".to_string(),
|
"Price is too low, please use a price of 25 coins or more".to_string(),
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl DataManager {
|
||||||
Ok(res.unwrap())
|
Ok(res.unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAXIMUM_FREE_PRODUCTS: usize = 5;
|
const MAXIMUM_FREE_PRODUCTS: usize = 10;
|
||||||
|
|
||||||
/// Create a new product in the database.
|
/// Create a new product in the database.
|
||||||
///
|
///
|
||||||
|
|
|
@ -54,13 +54,17 @@ impl DataManager {
|
||||||
match transfer.method {
|
match transfer.method {
|
||||||
CoinTransferMethod::Transfer => None,
|
CoinTransferMethod::Transfer => None,
|
||||||
CoinTransferMethod::Purchase(id) => {
|
CoinTransferMethod::Purchase(id) => {
|
||||||
Some(if let Some(product) = seen_products.get(&id) {
|
if let Some(product) = seen_products.get(&id) {
|
||||||
product.to_owned()
|
Some(product.to_owned())
|
||||||
} else {
|
} else {
|
||||||
let product = self.get_product_by_id(id).await?;
|
match self.get_product_by_id(id).await {
|
||||||
seen_products.insert(product.id, product.clone());
|
Ok(product) => {
|
||||||
product
|
seen_products.insert(product.id, product.clone());
|
||||||
})
|
Some(product)
|
||||||
|
}
|
||||||
|
Err(_) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transfer.is_pending,
|
transfer.is_pending,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue