add: put ip block button on blocked page as well

This commit is contained in:
trisua 2025-06-28 13:33:25 -04:00
parent 0163391380
commit 0272985b81
2 changed files with 43 additions and 7 deletions

View file

@ -228,7 +228,7 @@
(icon_class (text "chevron-down") (text "dropdown-arrow"))
(str (text "auth:action.block")))
(div
("class" "inner")
("class" "inner left")
(button
("onclick" "toggle_block_user()")
(icon (text "shield"))

View file

@ -24,12 +24,24 @@
(div
("class" "card w-full secondary flex gap-2")
(text "{% if user -%} {% if not is_blocking -%}")
(button
("onclick" "toggle_block_user()")
("class" "lowered red")
(text "{{ icon \"shield\" }}")
(span
(text "{{ text \"auth:action.block\" }}")))
(div
("class" "dropdown")
(button
("onclick" "trigger('atto::hooks::dropdown', [event])")
("exclude" "dropdown")
("class" "lowered red")
(icon_class (text "chevron-down") (text "dropdown-arrow"))
(str (text "auth:action.block")))
(div
("class" "inner left")
(button
("onclick" "toggle_block_user()")
(icon (text "shield"))
(str (text "auth:action.block")))
(button
("onclick" "ip_block_user()")
(icon (text "wifi"))
(str (text "auth:action.ip_block")))))
(text "{% else %}")
(button
("onclick" "toggle_block_user()")
@ -58,6 +70,30 @@
res.message,
]);
});
};
globalThis.ip_block_user = async () => {
if (
!(await trigger(\"atto::confirm\", [
\"Are you sure you would like to do this?\",
]))
) {
return;
}
fetch(
\"/api/v1/auth/user/{{ profile.id }}/block_ip\",
{
method: \"POST\",
},
)
.then((res) => res.json())
.then((res) => {
trigger(\"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
]);
});
};"))
(text "{%- endif %}")
(a