-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Gaurav1924/SigninErrorFixed
Signin error fixed
- Loading branch information
Showing
15 changed files
with
11,278 additions
and
34 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.button-link { | ||
display: inline-flex; | ||
text-decoration: none; | ||
} | ||
|
||
.edit-button { | ||
background-color: #4a90e2; | ||
color: white; | ||
padding: 0.5rem 1rem; | ||
border-radius: 0.375rem; | ||
font-weight: bold; | ||
transition: background-color 0.3s ease; | ||
} | ||
|
||
.edit-button:hover { | ||
background-color: #357abd; | ||
} | ||
|
||
.text-blue-600 { | ||
color: #1d4ed8; | ||
} | ||
|
||
.text-blue-600:hover { | ||
color: #1e40af; | ||
} | ||
|
||
.sr-only { | ||
position: absolute; | ||
width: 1px; | ||
height: 1px; | ||
margin: -1px; | ||
padding: 0; | ||
overflow: hidden; | ||
clip: rect(0, 0, 0, 0); | ||
border: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,55 @@ | ||
<header class="px-4 sm:px-6 lg:px-8"> | ||
<div class="flex items-center justify-between border-b border-zinc-100 py-3 text-sm"> | ||
<div class="flex items-center gap-4"> | ||
<a href="/"> | ||
Polly | ||
</a> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Polly</title> | ||
<link rel="stylesheet" href="/assets/css/styles.css"> | ||
</head> | ||
<body> | ||
<header class="px-4 sm:px-6 lg:px-8"> | ||
<div class="flex items-center justify-between border-b border-zinc-100 py-3 text-sm"> | ||
<div class="flex items-center gap-4"> | ||
<a href="/" class="font-bold text-lg"> | ||
Polly | ||
</a> | ||
</div> | ||
<div class="flex items-center gap-4 font-semibold leading-6 text-zinc-900"> | ||
<%= if assigns[:current_user] do %> | ||
<.link href={~p"/username/log_out"} method="delete" class="text-blue-600 hover:underline"> | ||
<%= assigns[:current_user] %> | ||
</.link> | ||
<% else %> | ||
<.link navigate={~p"/username/log_in"} class="text-blue-600 hover:underline"> | ||
Sign In | ||
</.link> | ||
<% end %> | ||
</div> | ||
</div> | ||
<div class="flex items-center gap-4 font-semibold leading-6 text-zinc-900"> | ||
<%= if assigns[:current_user] do %> | ||
<.link href={~p"/username/log_out"} method="delete"> | ||
<%= assigns[:current_user] %> | ||
</.link> | ||
<% else %> | ||
<.link navigate={~p"/username/log_in"}> | ||
Sign In | ||
</.link> | ||
<% end %> | ||
</header> | ||
|
||
<main class="px-4 py-20 sm:px-6 lg:px-8"> | ||
<div class="mx-auto max-w-2xl"> | ||
<.flash_group flash={@flash} /> | ||
|
||
<!-- Action Buttons --> | ||
<div class="action-buttons flex gap-4 mt-6"> | ||
<%= if assigns[:polls] do %> | ||
<%= for {_id, poll} <- @polls do %> | ||
<div class="flex items-center gap-4"> | ||
<.link navigate={~p"/polls/#{poll.id}/edit"} class="button-link"> | ||
<.button class="edit-button">Edit</.button> | ||
</.link> | ||
<div class="sr-only"> | ||
<.link navigate={~p"/polls/#{poll.id}"} class="text-blue-600 hover:underline"> | ||
Show | ||
</.link> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= @inner_content %> | ||
</div> | ||
</div> | ||
</div> | ||
</header> | ||
<main class="px-4 py-20 sm:px-6 lg:px-8"> | ||
<div class="mx-auto max-w-2xl"> | ||
<.flash_group flash={@flash} /> | ||
<%= @inner_content %> | ||
</div> | ||
</main> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
defmodule PollyWeb.PollLive.Edit do | ||
use PollyWeb, :live_view | ||
|
||
alias Polly.Polls | ||
alias Polly.Schema.Poll | ||
|
||
@impl true | ||
def mount(_params, _session, socket) do | ||
{:ok, assign(socket, :page_title, "Edit Poll")} | ||
end | ||
|
||
@impl true | ||
def handle_params(%{"id" => id}, _, socket) do | ||
poll = Polls.get_poll!(id) | ||
changeset = Polls.change_poll(poll) | ||
{:noreply, assign(socket, poll: poll, changeset: changeset)} | ||
end | ||
|
||
@impl true | ||
def handle_event("save", %{"poll" => poll_params}, socket) do | ||
case Polls.update_poll(socket.assigns.poll, poll_params) do | ||
{:ok, poll} -> | ||
{:noreply, | ||
socket | ||
|> put_flash(:info, "Poll updated successfully") | ||
|> push_redirect(to: Routes.poll_index_path(socket, :index))} | ||
|
||
{:error, %Ecto.Changeset{} = changeset} -> | ||
{:noreply, assign(socket, :changeset, changeset)} | ||
end | ||
end | ||
|
||
def render(assigns) do | ||
~H""" | ||
<.header> | ||
Edit Poll | ||
</.header> | ||
<.simple_form | ||
for={@changeset} | ||
id="poll-form" | ||
phx-target={@myself} | ||
phx-submit="save" | ||
> | ||
<.input field={@changeset[:title]} type="text" label="Title" /> | ||
<.input field={@changeset[:description]} type="textarea" label="Description" /> | ||
<fieldset> | ||
<legend>Options</legend> | ||
<%= hidden_input(@changeset, :options, value: "[]") %> | ||
<%= for f_option <- inputs_for(@changeset, :options) do %> | ||
<div class="m-4"> | ||
<%= hidden_inputs_for(f_option) %> | ||
<.input field={f_option[:text]} type="text" /> | ||
</div> | ||
<% end %> | ||
<.button id="add-option" type="button" phx-click="add-option" phx-target={@myself}> | ||
Add | ||
</.button> | ||
</fieldset> | ||
<:actions> | ||
<.button phx-disable-with="Saving...">Save Poll</.button> | ||
</:actions> | ||
</.simple_form> | ||
""" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.