add: transfer refunds
This commit is contained in:
parent
95cb889080
commit
fdaae8d977
10 changed files with 340 additions and 26 deletions
|
@ -87,9 +87,9 @@
|
|||
(span
|
||||
(text "{{ dislikes }}"))
|
||||
(text "{%- endif %}"))
|
||||
(text "{%- endif %} {%- endmacro %} {% macro full_username(user) -%} {% if user and user.username -%}")
|
||||
(text "{%- endif %} {%- endmacro %} {% macro full_username(user, wrap=true) -%} {% if user and user.username -%}")
|
||||
(div
|
||||
("class" "flex flex_wrap items_center")
|
||||
("class" "flex {% if wrap -%} flex_wrap {%- endif %} items_center")
|
||||
(a
|
||||
("href" "/@{{ user.username }}")
|
||||
("class" "flush flex gap_1")
|
||||
|
|
|
@ -49,24 +49,36 @@
|
|||
(th (text "Sender"))
|
||||
(th (text "Receiver"))
|
||||
(th (text "Amount"))
|
||||
(th (text "Product")))
|
||||
(th (text "Product"))
|
||||
(th (text "Source"))
|
||||
(th (text "Actions")))
|
||||
(tbody
|
||||
(text "{% for transfer in list -%}")
|
||||
(tr
|
||||
(td (span ("class" "date short") (text "{{ transfer[1] }}")))
|
||||
(td ("class" "w_content") (text "{{ components::full_username(user=transfer[3]) }}"))
|
||||
(td ("class" "w_content") (text "{{ components::full_username(user=transfer[4]) }}"))
|
||||
(td (span ("class" "date short") (text "{{ transfer[3].created }}")))
|
||||
(td ("class" "w_content") (text "{{ components::full_username(user=transfer[0], wrap=false) }}"))
|
||||
(td ("class" "w_content") (text "{{ components::full_username(user=transfer[1], wrap=false) }}"))
|
||||
(td
|
||||
("class" "flex items_center gap_1")
|
||||
(text "{{ transfer[2] }}")
|
||||
(text "{% if transfer[6] -%}")
|
||||
(text "{{ transfer[3].amount }}")
|
||||
(text "{% if transfer[3].is_pending -%}")
|
||||
(span ("class" "flex items_center gap_1") ("title" "Pending") (icon (text "clock")))
|
||||
(text "{%- endif %}"))
|
||||
(td
|
||||
(text "{% if transfer[5] -%}")
|
||||
(text "{% if transfer[2] -%}")
|
||||
(a
|
||||
("href" "/product/{{ transfer[5].id }}")
|
||||
("href" "/product/{{ transfer[2].id }}")
|
||||
(icon (text "external-link")))
|
||||
(text "{%- endif %}"))
|
||||
(td (text "{{ transfer[3].source }}"))
|
||||
(td
|
||||
(text "{% if user.id == transfer[1].id -%}")
|
||||
; we're the receiver
|
||||
(button
|
||||
("class" "small tiny square raised camo big_icon")
|
||||
("onclick" "issue_refund('{{ transfer[3].id }}')")
|
||||
("title" "Issue refund")
|
||||
(icon (text "undo")))
|
||||
(text "{%- endif %}")))
|
||||
(text "{%- endfor %}")))))))
|
||||
|
||||
|
@ -118,5 +130,23 @@
|
|||
window.location.href = res.payload;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
globalThis.issue_refund = async (transfer) => {
|
||||
if (
|
||||
!(await trigger(\"atto::confirm\", [
|
||||
\"Are you sure you would like to do this?\",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/v1/transfers/${transfer}/refund`, {
|
||||
method: \"POST\",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger(\"atto::toast\", [res.ok ? \"success\" : \"error\", res.message]);
|
||||
});
|
||||
}"))
|
||||
(text "{% endblock %}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue