|
|
|
@ -2,12 +2,16 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.BookSearch do
|
|
|
|
|
use Phoenix.Component
|
|
|
|
|
use DecentralisedBookIndexWeb, :verified_routes
|
|
|
|
|
|
|
|
|
|
alias DecentralisedBookIndex.Accounts.Role
|
|
|
|
|
|
|
|
|
|
attr :search_query, :string, default: ""
|
|
|
|
|
attr :search_mode, :string, default: "title"
|
|
|
|
|
attr :search_mode_options, :list, required: true
|
|
|
|
|
attr :select_options, :list, required: true
|
|
|
|
|
attr :selected_option, :string, required: true
|
|
|
|
|
|
|
|
|
|
attr :current_user, :map, default: nil
|
|
|
|
|
|
|
|
|
|
def book_search(assigns) do
|
|
|
|
|
~H"""
|
|
|
|
|
<div class="relative bg-white shadow-md dark:bg-gray-800 sm:rounded-lg">
|
|
|
|
@ -26,6 +30,7 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.BookSearch do
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-col items-stretch justify-end flex-shrink-0 w-full space-y-2 md:w-auto md:flex-row md:space-y-0 md:items-center md:space-x-3">
|
|
|
|
|
<%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
|
|
|
|
|
<.link patch={~p"/books/new"}>
|
|
|
|
|
<button type="button" class="flex items-center justify-center px-4 py-2 text-sm font-medium text-black dark:text-white rounded-lg bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 dark:bg-primary-600 dark:hover:bg-primary-700 focus:outline-none dark:focus:ring-primary-800">
|
|
|
|
|
<svg class="h-3.5 w-3.5 mr-2" fill="currentColor" viewbox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
|
|
@ -34,6 +39,7 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.BookSearch do
|
|
|
|
|
Add book
|
|
|
|
|
</button>
|
|
|
|
|
</.link>
|
|
|
|
|
<% end %>
|
|
|
|
|
<.dropdown_settings
|
|
|
|
|
search_mode={@search_mode}
|
|
|
|
|
search_mode_options={@search_mode_options}
|
|
|
|
|