Skip to content

Commit 01468e0

Browse files
committed
hide buttons based on current_user
1 parent 35a2c6b commit 01468e0

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

lib/algora_web/live/contract_live.ex

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,25 @@ defmodule AlgoraWeb.ContractLive do
329329
</div>
330330
</div>
331331
<%= if transaction = Enum.find(@transactions, fn tx -> tx.type == :charge and tx.status == :requires_capture end) do %>
332-
<.button
333-
phx-click="accept_contract"
334-
phx-disable-with="Accepting..."
335-
phx-value-tx_id={transaction.id}
336-
>
337-
Accept contract
338-
</.button>
332+
<%= if @current_user && @current_user.id == @contractor.id do %>
333+
<.button
334+
phx-click="accept_contract"
335+
phx-disable-with="Accepting..."
336+
phx-value-tx_id={transaction.id}
337+
>
338+
Accept contract
339+
</.button>
340+
<% else %>
341+
<.badge variant="warning" class="mb-auto">
342+
Offer sent
343+
</.badge>
344+
<% end %>
345+
<% end %>
346+
347+
<%= if _transaction = Enum.find(@transactions, fn tx -> tx.type == :debit end) do %>
348+
<.badge variant="success" class="mb-auto">
349+
Active
350+
</.badge>
339351
<% end %>
340352
</div>
341353
</.card_content>
@@ -352,7 +364,7 @@ defmodule AlgoraWeb.ContractLive do
352364
</div>
353365
</.card_content>
354366
</.card>
355-
<.card :if={length(@transactions) == 0}>
367+
<.card :if={length(@transactions) == 0 and @can_create_bounty}>
356368
<.card_header>
357369
<.card_title>
358370
Finalize offer
@@ -392,7 +404,7 @@ defmodule AlgoraWeb.ContractLive do
392404
</div>
393405
</dt>
394406
</div>
395-
<.button :if={@can_create_bounty} phx-click="reward">
407+
<.button phx-click="reward">
396408
Authorize
397409
</.button>
398410
</dl>
@@ -422,7 +434,10 @@ defmodule AlgoraWeb.ContractLive do
422434
</thead>
423435
<tbody class="divide-y divide-border">
424436
<%= for transaction <- @transactions do %>
425-
<tr class="hover:bg-muted/50">
437+
<tr
438+
:if={@can_create_bounty or transaction.status != :requires_release}
439+
class="hover:bg-muted/50"
440+
>
426441
<td class="whitespace-nowrap px-6 py-4 text-sm">
427442
<div :if={@timezone}>
428443
{Util.timestamp(transaction.inserted_at, @timezone)}

0 commit comments

Comments
 (0)