Skip to content

Commit 929d758

Browse files
feat: unlimited attendees
1 parent ca3e7ef commit 929d758

38 files changed

Lines changed: 458 additions & 452 deletions

File tree

lib/atomic_web/components/image_uploader.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ defmodule AtomicWeb.Components.ImageUploader do
2121
<%= if @image do %>
2222
<div class="flex flex-col place-items-center">
2323
<img class="p-4" src={@image} />
24-
<span class="text-sm text-orange-500 cursor-pointer hover:text-red-800">Click to upload new image</span>
24+
<span class="cursor-pointer text-sm text-orange-500 hover:text-red-800">Click to upload new image</span>
2525
<p class="text-xs text-zinc-500">(PNG, JPG, GIF up to 10MB)</p>
2626
</div>
2727
<% else %>
2828
<article class="h-full w-full">
2929
<figure class="flex h-full items-center justify-center">
3030
<div class="flex h-full w-full place-items-center rounded-md border-2 border-dashed border-zinc-300">
31-
<div class="flex place-items-center justify-center h-full mx-auto sm:col-span-6 lg:w-full">
31+
<div class="mx-auto flex h-full place-items-center justify-center sm:col-span-6 lg:w-full">
3232
<div class="my-[140px] flex justify-center px-6">
3333
<div class="space-y-1 text-center">
3434
<svg class="size-12 mx-auto text-zinc-400" stroke="currentColor" fill="none" viewBox="0 0 48 48" aria-hidden="true">
@@ -53,9 +53,9 @@ defmodule AtomicWeb.Components.ImageUploader do
5353
<%= if @uploads.image.entries do %>
5454
<%= for entry <- @uploads.image.entries do %>
5555
<%= for err <- upload_errors(@uploads.image, entry) do %>
56-
<div class="flex justify-center">
57-
<p class="alert alert-danger text-orange-500"><%= Phoenix.Naming.humanize(err) %></p>
58-
</div>
56+
<div class="flex justify-center">
57+
<p class="alert alert-danger text-orange-500"><%= Phoenix.Naming.humanize(err) %></p>
58+
</div>
5959
<% end %>
6060
<article class="upload-entry">
6161
<figure class="">
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<.page title="Edit Activity">
2-
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
2+
<div class="mx-auto max-w-5xl px-4 sm:px-6 lg:px-8">
33
<.live_component module={AtomicWeb.ActivityLive.FormComponent} id={@activity.id} title={@page_title} action={@live_action} activity={@activity} current_organization={@activity.organization} return_to={~p"/activities/#{@activity.id}"} />
44
</div>
55
</.page>

lib/atomic_web/live/activity_live/form_component.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ defmodule AtomicWeb.ActivityLive.FormComponent do
2424
|> assign_form(changeset)
2525
|> assign(:description_modal, false)
2626
|> assign(:maximum_entries_modal, false)
27-
|> assign(:has_max_capacity?, true)
27+
|> assign(:has_max_capacity?, activity.maximum_entries)
2828
|> assign(:has_description?, initial_description)
2929
|> allow_upload(:image, accept: Uploaders.Post.extension_whitelist(), max_entries: 1)}
3030
end
3131

3232
@impl true
3333
def handle_event("validate", %{"activity" => activity_params}, socket) do
3434
description = Map.get(activity_params, "description", "")
35+
capacity = Map.get(activity_params, "max_entries", "")
3536
has_description = is_nil(description) || String.trim(description) == ""
37+
has_capacity = is_nil(capacity) || String.trim(capacity) == ""
3638

3739
changeset =
3840
socket.assigns.activity
@@ -42,6 +44,7 @@ defmodule AtomicWeb.ActivityLive.FormComponent do
4244
{:noreply,
4345
socket
4446
|> assign(:has_description?, not has_description)
47+
|> assign(:has_max_capacity?, has_capacity)
4548
|> assign_form(changeset)}
4649
end
4750

@@ -75,9 +78,10 @@ defmodule AtomicWeb.ActivityLive.FormComponent do
7578

