add: invite codes
This commit is contained in:
parent
d1a074eaeb
commit
626c6711ef
19 changed files with 410 additions and 10 deletions
|
@ -25,7 +25,7 @@
|
|||
(div
|
||||
("class" "flex flex-col gap-1")
|
||||
(label
|
||||
("for" "username")
|
||||
("for" "password")
|
||||
(b
|
||||
(text "Password")))
|
||||
(input
|
||||
|
@ -34,6 +34,20 @@
|
|||
("required" "")
|
||||
("name" "password")
|
||||
("id" "password")))
|
||||
(text "{% if config.security.enable_invite_codes -%}")
|
||||
(div
|
||||
("class" "flex flex-col gap-1")
|
||||
(label
|
||||
("for" "invite_code")
|
||||
(b
|
||||
(text "Invite code")))
|
||||
(input
|
||||
("type" "text")
|
||||
("placeholder" "invite code")
|
||||
("required" "")
|
||||
("name" "invite_code")
|
||||
("id" "invite_code")))
|
||||
(text "{%- endif %}")
|
||||
(hr)
|
||||
(div
|
||||
("class" "card-nest w-full")
|
||||
|
@ -89,6 +103,7 @@
|
|||
captcha_response: e.target.querySelector(
|
||||
\"[name=cf-turnstile-response]\",
|
||||
).value,
|
||||
invite_code: (e.target.invite_code || { value: \"\" }).value,
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
|
|
|
@ -61,21 +61,35 @@
|
|||
("href" "#/account/blocks")
|
||||
(text "{{ icon \"shield\" }}")
|
||||
(span
|
||||
(text "{{ text \"settings:tab.blocks\" }}")))
|
||||
(text "{{ text \"settings:tab.blocks\" }}"))))
|
||||
|
||||
(text "{% if config.stripe -%}")
|
||||
; stripe menu
|
||||
(div
|
||||
("class" "pillmenu")
|
||||
("ui_ident" "account_settings_tabs")
|
||||
(a
|
||||
("data-tab-button" "account/uploads")
|
||||
("href" "?page=0#/account/uploads")
|
||||
(text "{{ icon \"image-up\" }}")
|
||||
(span
|
||||
(text "{{ text \"settings:tab.uploads\" }}")))
|
||||
(text "{% if config.stripe -%}")
|
||||
(text "{% if config.security.enable_invite_codes -%}")
|
||||
(a
|
||||
("data-tab-button" "account/invites")
|
||||
("href" "#/account/invites")
|
||||
(text "{{ icon \"ticket\" }}")
|
||||
(span
|
||||
(text "{{ text \"settings:tab.invites\" }}")))
|
||||
(text "{%- endif %}")
|
||||
(a
|
||||
("data-tab-button" "account/billing")
|
||||
("href" "#/account/billing")
|
||||
(text "{{ icon \"credit-card\" }}")
|
||||
(span
|
||||
(text "{{ text \"settings:tab.billing\" }}")))
|
||||
(text "{%- endif %}"))
|
||||
(text "{{ text \"settings:tab.billing\" }}"))))
|
||||
(text "{%- endif %}")
|
||||
|
||||
(div
|
||||
("class" "card-nest")
|
||||
("ui_ident" "home_timeline")
|
||||
|
@ -495,6 +509,72 @@
|
|||
]);
|
||||
});
|
||||
};"))))))
|
||||
|
||||
(text "{% if config.security.enable_invite_codes -%}")
|
||||
(div
|
||||
("class" "w-full flex flex-col gap-2 hidden")
|
||||
("data-tab" "account/invites")
|
||||
(div
|
||||
("class" "card lowered flex flex-col gap-2")
|
||||
(a
|
||||
("href" "#/account")
|
||||
("class" "button secondary")
|
||||
(text "{{ icon \"arrow-left\" }}")
|
||||
(span
|
||||
(text "{{ text \"general:action.back\" }}")))
|
||||
(div
|
||||
("class" "card-nest")
|
||||
(div
|
||||
("class" "card flex items-center gap-2 small")
|
||||
(text "{{ icon \"ticket\" }}")
|
||||
(span
|
||||
(text "{{ text \"settings:tab.invites\" }}")))
|
||||
(div
|
||||
("class" "card flex flex-col gap-2 secondary")
|
||||
(button
|
||||
("onclick" "generate_invite_code()")
|
||||
(icon (text "plus"))
|
||||
(str (text "settings:label.generate_invite")))
|
||||
|
||||
(text "{{ components::supporter_ad(body=\"Become a supporter to generate invite codes!\") }} {% for code in invites %}")
|
||||
(div
|
||||
("class" "card flex flex-col gap-2")
|
||||
(text "{% if code[1].is_used -%}")
|
||||
; used
|
||||
(b ("class" "{% if code[1].is_used -%} fade {%- endif %}") (s (text "{{ code[1].code }}")))
|
||||
(text "{{ components::full_username(user=code[0]) }}")
|
||||
(text "{% else %}")
|
||||
; unused
|
||||
(b (text "{{ code[1].code }}"))
|
||||
(text "{%- endif %}"))
|
||||
(text "{% endfor %}")
|
||||
(script
|
||||
(text "globalThis.generate_invite_code = async () => {
|
||||
if (
|
||||
!(await trigger(\"atto::confirm\", [
|
||||
\"Are you sure you would like to do this? This action is permanent.\",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/v1/invite`, {
|
||||
method: \"POST\",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger(\"atto::toast\", [
|
||||
res.ok ? \"success\" : \"error\",
|
||||
res.message,
|
||||
]);
|
||||
|
||||
if (res.ok) {
|
||||
alert(res.payload);
|
||||
}
|
||||
});
|
||||
};"))))))
|
||||
(text "{%- endif %}")
|
||||
|
||||
(div
|
||||
("class" "w-full flex flex-col gap-2 hidden")
|
||||
("data-tab" "account/billing")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue