import re

with open("apps/wallet_web/lib/wallet_web/live/admin/user_management_live/index.ex", "r") as f:
    content = f.read()

# Revert button to simple phx-click
old_btn = r'<button phx-click=\{JS\.push\("open_new_user"\) \|> show_modal\("new-user-modal"\)\} class="rounded-lg bg-zinc-900 text-white px-4 py-2 text-sm font-medium shadow-sm hover:bg-zinc-800">'
new_btn = '<button phx-click="open_new_user" class="rounded-lg bg-zinc-900 text-white px-4 py-2 text-sm font-medium shadow-sm hover:bg-zinc-800">'
content = re.sub(old_btn, new_btn, content)

# Revert 'cancel' button inside modal
old_cancel = r'<button type="button" phx-click=\{JS\.push\("close_new_user"\) \|> hide_modal\("new-user-modal"\)\} class="px-4 py-2 text-sm font-medium text-zinc-700 bg-white border border-zinc-300 rounded-lg shadow-sm hover:bg-zinc-50">'
new_cancel = '<button type="button" phx-click="close_new_user" class="px-4 py-2 text-sm font-medium text-zinc-700 bg-white border border-zinc-300 rounded-lg shadow-sm hover:bg-zinc-50">'
content = re.sub(old_cancel, new_cancel, content)

with open("apps/wallet_web/lib/wallet_web/live/admin/user_management_live/index.ex", "w") as f:
    f.write(content)

