dotfiles/app/lib/prymn_web/components/create_app.ex
2023-11-23 15:45:33 +02:00

78 lines
2.6 KiB
Elixir

defmodule PrymnWeb.CreateApp do
use PrymnWeb, :live_component
@impl true
def render(assigns) do
~H"""
<div class="mx-auto max-w-2xl">
<fieldset>
<legend class="mb-6 border-b border-slate-200 pb-2 text-base font-semibold">App Type</legend>
<span>
<input
id="wordpress"
type="radio"
name="app_type"
value="wordpress"
class="peer hidden"
checked={@app_type == "wordpress"}
/>
<label
for="wordpress"
class="inline-block cursor-pointer rounded p-5 shadow peer-checked:bg-black peer-checked:text-white"
phx-click={JS.patch(~p"/apps/new?app_type=wordpress")}
>
WordPress
</label>
</span>
<span>
<input
id="plain_html"
type="radio"
name="app_type"
value="plain_html"
class="peer hidden"
checked={@app_type == "plain_html"}
/>
<label
for="plain_html"
class="inline-block cursor-pointer rounded p-5 shadow peer-checked:bg-black peer-checked:text-white"
phx-click={JS.patch(~p"/apps/new?app_type=plain_html")}
>
Plain HTML
</label>
</span>
</fieldset>
<.wordpress_app_form :if={assigns.app_type == "wordpress"} servers={assigns[:servers]} />
</div>
"""
end
defp wordpress_app_form(assigns) do
~H"""
<.simple_form id="test" for={nil}>
<.input
:if={assigns.servers != nil}
id="server"
type="select"
name="server"
prompt="Select a server to host this app..."
options={[]}
value={nil}
label="Hosting Server"
/>
<.input id="name" type="text" name="app_name" value={nil} label="WordPress Site Name" required />
<.input id="domain" type="text" name="domain" value={nil} label="Domain Name" required />
<.input type="checkbox" name="create_database?" label="Create a new database?" />
<.input type="text" name="db_name" value={nil} label="Database name" />
<.input type="select" name="db_name" value={nil} options={["db1", "db2"]} label="Database" />
<.input type="text" name="admin_username" value={nil} label="Admin Username" />
<.input type="email" name="admin_email" value={nil} label="Admin Email" />
<.input type="password" name="admin_password" value={nil} label="Admin Password" />
<Button.primary type="submit">Create</Button.primary>
</.simple_form>
"""
end
end