export function generateLink(caseNumberInput) {
    const caseNumber = caseNumberInput.trim().toUpperCase();

    if (caseNumber) {
        const caseYear = caseNumber.substring(0, 2);
        const caseType = caseNumber.substring(2, 4);
        const caseRest = caseNumber.substring(4);

        let circuitId;
        if (caseType === "CY") {
            circuitId = "SMPDB0001_CT07"; // Clay County (7th Circuit)
        } else if (caseType === "CA") {
            circuitId = "CT17"; // Cass County (17th Circuit)
        } else if (caseType === "16") {
            circuitId = "CT16"; // Jackson County (16th Circuit)
        } else if (caseType === "AE") {
            circuitId = "SMPDB0001_CT06"; // Platte County (6th Circuit)
        } else {
            alert('Invalid case type.');
            return;
        }

        const link = `https://www.courts.mo.gov/cnet/cases/newHeader.do?inputVO.caseNumber=${caseYear}${caseType}${caseRest}&inputVO.courtId=${circuitId}`;

        return link;
    }
}
