mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-04-11 18:28:15 +00:00
Replace all @untitledui/icons imports across 55 files with equivalent
@fortawesome/pro-duotone-svg-icons icons, using FontAwesomeIcon wrappers
(FC<{ className?: string }>) for prop-based usage and inline replacements
for direct JSX usage. Drops unsupported Untitled UI-specific props
(strokeWidth, numeric size). TypeScript compiles clean with no errors.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
108 lines
4.7 KiB
TypeScript
108 lines
4.7 KiB
TypeScript
import type { FC } from 'react';
|
|
import { useNavigate } from 'react-router';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
import { faArrowLeft, faArrowUpRightFromSquare } from '@fortawesome/pro-duotone-svg-icons';
|
|
|
|
const ArrowLeft: FC<{ className?: string }> = ({ className }) => <FontAwesomeIcon icon={faArrowLeft} className={className} />;
|
|
const LinkExternal01: FC<{ className?: string }> = ({ className }) => <FontAwesomeIcon icon={faArrowUpRightFromSquare} className={className} />;
|
|
|
|
import { Button } from '@/components/base/buttons/button';
|
|
import { CampaignStatusBadge } from '@/components/shared/status-badge';
|
|
import type { Campaign } from '@/types/entities';
|
|
|
|
interface CampaignHeroProps {
|
|
campaign: Campaign;
|
|
}
|
|
|
|
const formatDateRange = (startDate: string | null, endDate: string | null): string => {
|
|
const fmt = (d: string) =>
|
|
new Intl.DateTimeFormat('en-IN', { month: 'short', day: 'numeric', year: 'numeric' }).format(new Date(d));
|
|
|
|
if (!startDate) return '--';
|
|
if (!endDate) return `${fmt(startDate)} \u2014 Ongoing`;
|
|
return `${fmt(startDate)} \u2014 ${fmt(endDate)}`;
|
|
};
|
|
|
|
const formatDuration = (startDate: string | null, endDate: string | null): string => {
|
|
if (!startDate) return '--';
|
|
|
|
const start = new Date(startDate);
|
|
const end = endDate ? new Date(endDate) : new Date();
|
|
const diffDays = Math.ceil((end.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
|
|
|
|
return `${diffDays} days`;
|
|
};
|
|
|
|
export const CampaignHero = ({ campaign }: CampaignHeroProps) => {
|
|
const navigate = useNavigate();
|
|
|
|
return (
|
|
<div className="border-b border-secondary bg-primary px-7 py-6">
|
|
{/* Back button */}
|
|
<button
|
|
onClick={() => navigate('/campaigns')}
|
|
className="mb-4 flex items-center gap-1.5 text-sm text-tertiary transition hover:text-secondary cursor-pointer"
|
|
>
|
|
<ArrowLeft className="size-4" />
|
|
<span>Back to Campaigns</span>
|
|
</button>
|
|
|
|
{/* Title row */}
|
|
<div className="flex flex-wrap items-start justify-between gap-4">
|
|
<div className="min-w-0 flex-1">
|
|
<h1 className="text-display-xs font-bold text-primary">
|
|
{campaign.campaignName ?? 'Untitled Campaign'}
|
|
</h1>
|
|
|
|
<div className="mt-2 flex flex-wrap items-center gap-2 text-sm text-tertiary">
|
|
<span>{campaign.externalCampaignId ?? campaign.id.slice(0, 12)}</span>
|
|
<span className="text-quaternary">·</span>
|
|
<span>{formatDateRange(campaign.startDate, campaign.endDate)}</span>
|
|
</div>
|
|
|
|
{/* Badges */}
|
|
<div className="mt-3 flex flex-wrap items-center gap-2">
|
|
{campaign.platform && (
|
|
<span className="rounded-lg bg-secondary px-2 py-0.5 text-xs font-medium text-secondary">
|
|
{campaign.platform}
|
|
</span>
|
|
)}
|
|
{campaign.campaignType && (
|
|
<span className="rounded-lg bg-secondary px-2 py-0.5 text-xs font-medium text-secondary">
|
|
{campaign.campaignType.replace(/_/g, ' ')}
|
|
</span>
|
|
)}
|
|
{campaign.campaignStatus && <CampaignStatusBadge status={campaign.campaignStatus} />}
|
|
<span className="rounded-lg bg-brand-primary_alt px-2 py-0.5 text-xs font-medium text-brand-secondary">
|
|
{formatDuration(campaign.startDate, campaign.endDate)}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Actions */}
|
|
<div className="flex shrink-0 items-center gap-2">
|
|
{campaign.platformUrl && (
|
|
<Button
|
|
color="secondary"
|
|
size="sm"
|
|
iconTrailing={LinkExternal01}
|
|
href={campaign.platformUrl}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
>
|
|
View on Platform
|
|
</Button>
|
|
)}
|
|
<Button
|
|
color="primary"
|
|
size="sm"
|
|
href={`/leads`}
|
|
>
|
|
View Leads
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|