2025-06-01 12:25:33 -04:00
( text "{% extends \"root.html\" %} {% block head %}" )
( title
( text "Requests - {{ config.name }}" ) )
( text "{% endblock %} {% block body %} {{ macros::nav(selected=\"requests\") }}" )
( main
2025-08-03 23:24:57 -04:00
( "class" "flex flex_col gap_2" )
2025-06-01 19:26:55 -04:00
; viewing other user's requests warning
( text "{% if profile.id != user.id -%}" )
( div
2025-08-03 23:24:57 -04:00
( "class" "card w_full red flex gap_2 items_center" )
2025-06-01 19:26:55 -04:00
( text "{{ icon \"skull\" }}" )
( b
( text "Viewing other user's requests! Please be careful." ) ) )
( text "{%- endif %}" )
; ...
2025-06-01 12:25:33 -04:00
( div
2025-08-03 23:24:57 -04:00
( "class" "card_nest" )
2025-06-01 12:25:33 -04:00
( div
2025-08-03 23:24:57 -04:00
( "class" "card small flex items_center justify_between gap_2" )
2025-06-01 12:25:33 -04:00
( span
2025-08-03 23:24:57 -04:00
( "class" "flex items_center gap_2" )
2025-06-01 12:25:33 -04:00
( text "{{ icon \"inbox\" }}" )
( span
( text "{{ text \"requests:label.requests\" }}" ) ) )
2025-06-01 19:26:55 -04:00
( text "{% if profile.id == user.id -%}" )
2025-06-01 12:25:33 -04:00
( button
( "onclick" "clear_requests()" )
2025-06-12 13:53:23 -04:00
( "class" "small red lowered" )
2025-06-01 12:25:33 -04:00
( text "{{ icon \"bomb\" }}" )
( span
2025-06-01 19:26:55 -04:00
( text "{{ text \"notifs:action.clear\" }}" ) ) )
( text "{% endif %}" ) )
2025-06-01 12:25:33 -04:00
( div
2025-08-03 23:24:57 -04:00
( "class" "card lowered flex flex_col gap_4" )
2025-06-01 12:25:33 -04:00
( text "{% for request in requests %} {% if request.action_type == \"CommunityJoin\" %}" )
( div
2025-08-03 23:24:57 -04:00
( "class" "card_nest" )
2025-06-01 12:25:33 -04:00
( div
2025-08-03 23:24:57 -04:00
( "class" "card small flex items_center gap_2" )
2025-06-01 12:25:33 -04:00
( text "{{ icon \"user-plus\" }}" )
( span
( text "{{ text \"requests:label.community_join_request\" }}" ) ) )
( div
2025-08-03 23:24:57 -04:00
( "class" "card flex flex_wrap gap_2" )
2025-06-01 12:25:33 -04:00
( a
( "href" "/community/{{ request.linked_asset }}/manage?uid={{ request.id }}#/members" )
( "class" "button" )
( text "{{ icon \"external-link\" }}" )
( span
( text "{{ text \"requests:label.review\" }}" ) ) )
( button
2025-06-12 13:53:23 -04:00
( "class" "lowered red" )
2025-06-01 12:25:33 -04:00
( "onclick" "remove_request('{{ request.id }}', '{{ request.linked_asset }}')" )
( text "{{ icon \"trash\" }}" )
( span
( text "{{ text \"general:action.delete\" }}" ) ) ) ) )
( text "{% elif request.action_type == \"Follow\" %}" )
( div
2025-08-03 23:24:57 -04:00
( "class" "card_nest" )
2025-06-01 12:25:33 -04:00
( div
2025-08-03 23:24:57 -04:00
( "class" "card small flex items_center gap_2" )
2025-07-15 00:08:49 -04:00
( a
( "href" "/api/v1/auth/user/find/{{ request.id }}" )
( text "{{ components::avatar(username=request.id, selector_type=\"id\") }}" ) )
2025-06-01 12:25:33 -04:00
( span
( text "{{ text \"requests:label.user_follow_request\" }}" ) ) )
( div
2025-08-03 23:24:57 -04:00
( "class" "card flex flex_col gap_2" )
2025-06-01 12:25:33 -04:00
( span
2025-08-03 23:24:57 -04:00
( "class" "flex items_center gap_2" )
2025-06-01 12:25:33 -04:00
( text "{{ text \"requests:label.user_follow_request_message\" }}" ) )
( div
2025-08-03 23:24:57 -04:00
( "class" "card flex flex_wrap w_full secondary gap_2" )
2025-06-01 12:25:33 -04:00
( a
( "href" "/api/v1/auth/user/find/{{ request.id }}" )
( "class" "button" )
( text "{{ icon \"external-link\" }}" )
( span
( text "{{ text \"requests:action.view_profile\" }}" ) ) )
( button
2025-06-12 13:53:23 -04:00
( "class" "lowered green" )
2025-06-01 12:25:33 -04:00
( "onclick" "accept_follow_request(event, '{{ request.id }}')" )
( text "{{ icon \"check\" }}" )
( span
( text "{{ text \"general:action.accept\" }}" ) ) )
( button
2025-06-12 13:53:23 -04:00
( "class" "lowered red" )
2025-06-01 12:25:33 -04:00
( "onclick" "remove_request('{{ request.id }}', '{{ request.linked_asset }}')" )
( text "{{ icon \"trash\" }}" )
( span
( text "{{ text \"general:action.delete\" }}" ) ) ) ) ) )
2025-08-08 02:17:06 -04:00
( text "{% elif request.action_type == \"Transfer\" %}" )
( div
( "class" "card_nest" )
( div
( "class" "card small flex items_center gap_2" )
( icon ( text "piggy-bank" ) )
( span
( str ( text "requests:label.coin_transfer_request" ) ) ) )
( div
( "class" "card flex flex_col gap_2" )
( span ( a ( "href" "/api/v1/auth/user/find/{{ request.linked_asset }}" ) ( text "Somebody" ) ) ( text " is asking for a transfer of " ) ( b ( text "{{ request.data.Int32 }} coins" ) ) ( text "." ) )
( div
( "class" "card flex flex_wrap w_full secondary gap_2" )
( a
( "href" "/api/v1/auth/user/find/{{ request.linked_asset }}" )
( "class" "button" )
( text "{{ icon \"external-link\" }}" )
( span
( text "{{ text \"requests:action.view_profile\" }}" ) ) )
( button
( "class" "lowered green" )
( "onclick" "accept_transfer_request(event, '{{ request.id }}', '{{ request.linked_asset }}', {{ request.data.Int32 }})" )
( text "{{ icon \"check\" }}" )
( span
( text "{{ text \"general:action.accept\" }}" ) ) )
( button
( "class" "lowered red" )
( "onclick" "remove_request('{{ request.id }}', '{{ request.linked_asset }}')" )
( text "{{ icon \"trash\" }}" )
( span
( text "{{ text \"general:action.delete\" }}" ) ) ) ) ) )
2025-06-01 12:25:33 -04:00
( text "{%- endif %} {% endfor %} {% for question in questions %}" )
( div
2025-08-03 23:24:57 -04:00
( "class" "card_nest" )
2025-07-13 18:42:08 -04:00
( text "{{ components::question(question=question[0], owner=question[1], asking_about=question[2], profile=user) }}" )
2025-06-01 12:25:33 -04:00
( form
2025-08-03 23:24:57 -04:00
( "class" "card flex flex_col gap_2" )
2025-06-01 12:25:33 -04:00
( "onsubmit" "answer_question_from_form(event, '{{ question[0].id }}')" )
( div
2025-08-03 23:24:57 -04:00
( "class" "flex flex_col gap_1" )
2025-06-01 12:25:33 -04:00
( label
( "for" "content" )
( text "{{ text \"communities:label.content\" }}" ) )
( textarea
( "type" "text" )
( "name" "content" )
( "id" "content" )
( "placeholder" "content" )
( "required" "" )
( "minlength" "2" )
( "maxlength" "4096" ) ) )
( div
( "id" "files_list" )
2025-08-03 23:24:57 -04:00
( "class" "flex gap_2 flex_wrap" ) )
2025-06-01 12:25:33 -04:00
( div
2025-08-03 23:24:57 -04:00
( "class" "flex w_full justify_between flex_collapse gap_2" )
2025-06-23 13:48:16 -04:00
( div
2025-08-03 23:24:57 -04:00
( "class" "flex flex_wrap w_full gap_2" )
2025-06-23 13:48:16 -04:00
( text "{{ components::create_post_options() }}" )
( button
( "type" "button" )
( "class" "red lowered" )
( "onclick" "trigger('me::remove_question', ['{{ question[0].id }}'])" )
( text "{{ text \"general:action.delete\" }}" ) )
( button
( "type" "button" )
( "class" "red lowered" )
( "onclick" "trigger('me::ip_block_question', ['{{ question[0].id }}'])" )
( text "{{ text \"auth:action.ip_block\" }}" ) ) )
2025-06-01 12:25:33 -04:00
( button
2025-06-23 13:48:16 -04:00
( text "{{ text \"requests:label.answer\" }}" ) ) ) ) )
2025-06-02 21:39:35 -04:00
( text "{% endfor %}" ) ) )
( text "{{ components::pagination(page=page, items=requests|length, key=\"&id=\", value=profile.id) }}" ) )
2025-06-01 12:25:33 -04:00
( script
2025-08-08 02:17:06 -04:00
( text " async function remove_request ( id, linked_asset, confirm = true ) {
if ( confirm ) {
if (
! ( await trigger ( \"atto::confirm\", [
\"Are you sure you want to do this?\",
] ) )
) {
return ;
}
2025-06-01 12:25:33 -04:00
}
fetch ( ` /api/v1/requests/${id}/${linked_asset} ` , {
method: \"DELETE\",
} )
. then ( ( res ) => res.json ( ) )
. then ( ( res ) => {
trigger ( \"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
] ) ;
} ) ;
}
async function clear_requests ( ) {
if (
! ( await trigger ( \"atto::confirm\", [
\"Are you sure you want to do this?\",
] ) )
) {
return ;
}
fetch ( \"/api/v1/requests/my\", {
method: \"DELETE\",
} )
. then ( ( res ) => res.json ( ) )
. then ( ( res ) => {
trigger ( \"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
] ) ;
} ) ;
}
window.answer_question_from_form = async ( e, answering ) => {
e.preventDefault ( ) ;
await trigger ( \"atto::debounce\", [\"posts::create\"] ) ;
2025-06-04 17:21:46 -04:00
// poll
const poll_data = get_poll_data ( ) ;
if ( !poll_data[0] ) {
return alert ( poll_data[1] ) ;
}
2025-06-01 12:25:33 -04:00
// create body
const body = new FormData ( ) ;
if ( e.target.file_picker ) {
for ( const file of e.target.file_picker.files ) {
body.append ( file.name, file ) ;
}
}
body.append (
\"body\",
JSON.stringify ( {
content: e.target.content.value,
community: \"{{ config.town_square }}\",
answering,
2025-06-04 17:21:46 -04:00
poll: poll_data[1],
2025-06-01 12:25:33 -04:00
} ) ,
) ;
// . . .
fetch ( \"/api/v1/posts\", {
method: \"POST\",
body,
} )
. then ( ( res ) => res.json ( ) )
. then ( async ( res ) => {
trigger ( \"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
] ) ;
if ( res.ok ) {
// update settings
await update_settings_maybe ( res.payload ) ;
// . . .
e.target.parentElement.remove ( ) ;
}
} ) ;
} ;
globalThis.accept_follow_request = async ( e, id ) => {
await trigger ( \"atto::debounce\", [\"users::follow\"] ) ;
if (
! ( await trigger ( \"atto::confirm\", [
\"Are you sure you would like to do this?\",
] ) )
) {
return ;
}
fetch ( ` /api/v1/auth/user/${id}/follow/accept ` , {
method: \"POST\",
} )
. then ( ( res ) => res.json ( ) )
. then ( async ( res ) => {
trigger ( \"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
] ) ;
if ( res.ok ) {
e.target.parentElement.parentElement.parentElement.parentElement.remove ( ) ;
if (
await trigger ( \"atto::confirm\", [
\"Would you like to follow this user back? This will allow them to view your profile.\",
] )
) {
fetch ( ` /api/v1/auth/user/${id}/follow ` , {
method: \"POST\",
} )
. then ( ( res ) => res.json ( ) )
. then ( ( res ) => {
trigger ( \"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
] ) ;
} ) ;
}
}
} ) ;
2025-08-08 02:17:06 -04:00
} ;
globalThis.accept_transfer_request = async ( e, id, receiver, amount ) => {
await trigger ( \"atto::debounce\", [\"economy::transfer\"] ) ;
if (
! ( await trigger ( \"atto::confirm\", [
\"Are you sure you would like to do this?\",
] ) )
) {
return ;
}
fetch ( ` /api/v1/transfers ` , {
method: \"POST\",
headers: {
\"Content-Type\": \"application/json\",
},
body: JSON.stringify ( {
receiver,
amount,
} ) ,
} )
. then ( ( res ) => res.json ( ) )
. then ( async ( res ) => {
trigger ( \"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
] ) ;
if ( res.ok ) {
e.target.parentElement.parentElement.parentElement.parentElement.remove ( ) ;
remove_request ( id, receiver, false ) ;
}
} ) ;
2025-06-01 12:25:33 -04:00
} ;"))
( text "{% endblock %}" )