Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions components/work/AwardProposalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export function AwardProposalCard({
grantOpen,
fundraise,
});
const funder = linkedGrant.organization.trim();
const headline =
phase === 'none'
? formatCurrency({
Expand Down Expand Up @@ -108,12 +107,7 @@ export function AwardProposalCard({
key: 'awarded',
label: 'Awarded',
date: awardedDate,
// Only a named funder says anything the step doesn't already.
detail: awarded
? funder && `From ${funder}`
: stillOpen
? funder && `${funder} picks who wins the prize once results are posted.`
: 'The prize has closed',
detail: !awarded && !stillOpen ? 'The prize has closed' : undefined,
done: awarded,
disabled: !awarded && !stillOpen,
},
Expand Down
39 changes: 2 additions & 37 deletions components/work/LinkedRfpCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,27 @@ import { DocumentThumbnail } from '@/components/Funding/dashboard/DocumentThumbn
import { isAwardMechanism } from '@/components/Funding/lib/fundingMechanism';
import { SidebarCard } from '@/components/ui/SidebarCard';
import { getLinkedGrantLink } from '@/components/work/lib/linkedGrant';
import { useCurrencyPreference } from '@/contexts/CurrencyPreferenceContext';
import { useExchangeRate } from '@/contexts/ExchangeRateContext';
import type { Work } from '@/types/work';
import { formatCurrencyAmount } from '@/utils/currency';
import { pluralizeSuffix } from '@/utils/stringUtils';
import { cn } from '@/utils/styles';

/**
* The RFP a proposal answers, in its sidebar under the funding card: the RFP's
* image, name, funder and amount, whether it is still open and how many
* proposals it has. The whole row opens the RFP.
* image, name and funder, kept short on purpose. The whole row opens the RFP.
*/
export function LinkedRfpCard({ work }: { work: Work }) {
const { showUSD } = useCurrencyPreference();
const { exchangeRate } = useExchangeRate();
const grant = work.linkedGrant;
const { title, href } = getLinkedGrantLink(work);
if (!grant || !title) return null;

const isPrize = isAwardMechanism(grant.fundingMechanism);
const isOpen = grant.status === 'OPEN';
const count = grant.applicantCount;
const amount =
grant.fundingAmount > 0
? formatCurrencyAmount({
amount: grant.fundingAmount,
currency: grant.currency === 'USD' ? 'USD' : 'RSC',
showUSD,
exchangeRate,
shorten: true,
})
: undefined;
// The title falls back to the organization, so don't name it twice.
const funder = grant.organization.trim() !== title ? grant.organization.trim() : '';
const byline = [funder, amount].filter(Boolean).join(' · ');

const row = (
<>
<DocumentThumbnail image={grant.imageUrl} />
<span className="min-w-0 flex-1 text-[13px] leading-[18px]">
<span className="line-clamp-2 font-semibold text-gray-900">{title}</span>
{byline && <span className="mt-0.5 block truncate text-gray-500">{byline}</span>}
<span className="mt-0.5 flex items-center gap-1.5 text-gray-500">
<span
aria-hidden="true"
className={cn('h-1.5 w-1.5 rounded-full', isOpen ? 'bg-emerald-500' : 'bg-gray-400')}
/>
{isOpen ? 'Open' : 'Closed'}
{count > 0 && (
<>
<span aria-hidden="true">·</span>
{count} {isPrize ? 'competitor' : 'proposal'}
{pluralizeSuffix(count)}
</>
)}
</span>
{funder && <span className="mt-0.5 block truncate text-gray-500">{funder}</span>}
</span>
</>
);
Expand Down