7679
@impl true
7780
def handle_event("remove_max_capacity", _, socket) do
78-
{:noreply, socket
79-
|> assign(:has_max_capacity?, false)
80-
|> assign(:maximum_entries_modal, not socket.assigns.maximum_entries_modal)}
81+
{:noreply,
82+
socket
83+
|> assign(:has_max_capacity?, false)
84+
|> assign(:maximum_entries_modal, not socket.assigns.maximum_entries_modal)}
8185
end
8286

8387
defp save_activity(socket, :new, activity_params) do

lib/atomic_web/live/activity_live/form_component.html.heex

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@
2323
</div>
2424
</div>
2525
<div class="flex w-full">
26-
<div class="justify-top flex flex-col items-center pt-3 hidden sm:block">
26+
<div class="justify-top flex hidden flex-col items-center pt-3 sm:block">
2727
<div class="size-3 bg-primary-600 m-1 rounded-full" />
2828
<div class="flex justify-center">
29-
<div class="border-l-primary-600 h-[3.25rem] border-l border-dashed w-[3px]" />
29+
<div class="border-l-primary-600 h-[3.25rem] w-[3px] border-l border-dashed" />
3030
</div>
3131
<div class="size-3 border-primary-600 m-1 rounded-full border" />
3232
</div>
3333
<div class="flex w-full flex-col">
34-
<div class="text-nowrap flex flex-col sm:flex-row items-baseline justify-between gap-y-1 sm:p-1 sm:pl-3">
34+
<div class="text-nowrap flex flex-col items-baseline justify-between gap-y-1 sm:flex-row sm:p-1 sm:pl-3">
3535
<span>Start</span>
3636
<div class="w-full sm:w-56">
37-
<.field class="w-full sm:w-56 atomic-button atomic-button--primary-outline text-gray-900" type="datetime-local" field={@form[:start]} label_class="hidden" error_label_class="hidden" required />
37+
<.field class="atomic-button atomic-button--primary-outline w-full text-gray-900 sm:w-56" type="datetime-local" field={@form[:start]} label_class="hidden" error_label_class="hidden" required />
3838
</div>
3939
</div>
40-
<div class="text-nowrap flex flex-col sm:flex-row items-baseline justify-between gap-y-1 sm:p-1 sm:pl-3">
40+
<div class="text-nowrap flex flex-col items-baseline justify-between gap-y-1 sm:flex-row sm:p-1 sm:pl-3">
4141
<span>End</span>
4242
<div class="w-full sm:w-56">
43-
<.field class="w-full sm:w-56 atomic-button atomic-button--primary-outline text-gray-900" type="datetime-local" field={@form[:finish]} label_class="hidden" error_label_class="hidden" required />
43+
<.field class="atomic-button atomic-button--primary-outline w-full text-gray-900 sm:w-56" type="datetime-local" field={@form[:finish]} label_class="hidden" error_label_class="hidden" required />
4444
</div>
4545
</div>
4646
</div>
@@ -49,9 +49,9 @@
4949
<label for="description_button" class="atomic-label atomic-label--required">
5050
Description
5151
</label>
52-
<.button id="description_button" class="lg:w-full flex flex-col items-start px-3 py-3 border-gray-300 rounded-md bg-white text-gray-300 group atomic-button atomic-button--primary-outline focus-within:bg-white" type="button" phx-click="toggle_description_modal" phx-target={@myself}>
52+
<.button id="description_button" class="group atomic-button atomic-button--primary-outline flex flex-col items-start rounded-md border-gray-300 bg-white px-3 py-3 text-gray-300 focus-within:bg-white lg:w-full" type="button" phx-click="toggle_description_modal" phx-target={@myself}>
5353
<%= if not @has_description? do %>
54-
<label class="text-left cursor-pointer text-gray-500">
54+
<label class="cursor-pointer text-left text-gray-500">
5555
Add description
5656
</label>
5757
<% end %>
@@ -67,7 +67,7 @@
6767
autocomplete="off"
6868
error_class="text-danger-600 placeholder-danger-700"
6969
error_label_class="text-danger-700"
70-
class="text-sm p-0 bg-transparent border-none shadow-none cursor-pointer focus:outline-none focus:ring-0 focus:border-transparent text-gray-900"
70+
class="cursor-pointer border-none bg-transparent p-0 text-sm text-gray-900 shadow-none focus:border-transparent focus:outline-none focus:ring-0"
7171
/>
7272
</div>
7373
</.button>
@@ -86,14 +86,14 @@
8686
<label for="capacity_button" class="atomic-label atomic-label--required">
8787
Capacity
8888
</label>
89-
<.button id="capacity_button" type="button" class="lg:w-full flex flex-col items-start px-3 py-3 border-gray-300 rounded-md bg-white text-gray-300 group atomic-button atomic-button--primary-outline focus-within:bg-white" phx-click="toggle_maximum_entries_modal" phx-target={@myself}>
89+
<.button id="capacity_button" type="button" class="group atomic-button atomic-button--primary-outline flex flex-col items-start rounded-md border-gray-300 bg-white px-3 py-3 text-gray-300 focus-within:bg-white lg:w-full" phx-click="toggle_maximum_entries_modal" phx-target={@myself}>
9090
<%= if @has_max_capacity? do %>
9191
<.field
92-
class="text-sm p-0 bg-transparent border-none shadow-none cursor-pointer focus:outline-none focus:ring-0 focus:border-transparent text-gray-900"
92+
class="cursor-pointer border-none bg-transparent p-0 text-sm text-gray-900 shadow-none focus:border-transparent focus:outline-none focus:ring-0"
9393
type="number"
9494
field={@form[:maximum_entries]}
9595
label="Maximum entries"
96-
placeholder="Choose maximum entries"
96+
placeholder="Choose maximum capacity"
9797
readonly
9898
required
9999
label_class="hidden"
@@ -103,19 +103,19 @@
103103
/>
104104
<% else %>
105105
<.field
106-
class="text-sm p-0 bg-transparent border-none shadow-none cursor-pointer focus:outline-none focus:ring-0 focus:border-transparent text-gray-900"
107-
type="number"
108-
field={@form[:maximum_entries]}
109-
label="Maximum entries"
110-
placeholder="Unlimited"
111-
readonly
112-
value="nil"
113-
required
114-
label_class="hidden"
115-
wrapper_class="m-0"
116-
error_class="text-danger-600 placeholder-danger-700"
117-
error_label_class="text-danger-700"
118-
/>
106+
class="cursor-pointer border-none bg-transparent p-0 text-sm text-gray-900 shadow-none focus:border-transparent focus:outline-none focus:ring-0"
107+
type="number"
108+
field={@form[:maximum_entries]}
109+
label="Maximum entries"
110+
placeholder="Unlimited"
111+
value=" "
112+
readonly
113+
required
114+
label_class="hidden"
115+
wrapper_class="m-0"
116+
error_class="text-danger-600 placeholder-danger-700"
117+
error_label_class="text-danger-700"
118+
/>
119119
<% end %>
120120
</.button>
121121

@@ -135,20 +135,20 @@
135135
<.modal :if={@description_modal} id="description-modal" show on_cancel={JS.push("toggle_description_modal", target: @myself)}>
136136
<div class="mt-4 flex-grow">
137137
<.field class="\-h-10 resize-none " type="textarea" field={@form[:description]} label="Description" placeholder="Choose description" rows={15} required />
138-
<div class="w-full flex justify-end">
138+
<div class="flex w-full justify-end">
139139
<.button class="text" type="button" phx-click="toggle_description_modal" phx-target={@myself}>
140140
<span><%= gettext("Done") %></span>
141141
</.button>
142142
</div>
143143
</div>
144144
</.modal>
145145
<.modal :if={@maximum_entries_modal} id="maximum_entries_modal" show on_cancel={JS.push("toggle_maximum_entries_modal", target: @myself)}>
146-
<div class="w-full h-full">
146+
<div class="h-full w-full">
147147
<div class="">
148148
<%= if @has_max_capacity? do %>
149149
<.field class="" type="number" field={@form[:maximum_entries]} placeholder="Choose maximum entries" />
150150
<% else %>
151-
<.field class="" type="number" value="nil" field={@form[:maximum_entries]} placeholder="Unlimited"/>
151+
<.field class="" type="number" field={@form[:maximum_entries]} value="" placeholder="Unlimited" />
152152
<% end %>
153153
</div>
154154
<div class="flex gap-3">

