import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useCallback } from "react";
import { ClickableText } from "..";
import { getInitials } from "../../utils";
import "./style.scss";
const CreatedByUserDisplay = ({ campaign, }) => {
    return (_jsxs("span", { children: ["Created by", " ", _jsxs("span", { className: "tribeMember", children: [_jsx("h1", { className: "initials", children: getInitials(campaign.username) }), _jsx("span", { children: _jsx("p", { children: campaign.username }) })] })] }));
};
const ScheduleDateDisplay = ({ date, isPaused, }) => {
    const scheduledDate = new Date(date);
    const getFormatedDate = useCallback(() => {
        const day = scheduledDate.getDate();
        const monthNames = [
            "January",
            "February",
            "March",
            "April",
            "May",
            "June",
            "July",
            "August",
            "September",
            "October",
            "November",
            "December",
        ];
        const month = monthNames[scheduledDate.getMonth()];
        return `${day} ${month}`;
    }, [scheduledDate]);
    return (_jsxs("span", { className: "schedule--text", children: ["Scheduled for ", getFormatedDate(), isPaused ? ". Campaign paused" : ""] }));
};
const ProspectCampaign = ({ campaign, onCampaignClick, }) => {
    const isCurrentUserCampaign = campaign.campaignUserId === campaign.currentUserId;
    const isCampaignScheduled = !!campaign?.scheduled;
    return (_jsxs("div", { className: "prospect--campaign--container", children: [_jsxs("div", { className: "header", children: [_jsx("span", { children: "Campaign" }), isCurrentUserCampaign && (_jsx(ClickableText, { colorVariant: "gray", sizeVariant: "sm", text: "View", onClick: onCampaignClick }))] }), (!isCurrentUserCampaign || isCampaignScheduled) && (_jsxs("p", { children: [isCampaignScheduled && campaign?.scheduled?.date && (_jsx(ScheduleDateDisplay, { date: campaign.scheduled.date, isPaused: campaign.scheduled.isPaused })), isCampaignScheduled && campaign?.scheduled?.date && !isCurrentUserCampaign ? ", " : "", !isCurrentUserCampaign && (_jsx(CreatedByUserDisplay, { campaign: campaign }))] }))] }));
};
export default ProspectCampaign;
