add: single_use products
This commit is contained in:
parent
7fbc732290
commit
e5e6d5cddb
12 changed files with 149 additions and 7 deletions
|
@ -77,6 +77,18 @@
|
|||
("oninput" "event.preventDefault(); update_on_sale_from_form(event.target.checked)"))
|
||||
(span
|
||||
(str (text "economy:label.on_sale"))))
|
||||
(label
|
||||
("for" "single_use")
|
||||
("class" "flex items_center gap_2")
|
||||
(input
|
||||
("type" "checkbox")
|
||||
("id" "single_use")
|
||||
("name" "single_use")
|
||||
("class" "w_content")
|
||||
("checked" "{{ product.single_use }}")
|
||||
("oninput" "event.preventDefault(); update_single_use_from_form(event.target.checked)"))
|
||||
(span
|
||||
(str (text "economy:label.single_use"))))
|
||||
(div
|
||||
("class" "flex flex_col gap_1")
|
||||
(label
|
||||
|
@ -240,6 +252,27 @@
|
|||
});
|
||||
}
|
||||
|
||||
async function update_single_use_from_form(single_use) {
|
||||
await trigger(\"atto::debounce\", [\"products::update\"]);
|
||||
|
||||
fetch(\"/api/v1/products/{{ product.id }}/single_use\", {
|
||||
method: \"POST\",
|
||||
headers: {
|
||||
\"Content-Type\": \"application/json\",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
single_use,
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger(\"atto::toast\", [
|
||||
res.ok ? \"success\" : \"error\",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
async function update_price_from_form(e) {
|
||||
e.preventDefault();
|
||||
await trigger(\"atto::debounce\", [\"products::update\"]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue