Accounts can now be deleted

This commit is contained in:
2020-08-14 15:17:58 +02:00
parent 00dafe1da9
commit 662d6c706b
16 changed files with 204 additions and 29 deletions
+71
View File
@@ -8,6 +8,7 @@ import be.simplenotes.app.views.components.submitButton
import be.simplenotes.domain.security.JwtPayload
import io.konform.validation.ValidationError
import kotlinx.html.*
import kotlinx.html.ButtonType.submit
class UserView(staticFileResolver: StaticFileResolver) : View(staticFileResolver) {
fun register(
@@ -70,4 +71,74 @@ class UserView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
}
}
}
fun settings(
jwtPayload: JwtPayload,
error: String? = null,
validationErrors: List<ValidationError> = emptyList(),
) = renderPage("Settings", jwtPayload = jwtPayload) {
div("container mx-auto p-8") {
section("m-4 p-4 bg-gray-800 rounded") {
h1("text-xl") {
+"Welcome "
span("text-teal-200 font-semibold") { +jwtPayload.username }
}
}
section("m-4 p-4 bg-gray-800 rounded") {
p(classes = "mb-4") {
+"Export all my data in a zip file"
}
form {
button(classes = "btn btn-teal block") { +"Export my data" }
}
}
section(classes = "m-4 p-4 bg-gray-800 rounded") {
h2(classes = "mb-4 text-red-600 text-lg font-semibold") {
+"Delete my account"
}
error?.let { alert(Alert.Warning, error) }
details {
summary {
span(classes = "mb-4 font-semibold underline") {
+"Are you sure? "
+"You are about to delete this user, and this process is irreversible !"
}
}
form(classes = "mt-4", method = FormMethod.post) {
input(
id = "password",
placeholder = "Password",
autoComplete = "off",
type = InputType.password,
error = validationErrors.find { it.dataPath == ".password" }?.message
)
checkBoxInput(name = "checked") {
attributes["required"] = ""
+" Do you want to proceed ?"
}
button(type = submit, classes = "block mt-4 btn btn-red", name = "delete") { +"I'm sure" }
}
}
}
}
}
}
class SUMMARY(consumer: TagConsumer<*>) :
HTMLTag(
"summary", consumer, emptyMap(),
inlineTag = true,
emptyTag = false
),
HtmlInlineTag
fun DETAILS.summary(block: SUMMARY.() -> Unit = {}) {
SUMMARY(consumer).visit(block)
}