import Link from "next/link"; export function capitalizeFirstLetter(val) { return String(val).charAt(0).toUpperCase() + String(val).slice(1); } export function formatDates(dateObj, showTime) { const d = new Date(dateObj); const dd = String(d.getDate()).padStart(2, "0"); const mm = String(d.getMonth() + 1).padStart(2, "0"); const yyyy = d.getFullYear(); const hh = String(d.getHours()).padStart(2, "0"); const mins = String(d.getMinutes()).padStart(2, "0"); return showTime && !(hh === "00" && mins === "00") ? `${hh}:${mins}` : `${dd}/${mm}/${yyyy}`; } export function hasValidKey(obj, key) { return obj?.hasOwnProperty(key) && obj[key] !== null && obj[key] !== ""; } export function showReps(startDate, endDate) { const now = new Date(); const start = new Date(startDate); const end = new Date(endDate); return now >= start && now <= end; } export function showRepsEnded(startDate, endDate) { const now = new Date(); const start = new Date(startDate); const end = new Date(endDate); return now > start && now > end; } export function isObjectNotEmpty(obj, key) { return obj.hasOwnProperty(key) && Object.keys(obj[key]).length > 0; } export function hasOwnPropertyAndNotNull(obj, property) { return obj.hasOwnProperty(property) && obj[property] !== null; } export function linkedCasesList(linkedCasesReference, locale) { //console.log(linkedCasesReference); linkedCasesReference = linkedCasesReference.value || []; return ( <> ); } export const getBilingualText = (value, locale) => { if (!value) return ""; // Prefer new delimiter if present const delimiter = value.includes(">>>") ? ">>>" : ";"; // No delimiter at all → return whole string if (!value.includes(delimiter)) return value; const [en, cy] = value.split(delimiter); return locale === "cy" ? (cy ?? en) : (en ?? cy); };