diff --git a/.dockerignore b/.dockerignore index 3fdebbd..ec97931 100644 --- a/.dockerignore +++ b/.dockerignore @@ -26,6 +26,7 @@ server/build server/dev server/test server/justfile +server/priv/static/ # shared shared/build diff --git a/.env.example b/.env.example index 7e94bd5..a3e0ebe 100644 --- a/.env.example +++ b/.env.example @@ -6,4 +6,4 @@ export DATABASE_URL="postgresql://user:password@host:port/database" #  KEY export SECRET_KEY="" -export RUN_BACKEND_LOCALLY="true" +export RUN_SERVER_LOCALLY="true" diff --git a/client/src/client/page/login.gleam b/client/src/client/page/login.gleam index 384bb47..37bfcf1 100644 --- a/client/src/client/page/login.gleam +++ b/client/src/client/page/login.gleam @@ -19,7 +19,7 @@ pub type Model { } pub type Msg { - UserUpdatedLoginField(value: String) + UserUpdatedEmailField(value: String) UserUpdatedPasswordField(value: String) UserSentRequest @@ -37,19 +37,19 @@ pub type LoginStep { pub fn update(model: Model, msg: Msg) -> LoginStep { case msg { - UserUpdatedLoginField(value:) -> { - let value = + UserUpdatedEmailField(value:) -> { + let email = string.trim(value) |> string.lowercase() - let new = Model(..model, email: value) + let new = Model(..model, email:) Continue(new, effect.none()) } UserUpdatedPasswordField(value:) -> { - let value = string.trim(value) + let password = string.trim(value) - let new = Model(..model, password: value) + let new = Model(..model, password:) Continue(new, effect.none()) } @@ -90,7 +90,7 @@ pub fn view(_session: session.Session, model: Model) -> element.Element(Msg) { html.section(attributes, [ html.div(container_attr, [ view_fieldset(model), - view_login_button(model), + view_send_button(model), view_message_text(model), ]), ]), @@ -99,7 +99,7 @@ pub fn view(_session: session.Session, model: Model) -> element.Element(Msg) { element.fragment(content) } -fn view_login_button(model: Model) -> element.Element(Msg) { +fn view_send_button(model: Model) -> element.Element(Msg) { let attributes = [ class("flex gap-2 justify-center items-center"), class("p-2 text-white rounded-md bg-secondary"), @@ -144,7 +144,7 @@ fn view_fieldset(model: Model) -> element.Element(Msg) { value: model.email, icon: "md-email", disabled: False, - on_input: UserUpdatedLoginField, + on_input: UserUpdatedEmailField, input_type: "email", ), diff --git a/client/src/client/page/signup.gleam b/client/src/client/page/signup.gleam index df0ca0a..a8a8945 100644 --- a/client/src/client/page/signup.gleam +++ b/client/src/client/page/signup.gleam @@ -51,6 +51,7 @@ fn build_request(model: Model) -> contract.RequestBody { } pub type Msg { + // Field updates UserUpdatedNameField(String) UserUpdatedEmailField(String) UserUpdatedPhoneField(String) @@ -58,8 +59,8 @@ pub type Msg { UserUpdatedConfirmPasswordField(String) UserSelectedRole(String) + // Auth related messages UserSentRequest - ServerSentResponse(Result(user.User, rsvp.Error)) } @@ -90,22 +91,29 @@ pub fn update(model: Model, msg: Msg) -> #(Model, effect.Effect(Msg)) { #(Model(..model, user_role:), effect.none()) } - UserUpdatedPasswordField(user_password) -> { - let text_message = case user_password == model.user_confirm_password { - True -> "" - False -> "Passwords must match" + UserUpdatedPasswordField(value) -> { + let match_not_empty = model.user_confirm_password != "" + + let text_message = case value == model.user_confirm_password { + False if match_not_empty -> "Passwords must match" + _ -> "" } - #(Model(..model, text_message:, user_password:), effect.none()) + #(Model(..model, text_message:, user_password: value), effect.none()) } - UserUpdatedConfirmPasswordField(user_confirm_password) -> { - let text_message = case user_confirm_password == model.user_password { - True -> "" - False -> "Passwords must match" + UserUpdatedConfirmPasswordField(value) -> { + let match_not_empty = model.user_password != "" + + let text_message = case value == model.user_password { + False if match_not_empty -> "Passwords must match" + _ -> "" } - #(Model(..model, text_message:, user_confirm_password:), effect.none()) + #( + Model(..model, text_message:, user_confirm_password: value), + effect.none(), + ) } UserSentRequest -> { diff --git a/justfile b/justfile index 5f47cda..f7c811c 100644 --- a/justfile +++ b/justfile @@ -16,9 +16,9 @@ pg_health_cmd := "--health-cmd 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB} pg_health_conf := "--health-interval 10s --health-retries 3 --health-timeout 5s" pg_health_start_period := "--health-start-period 30s" -# backend -run_backend_locally := env("RUN_BACKEND_LOCALLY", "false") -backend_port := if run_backend_locally == "false" { "-p 8000:8000" } else { "" } +# server +run_server_locally := env("RUN_SERVER_LOCALLY", "false") +server_port := if run_server_locally == "false" { "-p 8000:8000" } else { "" } # List available recipes @_default: @@ -58,44 +58,44 @@ test: # ------------------------------------------------------------------------------ # 󰏖 Create pod -# Behavior can be changed using the `run_backend_locally` recipe variable +# Behavior can be changed using the `run_server_locally` recipe variable [group("podman")] @create-pod: podman pod exists {{ pod_name }} || \ podman pod create \ --name {{ pod_name }} \ - {{ backend_port }} \ + {{ server_port }} \ -p 5432:5432 -# 󰏖 Build the backend container image +# 󰏖 Build the server container image [group("podman")] -build-backend: - @podman build -t sigo-fullstack . +build-server: + @podman build -t sigo-server . #  Starts the PostgreSQL database inside the pod [group("podman")] @init-database: create-pod podman run -d \ --pod {{ pod_name }} \ - --name postgres-database \ + --name db \ {{ pg_env }} \ {{ pg_health_cmd }} {{ pg_health_conf }} {{ pg_health_start_period }} \ {{ pg_volume }} \ {{ pg_image }} -#  Starts the backend application +#  Starts the server [group("podman")] -@init-backend: create-pod build-backend +@init-server: create-pod build-server podman run -d \ --pod {{ pod_name }} \ - --name backend \ + --name server \ -e DATABASE_URL -e SECRET_KEY \ - sigo-fullstack + sigo-server -#  Starts the full stack +#  Starts the server and database [group("podman")] -up: init-database init-backend +up: init-database init-server @echo {{ GREEN }}"Listening on http://0.0.0.0:8000"{{ NORMAL }} #  Starts only the database