diff --git a/server.ts b/server.ts index da124c8..3c0a5aa 100644 --- a/server.ts +++ b/server.ts @@ -751,8 +751,8 @@ app.post('/api/submit', async (c) => { const onlySymbols = /^[^A-Za-z0-9]+$/.test(jobName); const hasLetters = /[A-Za-z]/.test(jobName); const isInvalidLiteral = invalidLiterals.includes(jobName.toLowerCase()); - const isLongEnough = jobName.length >= 4; - if (!isLongEnough || !hasLetters || onlySymbols || isInvalidLiteral) { + const isLongEnough = jobName.length >= 4 || jobName.toUpperCase() === "UNK"; + if (!isLongEnough || (!hasLetters && jobName.toUpperCase() !== "UNK") || onlySymbols || isInvalidLiteral) { return c.json({ success: false, message: 'Job name must be at least 4 characters with letters (no symbols-only, no N/A).' @@ -771,7 +771,7 @@ app.post('/api/submit', async (c) => { } // Get all existing job numbers and find the max - const existingJobs = await pb.collection(pbCollection).getFullList({ + const existingJobs = await pb.collection(activeConfig.pbCollection).getFullList({ fields: 'Job_Number', sort: '-created', }); @@ -792,7 +792,7 @@ app.post('/api/submit', async (c) => { delete data.pbToken; // Create the record in PocketBase as the authenticated user - const record = await pb.collection(pbCollection).create(data); + const record = await pb.collection(activeConfig.pbCollection).create(data); console.log(`✓ Created PocketBase record with Job_Number: ${newJobNumber}, ID: ${record.id}`); // Persist calculated fields to PocketBase immediately after creation @@ -802,7 +802,7 @@ app.post('/api/submit', async (c) => { const voxerLinkVal = calculateVoxerLink(record); const jobCodesVal = calculateJobCodes(record); - await pb.collection(pbCollection).update(record.id, { + await pb.collection(activeConfig.pbCollection).update(record.id, { Job_Full_Name: fullName, Job_QB_Link: qbLink, Voxer_Link: voxerLinkVal, @@ -872,7 +872,7 @@ app.post('/api/submit', async (c) => { try { const dueStatic = calculateDueDateCounter(record); const activeStatic = calculateActive(record); - await pb.collection(pbCollection).update(record.id, { + await pb.collection(activeConfig.pbCollection).update(record.id, { Job_Folder_Link: jobFolderLink || '', Due_Date_Counter: dueStatic, Active: activeStatic