{% comment %} Single connected account card - HTMX-swappable. Usage: {% include "social_accounts/partials/_account_card.html" with account=account workspace_id=workspace_id %} {% endcomment %} {% load social_accounts_tags %}
{% if account.avatar_url %} {{ account.account_name|default:account.account_handle }} {% else %}
{% include "social_accounts/partials/_platform_icon.html" with platform=account.platform size="5" %}
{% endif %}

{{ account.account_name|default:account.account_handle }}

{% include "social_accounts/partials/_platform_icon.html" with platform=account.platform size="4" %}
{% if account.account_handle %}

@{{ account.account_handle|cut:"@" }}

{% endif %}
{% include "social_accounts/partials/_status_badge.html" with status=account.connection_status error=account.last_error %} {% if account.follower_count %} {{ account.follower_count|format_number }} followers {% endif %}
{% if account.needs_reconnect %}
{% csrf_token %}
{% endif %}

Disconnect {{ account.account_name|default:account.account_handle }}?

{% comment %} Say what disconnect really does; the privacy policy promises it and platform reviewers read this against the policy. Only claim a revocation the provider performs. The Facebook-Page flows drop our copy of the credentials but cannot revoke the grant, because the only endpoint that would do so revokes this app for the whole person and would sever their other connected accounts. {% endcomment %}

{% if account.revokes_platform_grant_on_disconnect %} This revokes Redea Social's access to the account. {% elif account.keeps_platform_grant_on_disconnect %} This removes the account from Redea Social only. To revoke our access entirely, remove Redea Social in Facebook › Settings › Apps and Websites. {% else %} This removes the account from Redea Social only. To revoke our access entirely, remove Redea Social in your {{ account.get_platform_display }} settings. {% endif %}

Its analytics, inbox messages and posts made only for it are deleted from Redea Social. Posts shared with other channels stay.

{% csrf_token %}
{% comment %} Meta drops permissions it has not approved, or that the user declined, without failing the grant — so the connection reports healthy and only breaks later, at publish or insights time, with an opaque platform error. Naming them here turns that into something the user can act on. {% endcomment %} {% if account.missing_scopes %}

Some features are unavailable. This account was connected without {{ account.missing_scopes|join:", " }}. Anything relying on them will fail until the permission is granted — reconnect to try again.

{% endif %} {% if account.last_error and account.connection_status == "error" %}

{{ account.last_error }}

{% endif %} {% comment %} The connection is healthy enough to publish and report, and comments still reach the inbox via the polling cycle — but without the subscription they arrive minutes late instead of instantly, which is worth saying rather than letting the account look untouched. Every failure here offers a way out: "Try again" re-runs the call, and a grant that can never satisfy it offers Reconnect instead. Suppressed entirely once the *connection* is broken. A dead token can't carry a subscription, so "Try again" there would be a button that provably does nothing; the card already shows the connection error and its own Reconnect, which is the only thing that helps. ``retry_webhooks`` refuses the same accounts, so the two never disagree about what is on offer. {% endcomment %} {% if account.webhooks_active is False and not account.needs_reconnect %}

Real-time comments are off. {{ account.webhook_error|default:"We couldn't set up real-time updates for this account." }} New comments still reach the inbox, but can take a few minutes to appear.

{% if account.webhook_needs_reconnect %}
{% csrf_token %}
{% else %} {% comment %} method/action as well as hx-post: without them a browser that never ran htmx falls back to the form default — GET to the current URL, which puts the CSRF token in the query string and retries nothing. @htmx:after-request re-enables the button when a request fails, since htmx only swaps this card away on success. {% endcomment %}
{% csrf_token %}
{% endif %}
{% endif %} {% if account.connection_status == "connected" %}

Posting Schedule

Set recurring time slots for when queued posts are automatically published.

{% include "social_accounts/partials/_posting_slots_grid.html" with account=account workspace_id=workspace_id %}
{% endif %}