extends baseLayout

block body
    #settings
        include components/userinfo

        .settings-block
            form(action="settings/save", method="POST", enctype="multipart/form-data")
                h2 account settings

                .username
                    p change username
                    input(type="text", value=user.username, name="username", autocomplete="off", spellcheck="false", aria-label="username")
                    span.available username available

                .avatar
                    p upload a new avatar
                    label(for="avatar-upload", class="avatar-upload-label")
                        i.fas.fa-upload
                        span upload
                    input(type="file", accept=".png,.jpg", name="avatar", id="avatar-upload", aria-label="avatar upload")

                h2 behaviour

                .default-lang
                    p default language
                    - string dropdownLabel = "default language";
                    include components/dropdown
                        block options
                            - import std.conv : to;
                            - import pastemyst.data : languages;
                            input.hidden(type="text", name="language")
                            - foreach (ulong i, lang; languages)
                                - bool checked = false;
                                - if (lang["name"] == user.defaultLang)
                                    - checked = true;
                                label.option
                                    input(type="radio", name="language-temp", value=lang["name"].to!string() ~ "," ~ lang["mimes"][0].to!string(), checked=checked)
                                    span= lang["name"].to!string()

                h2 visibility

                input(type="checkbox", id="public-profile", name="publicProfile", aria-label="public profile", checked=user.publicProfile ? true : false)
                label(for="public-profile") public profile
                p.description whether your profile is public for everyone to see. your avatar and username will be visible including any pastes you marked to show on your profile.
                - if (user.publicProfile)
                    p.description your public profile is available here: #[a(href="/users/" ~ user.username) /users/#{user.username}]

                h2 api
                - import pastemyst.db : findOneById;
                - import pastemyst.data : ApiKey;
                - auto key = findOneById!ApiKey(user.id).get().key;

                p.description this is a token which you can use to get information which can only be fetched with your account. to see how to use the token read the #[a(href="/api-docs") api docs].
                p.description you should keep this token a secret, but you can regenerate it if needed.

                span.token= key
                a.token-copy copy
                
                br

                a.regen(href="settings/regen") regenerate

                h2 privacy

                p.description you can view all the data we store on you with this link. the page is private and only you can see it.

                a.view-data(href="/user/data") view all my data

                h2 account deletion

                p.description deleting your account will delete #[b everything] tied to your account (user data, pastes, stars, etc.)
                p.description this action cannot be undone

                .delete-account
                    i.fas.fa-exclamation-triangle
                    a(href="/user/delete") delete my account

                br
                button.save(type="button") save

block scripts
    - import pastemyst.data : getVersion;

    script(type="module", src="/static/scripts/pages/settings.js?v=#{getVersion()}")
