Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

2.0 KB
Raw Blame
<script setup lang="ts">
import { IconAlertTriangle, IconRefresh } from '@tabler/icons-vue';
import { computed } from 'vue';

import type { ChannelAccount } from '@/types/channel';
import type { Repurpose } from '@/types/repurpose';
import { RepurposeHealth, type RepurposeHealthValue, RepurposeStatus } from '@/types/repurpose-status';
import { SocialAccountStatus } from '@/types/social-account-status';

const props = defineProps<{
    repurpose: Repurpose;
    accounts: ChannelAccount[];
}>();

const state = computed<RepurposeHealthValue | null>(() => {
    if (props.repurpose.status !== RepurposeStatus.Paused || props.repurpose.paused_reason === null) {
        return null;
    }

    if (!props.repurpose.source_social_account_id) {
        return RepurposeHealth.SourceMissing;
    }

    const source = props.accounts.find((account) => account.id === props.repurpose.source_social_account_id);

    if (!source || source.status !== SocialAccountStatus.Connected) {
        return RepurposeHealth.SourceUnusable;
    }

    const usable = props.repurpose.destinations.filter((destination) => {
        const account = props.accounts.find((item) => item.id === destination.social_account_id);

        return account !== undefined;
    });

    return usable.length === 0 ? RepurposeHealth.NoDestinations : RepurposeHealth.Ready;
});
</script>

<template>
    <div
        v-if="state"
        data-testid="repurpose-health-banner"
        :class="[
            'flex items-start gap-3 rounded-lg border px-4 py-3 text-sm',
            state === RepurposeHealth.Ready
                ? 'border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-400'
                : 'border-amber-500/30 bg-amber-500/5 text-amber-700 dark:text-amber-400',
        ]"
    >
        <component :is="state === RepurposeHealth.Ready ? IconRefresh : IconAlertTriangle" class="mt-0.5 size-4 shrink-0" />

        <p class="leading-relaxed">
            {{ $t(`repurposes.health.${state}`) }}
        </p>
    </div>
</template>