lib/atomic_web/live/activity_live/index.html.heex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
<% end %>
88
</:actions>
99
<!-- Tabs -->
10-
<.tabs class="overflow-scroll scrollbar-hide max-w-5-xl mx-auto px-4 sm:px-6 lg:px-8">
10+
<.tabs class="scrollbar-hide max-w-5-xl mx-auto overflow-scroll px-4 sm:px-6 lg:px-8">
1111
<%= if @is_authenticated? and @has_current_organization? do %>
1212
<.link patch="?tab=organization" replace={false}>
1313
<.tab active={@current_tab == "organization"}>
14-
<.icon name="hero-globe-alt" class="h-5 w-5 mr-1" />
14+
<.icon name="hero-globe-alt" class="mr-1 h-5 w-5" />
1515
<%= @current_user.current_organization.name <> gettext("'s activities") %>
1616
</.tab>
1717
</.link>
1818
<% end %>
1919

2020
<.link patch="?tab=discover" replace={false}>
2121
<.tab active={@current_tab == "discover"}>
22-
<.icon name="hero-globe-alt" class="h-5 w-5 mr-1" />
22+
<.icon name="hero-globe-alt" class="mr-1 h-5 w-5" />
2323
<%= gettext("Discover") %>
2424
</.tab>
2525
</.link>
2626

2727
<%= if @is_authenticated? do %>
2828
<.link patch="?tab=following" replace={false}>
2929
<.tab active={@current_tab == "following"}>
30-
<.icon name="hero-eye" class="h-5 w-5 mr-1" />
30+
<.icon name="hero-eye" class="mr-1 h-5 w-5" />
3131
<%= gettext("Following") %>
3232
</.tab>
3333
</.link>
@@ -36,13 +36,13 @@
3636
<%= if @is_authenticated? do %>
3737
<.link patch="?tab=enrolled" replace={false}>
3838
<.tab active={@current_tab == "enrolled"} number={@upcoming_enrolled_count}>
39-
<.icon name="hero-ticket" class="h-5 w-5 mr-1" />
39+
<.icon name="hero-ticket" class="mr-1 h-5 w-5" />
4040
<%= gettext("Upcoming") %>
4141
</.tab>
4242
</.link>
4343
<.link patch="?tab=past" replace={false}>
4444
<.tab active={@current_tab == "past"}>
45-
<.icon name="hero-clock" class="h-5 w-5 mr-1" />
45+
<.icon name="hero-clock" class="mr-1 h-5 w-5" />
4646
<%= gettext("Past") %>
4747
</.tab>
4848
</.link>
@@ -55,15 +55,15 @@
5555
<.empty_state url={~p"/organizations/#{@current_organization}/activities/new"} placeholder="activity" />
5656
</div>
5757
<% else %>
58-
<div class="text-zinc-600 mt-32 flex flex-col items-center w-full justify-center">
58+
<div class="mt-32 flex w-full flex-col items-center justify-center text-zinc-600">
5959
<.icon class="w-24" name="hero-megaphone" />
6060
<p class="pt-4"><%= gettext("No activities to show.") %></p>
6161
<p><%= activities_empty_state_description(@current_tab) %></p>
6262
</div>
6363
<% end %>
6464
<% else %>
6565
<div class="overflow-hidden bg-white">
66-
<ul role="list" class="p-4 overflow-auto grid sm:grid-cols-2 gap-4">
66+
<ul role="list" class="grid gap-4 overflow-auto p-4 sm:grid-cols-2">
6767
<%= for activity <- @activities do %>
6868
<li id={activity.id} class={@current_tab == "past" && "opacity-70"}>
6969
<.activity_card activity={activity} />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<.page title="New Activity">
2-
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
2+
<div class="mx-auto max-w-5xl px-4 sm:px-6 lg:px-8">
33
<.live_component module={AtomicWeb.ActivityLive.FormComponent} id={:new} title={@page_title} action={@live_action} activity={@activity} current_organization={@current_organization} return_to={~p"/activities/"} />
44
</div>
55
</.page>

0 commit comments

Comments
 (0)