fix: global question answering

This commit is contained in:
trisua 2025-05-11 15:40:03 -04:00
parent 68c3a5d84e
commit 52339e6b98

View file

@ -33,9 +33,18 @@
></textarea>
</div>
<div id="files_list" class="flex gap-2 flex-wrap"></div>
<div class="flex gap-2">
{{ components::emoji_picker(element_id="content",
render_dialog=true) }} {% if is_supporter %} {{
components::file_picker(files_list_id="files_list") }} {% endif
%}
<button class="primary">
{{ text "communities:action.create" }}
{{ text "requests:label.answer" }}
</button>
</div>
</form>
</div>
{% endif %}
@ -62,16 +71,29 @@
window.answer_question_from_form = async (e, answering) => {
e.preventDefault();
await trigger("atto::debounce", ["posts::create"]);
fetch("/api/v1/posts", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
// 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: community ? community : "{{ config.town_square }}",
answering,
}),
);
// ...
fetch("/api/v1/posts", {
method: "POST",
body,
})
.then((res) => res.json())
.then((res) => {