Prevent new domain request until new subdomain is correct.

This commit is contained in:
Philippe Pittoli 2023-07-25 23:01:03 +02:00
parent fa4e6703ee
commit e1dcf5c40b

View File

@ -262,11 +262,13 @@ handleAction = case _ of
HandleNewDomainInput adduserinp -> do HandleNewDomainInput adduserinp -> do
case adduserinp of case adduserinp of
INP_newdomain v -> do INP_newdomain v -> do
H.modify_ _ { newDomainForm { new_domain = v } } H.modify_ _ { newDomainForm { new_domain = v } }
case runParser v DomainParser.domain of case v of
Left error_string -> H.modify_ _ { newDomainForm { error_string = Just $ show error_string } } "" -> H.modify_ _ { newDomainForm { error_string = Nothing } }
Right _ -> H.modify_ _ { newDomainForm { error_string = Nothing } } otherwise -> case runParser v DomainParser.domain of
Left error_string -> H.modify_ _ { newDomainForm { error_string = Just $ show error_string } }
Right _ -> H.modify_ _ { newDomainForm { error_string = Nothing } }
UpdateSelectedDomain domain -> H.modify_ _ { newDomainForm { selected_domain = domain } } UpdateSelectedDomain domain -> H.modify_ _ { newDomainForm { selected_domain = domain } }
EnterDomain domain -> do EnterDomain domain -> do
@ -287,10 +289,12 @@ handleAction = case _ of
{ newDomainForm } <- H.get { newDomainForm } <- H.get
let new_domain = build_new_domain newDomainForm.new_domain newDomainForm.selected_domain let new_domain = build_new_domain newDomainForm.new_domain newDomainForm.selected_domain
case new_domain of case newDomainForm.error_string, new_domain of
"" -> Just error_string, _ ->
H.raise $ Log $ UnableToSend $ "You didn't enter a valid new domain: " <> error_string
_, "" ->
H.raise $ Log $ UnableToSend "You didn't enter the new domain!" H.raise $ Log $ UnableToSend "You didn't enter the new domain!"
_ -> do Nothing, _ -> do
message <- H.liftEffect message <- H.liftEffect
$ DNSManager.serialize $ DNSManager.serialize
$ DNSManager.MkNewDomain { domain: new_domain } $ DNSManager.MkNewDomain { domain: new_domain }