Skip to content

Commit

Permalink
Added alerts for phone number validation. Put e-mail addresses in table.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinscholten committed Mar 8, 2022
1 parent 6432e03 commit d6bf6a8
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/frontendMain/kotlin/Welcome.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import react.redux.useDispatch
import react.redux.useSelector
import redux.RAction
import state.AppState
import styled.styledButton
import styled.styledInput
import styled.*
import validators.isTelefoonnummerValid

fun RBuilder.welcome() = child(functionComponent {
Expand All @@ -36,11 +35,15 @@ fun RBuilder.welcome() = child(functionComponent {
b { +"Leeftijd: " }
+"${werknemer?.age}"
}
p {
b { +"Emails: " }
}
werknemer?.emails?.forEachIndexed { index, email ->
p {+" ${index + 1}. $email"}
styledTable {
styledTr {
styledTd { b { +"E-mails:" } }
}
werknemer?.emails?.forEachIndexed { index, email ->
styledTr {
styledTd { +email }
}
}
}
p {
b { +"Bedrijf: " }
Expand All @@ -49,13 +52,9 @@ fun RBuilder.welcome() = child(functionComponent {
p {
b { +"Telefoonnummer: " }
}
if(!werknemer?.telefoonnummer.isNullOrBlank()) {
p { +werknemer?.telefoonnummer!! }
}
styledInput {
attrs {
type = InputType.text
id = "inputTelefoon"
defaultValue = werknemer?.telefoonnummer.orEmpty()
onChangeFunction = {event->
tempTelefoonnummer = (event.target as HTMLInputElement).value
Expand All @@ -66,9 +65,9 @@ fun RBuilder.welcome() = child(functionComponent {
attrs.onClickFunction = {
if(isTelefoonnummerValid(tempTelefoonnummer)) {
setTelefoonnummer(dispatch, tempTelefoonnummer)
(document.getElementById("inputTelefoon") as HTMLInputElement).value = ""
window.alert("✅ Telefoonnummer veranderd naar '${tempTelefoonnummer}'")
} else {
window.alert("Telefoonnummer niet valide!")
window.alert("Telefoonnummer niet valide!")
}
}
+"Zet telefoonnummer"
Expand Down

0 comments on commit d6bf6a8

Please sign in to comment.