(text "{% extends \"root.html\" %} {% block head %}") (title (text "My stacks - {{ config.name }}")) (text "{% endblock %} {% block body %} {{ macros::nav() }}") (main ("class" "flex flex-col gap-2") (text "{{ macros::timelines_nav(selected=\"stacks\") }} {% if user -%}") (div ("class" "card-nest") (div ("class" "card small") (b (text "{{ text \"stacks:label.create_new\" }}"))) (form ("class" "card flex flex-col gap-2") ("onsubmit" "create_stack_from_form(event)") (div ("class" "flex flex-col gap-1") (label ("for" "name") (text "{{ text \"communities:label.name\" }}")) (input ("type" "text") ("name" "name") ("id" "name") ("placeholder" "name") ("required" "") ("minlength" "2") ("maxlength" "32"))) (button ("class" "primary") (text "{{ text \"communities:action.create\" }}")))) (text "{%- endif %}") (div ("class" "card-nest w-full") (div ("class" "card small flex items-center justify-between gap-2") (div ("class" "flex items-center gap-2") (text "{{ icon \"award\" }}") (span (text "{{ text \"stacks:label.my_stacks\" }}")))) (div ("class" "card flex flex-col gap-2") (text "{% for item in list %}") (a ("href" "/stacks/{{ item.id }}") ("class" "card secondary flex flex-col gap-2") (div ("class" "flex items-center gap-2") (text "{{ icon \"list\" }}") (b (text "{{ item.name }}"))) (span (text "Created ") (span ("class" "date") (text "{{ item.created }}")) (text "; {{ item.privacy }}; {{ item.users|length }} users"))) (text "{% endfor %}")))) (script (text "async function create_stack_from_form(e) { e.preventDefault(); await trigger(\"atto::debounce\", [\"stacks::create\"]); fetch(\"/api/v1/stacks\", { method: \"POST\", headers: { \"Content-Type\": \"application/json\", }, body: JSON.stringify({ name: e.target.name.value, }), }) .then((res) => res.json()) .then((res) => { trigger(\"atto::toast\", [ res.ok ? \"success\" : \"error\", res.message, ]); if (res.ok) { setTimeout(() => { window.location.href = `/stacks/${res.payload}`; }, 100); } }); }")) (text "{% endblock %}")