2025-04-08 15:49:41 -04:00
|
|
|
{% extends "root.html" %} {% block head %}
|
2025-03-27 18:10:47 -04:00
|
|
|
<title>My communities - {{ config.name }}</title>
|
|
|
|
{% endblock %} {% block body %} {{ macros::nav(selected="communities") }}
|
|
|
|
<main class="flex flex-col gap-2">
|
2025-03-29 00:26:56 -04:00
|
|
|
{% if user %}
|
2025-03-27 18:10:47 -04:00
|
|
|
<div class="card-nest">
|
2025-03-29 00:26:56 -04:00
|
|
|
<div class="card small">
|
2025-03-27 18:10:47 -04:00
|
|
|
<b>{{ text "communities:label.create_new" }}</b>
|
|
|
|
</div>
|
|
|
|
|
2025-03-29 00:26:56 -04:00
|
|
|
<form
|
|
|
|
class="card flex flex-col gap-2"
|
|
|
|
onsubmit="create_community_from_form(event)"
|
|
|
|
>
|
2025-03-27 18:10:47 -04:00
|
|
|
<div class="flex flex-col gap-1">
|
2025-03-31 11:45:34 -04:00
|
|
|
<label for="title">{{ text "communities:label.name" }}</label>
|
2025-03-27 18:10:47 -04:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
name="title"
|
|
|
|
id="title"
|
|
|
|
placeholder="name"
|
|
|
|
required
|
|
|
|
minlength="2"
|
|
|
|
maxlength="32"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button class="primary">
|
|
|
|
{{ text "communities:action.create" }}
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
2025-04-02 23:26:43 -04:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
<div class="card-nest w-full">
|
2025-04-10 21:37:33 -04:00
|
|
|
<div class="card small flex items-center justify-between gap-2">
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
{{ icon "award" }}
|
|
|
|
<span>{{ text "communities:label.my_communities" }}</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a href="/communities/search" class="button quaternary small">
|
|
|
|
{{ icon "search" }}
|
|
|
|
<span>{{ text "communities:label.join_new" }}</span>
|
|
|
|
</a>
|
2025-04-02 23:26:43 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card flex flex-col gap-2">
|
|
|
|
{% for item in list %} {{
|
|
|
|
components::community_listing_card(community=item) }} {% endfor %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card-nest w-full">
|
2025-04-10 21:46:24 -04:00
|
|
|
<div class="card small flex items-center gap-2">
|
|
|
|
{{ icon "trending-up" }}
|
|
|
|
<span>{{ text "communities:label.popular_communities" }}</span>
|
2025-04-02 23:26:43 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card flex flex-col gap-2">
|
|
|
|
{% for item in popular_list %} {{
|
|
|
|
components::community_listing_card(community=item) }} {% endfor %}
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-03-27 18:10:47 -04:00
|
|
|
</main>
|
2025-03-29 00:26:56 -04:00
|
|
|
|
|
|
|
<script>
|
2025-04-03 16:47:48 -04:00
|
|
|
async function create_community_from_form(e) {
|
2025-03-29 00:26:56 -04:00
|
|
|
e.preventDefault();
|
2025-04-03 16:47:48 -04:00
|
|
|
await trigger("atto::debounce", ["communities::create"]);
|
2025-03-29 00:26:56 -04:00
|
|
|
fetch("/api/v1/communities", {
|
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
title: e.target.title.value,
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((res) => {
|
|
|
|
trigger("atto::toast", [
|
|
|
|
res.ok ? "success" : "error",
|
|
|
|
res.message,
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location.href = `/community/${res.payload}`;
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
2025-03-27 18:10:47 -04:00
|
|
|
{% endblock %}
|