defmodule PokemonCoutureWeb.Components.ClothesComponent do use Phoenix.LiveComponent alias PokemonCouture.Shops def mount(socket) do {:ok, socket} end def render(assigns) do ~L""" <%= @clothes.name %> <%= @clothes.color %> <%= @clothes.game %> """ end def handle_event("toggle-active", _value, socket) do new_clothes = if socket.assigns.user in socket.assigns.clothes.users do Shops.remove_owner(socket.assigns.clothes, socket.assigns.user) else Shops.add_owner(socket.assigns.clothes, socket.assigns.user) end socket = assign(socket, :clothes, new_clothes) {:noreply, socket} end end