bugfix: disallow joining room without nickname
and also creating a room without a name maybe maybe spectatorship sometimes later
This commit is contained in:
parent
bbabeb6c14
commit
346069ae96
|
@ -34,7 +34,8 @@ lazy val frontend = project
|
||||||
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.4.0",
|
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.4.0",
|
||||||
libraryDependencies += "com.raquo" %%% "laminar" % "15.0.1",
|
libraryDependencies += "com.raquo" %%% "laminar" % "15.0.1",
|
||||||
libraryDependencies += "io.laminext" %%% "websocket-circe" % "0.15.0",
|
libraryDependencies += "io.laminext" %%% "websocket-circe" % "0.15.0",
|
||||||
libraryDependencies += "io.laminext" %%% "fetch-circe" % "0.15.0"
|
libraryDependencies += "io.laminext" %%% "fetch-circe" % "0.15.0",
|
||||||
|
libraryDependencies += "io.laminext" %%% "validation-cats" % "0.15.0"
|
||||||
)
|
)
|
||||||
.dependsOn(common.js)
|
.dependsOn(common.js)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ import com.raquo.laminar.api.L.{*, given}
|
||||||
import io.laminext.fetch.Fetch
|
import io.laminext.fetch.Fetch
|
||||||
import io.laminext.fetch.circe._
|
import io.laminext.fetch.circe._
|
||||||
|
|
||||||
|
import io.laminext.syntax.core._
|
||||||
|
import io.laminext.syntax.validation._
|
||||||
|
|
||||||
import scala.util.Failure
|
import scala.util.Failure
|
||||||
import scala.util.Success
|
import scala.util.Success
|
||||||
|
|
||||||
|
@ -29,7 +32,8 @@ object JoinRoomComponent {
|
||||||
value <-- data.signal,
|
value <-- data.signal,
|
||||||
onInput.mapToValue --> data.writer
|
onInput.mapToValue --> data.writer
|
||||||
)
|
)
|
||||||
)
|
).validated(V.nonBlank("name must not be blank"))
|
||||||
|
|
||||||
def passInput(data: Var[String], placeholderText: String) = input(
|
def passInput(data: Var[String], placeholderText: String) = input(
|
||||||
tpe := "password",
|
tpe := "password",
|
||||||
className := "border-2 m-1 rounded",
|
className := "border-2 m-1 rounded",
|
||||||
|
@ -104,16 +108,36 @@ object JoinRoomComponent {
|
||||||
} --> responseReceived
|
} --> responseReceived
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val roomNameInput = nameInput(roomNameVar, "Enter room name:")
|
||||||
|
val roomPassInput = passInput(roomPassVar, "room password")
|
||||||
|
val nickNameInput = nameInput(nicknameVar, "Enter your nickname:")
|
||||||
|
val nickPassInput = passInput(nicknamePass, "nickname pass")
|
||||||
div(
|
div(
|
||||||
className := "bg-green-50 w-full h-full flex justify-center",
|
className := "bg-green-50 w-full h-full flex justify-center",
|
||||||
div(
|
div(
|
||||||
className := "w-60 flex flex-col justify-center",
|
className := "w-60 flex flex-col justify-center",
|
||||||
"Logging in:",
|
"Logging in:",
|
||||||
nameInput(roomNameVar, "Enter room name:"),
|
roomNameInput,
|
||||||
passInput(roomPassVar, "room password"),
|
div(
|
||||||
label("Alert: no https, please don't use good passwords"),
|
child.maybe <-- roomNameInput.validationError.optionMap(errors =>
|
||||||
nameInput(nicknameVar, "Enter your nickname:"),
|
span(
|
||||||
passInput(nicknamePass, "nickname pass:"),
|
cls := "text-red-700 text-sm",
|
||||||
|
errors.map(error => div(error))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
roomPassInput,
|
||||||
|
label("Alert: no https, please use throwaway passwords"),
|
||||||
|
nickNameInput,
|
||||||
|
div(
|
||||||
|
child.maybe <-- nickNameInput.validationError.optionMap(errors =>
|
||||||
|
span(
|
||||||
|
cls := "text-red-700 text-sm",
|
||||||
|
errors.map(error => div(error))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
nickPassInput,
|
||||||
submitButton,
|
submitButton,
|
||||||
newRoomButton,
|
newRoomButton,
|
||||||
div(
|
div(
|
||||||
|
|
Loading…
Reference in New Issue