Catalyst / admin/Bid-Sentinel 14.8 GB / 57.8 GB 40.0 GB free
Help Sign in

admin / Bid-Sentinel

public

Bid Scrape and Tracking Application with AI Capability

Code Issues Pull requests Pipelines Packages Security Insights Wiki Settings
Bid-Sentinel / bid-sentinel-v2 / frontend / src / utils / format.js 1038 B · main
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
export function formatDate(value) {
  if (!value) return "—";
  const d = new Date(value);
  if (Number.isNaN(d.getTime())) return "—";
  return d.toLocaleDateString("en-GB", {
    day: "2-digit",
    month: "short",
    year: "numeric",
  });
}

export function formatValue(tender) {
  if (tender.value_amount != null) {
    return new Intl.NumberFormat("en-GB", {
      style: "currency",
      currency: tender.currency || "GBP",
      maximumFractionDigits: 0,
    }).format(tender.value_amount);
  }
  return tender.value_text || "—";
}

export function formatMoney(amount) {
  if (amount == null || Number.isNaN(amount)) return "£0";
  if (amount >= 1_000_000) return ${(amount / 1_000_000).toFixed(1)}M`;
  if (amount >= 1_000) return ${Math.round(amount / 1_000)}k`;
  return ${Math.round(amount)}`;
}

export function daysUntil(value) {
  if (!value) return null;
  const d = new Date(value);
  if (Number.isNaN(d.getTime())) return null;
  return Math.ceil((d.getTime() - Date.now()) / (1000 * 60 * 60 * 24));
}