add: coin purchases + donator badge
This commit is contained in:
parent
fd529d3847
commit
44f9edd67e
21 changed files with 345 additions and 38 deletions
|
@ -14,9 +14,9 @@
|
|||
(span (str (text "general:link.wallet")))))
|
||||
(div
|
||||
("class" "card lowered flex flex_col gap_4")
|
||||
(a
|
||||
(button
|
||||
("class" "card button raised")
|
||||
("href" "/wallet/buy")
|
||||
("onclick" "document.getElementById('buy_dialog').showModal()")
|
||||
(b (text "Coin balance"))
|
||||
(h3
|
||||
("class" "flex gap_2 items_center")
|
||||
|
@ -63,4 +63,54 @@
|
|||
(icon (text "external-link")))
|
||||
(text "{%- endif %}")))
|
||||
(text "{%- endfor %}")))))))
|
||||
|
||||
(dialog
|
||||
("id" "buy_dialog")
|
||||
(div
|
||||
("class" "inner flex flex_col gap_2")
|
||||
(p (text "All coin purchases are one-time and will not recur."))
|
||||
(p (text "If you do not receive your coins within a minute of purchase, please contact support."))
|
||||
|
||||
(button
|
||||
("class" "lowered w_full justify_start")
|
||||
("onclick" "checkout('Coins100')")
|
||||
(text "100 coins ({{ config.stripe.price_texts.coins_100 }})"))
|
||||
|
||||
(button
|
||||
("class" "w_full justify_start")
|
||||
("onclick" "checkout('Coins400')")
|
||||
(text "400 coins ({{ config.stripe.price_texts.coins_400 }})"))
|
||||
|
||||
(hr ("class" "margin"))
|
||||
(div
|
||||
("class" "flex gap_2 justify_between")
|
||||
(div null?)
|
||||
(button
|
||||
("class" "lowered red")
|
||||
("type" "button")
|
||||
("onclick", "document.getElementById('buy_dialog').close()")
|
||||
(icon (text "x"))
|
||||
(str (text "dialog:action.cancel"))))))
|
||||
|
||||
(script
|
||||
(text "globalThis.checkout = (product) => {
|
||||
document.getElementById('buy_dialog').close();
|
||||
fetch(\"/api/v1/service_hooks/stripe/checkout\", {
|
||||
method: \"POST\",
|
||||
headers: {
|
||||
\"Content-Type\": \"application/json\",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
product,
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger(\"atto::toast\", [res.ok ? \"success\" : \"error\", res.message]);
|
||||
|
||||
if (res.ok) {
|
||||
window.location.href = res.payload;
|
||||
}
|
||||
});
|
||||
}"))
|
||||
(text "{% endblock %}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue