Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

1.2 KB
Raw Blame
import {Event} from "../../../types.ts";
import {Badge} from "@mantine/core";
import {t} from "@lingui/macro";

interface EventLifecycleStatusLabelProps {
    event: Event;
    showLifecycleStatus?: boolean;
}

export const EventStatusBadge = ({event, showLifecycleStatus = true}: EventLifecycleStatusLabelProps) => {
    const getLifecycleStatus = (() => {
        switch (event.lifecycle_status) {
            case 'ENDED':
                return t`Ended`;
            case 'UPCOMING':
                return t`Upcoming`;
            case 'ONGOING':
                return t`Ongoing`;
            default:
                return undefined;
        }
    })();

    return (
        <>
            <Badge
                variant={'outline'}
                color={event?.status === 'LIVE' ? 'green' : (event?.status === 'DRAFT' || event?.status === 'PENDING_MANUAL_REVIEW') ? 'orange' : 'gray'}
                size="sm"
            >
                {event.status === 'PENDING_MANUAL_REVIEW' ? t`PENDING REVIEW` : event.status} {showLifecycleStatus && (
                <>
                    &bull; {getLifecycleStatus}
                </>
            )}
            </Badge>
        </>
    );
}