diff --git a/backend/scripts/reconcile.js b/backend/scripts/reconcile.js index 04a8dd8..6f21ac0 100644 --- a/backend/scripts/reconcile.js +++ b/backend/scripts/reconcile.js @@ -47,9 +47,12 @@ async function reconcile() { // Get batch ID at index const batchIdBytes32 = await contract.getBatchIdByIndex(i); +<<<<<<< HEAD +======= // Convert bytes32 to string (remove padding) const batchId = ethers.zeroPadValue(batchIdBytes32, 32).toString(); +>>>>>>> upstream/main // Get full batch data const onChainBatch = await contract.getBatch(batchIdBytes32); @@ -59,14 +62,21 @@ async function reconcile() { const readableBatchId = ethers.toUtf8String(batchIdBytes32); // Map blockchain stage (uint8) to string +<<<<<<< HEAD + const stageName = getStageName(0); +======= const stageName = getStageName(Number(onChainBatch.quantity) > 0 ? 0 : 0); // Stage is in updates, not CropBatch struct +>>>>>>> upstream/main // Update or insert batch in MongoDB await Batch.updateOne( { batchId: readableBatchId }, { $set: { +<<<<<<< HEAD +======= // Keep local data but update sync status +>>>>>>> upstream/main syncStatus: 'synced', lastSyncedAt: new Date(), onChainData: { diff --git a/backend/server.js b/backend/server.js index e3cdf7d..c2d8c71 100644 --- a/backend/server.js +++ b/backend/server.js @@ -60,9 +60,15 @@ const PORT = process.env.PORT || 3001; // ==================== MIDDLEWARE FUNCTIONS ==================== +<<<<<<< HEAD +// Authentication is handled by middleware imported from './middleware/auth': +// - protect: Verifies JWT and fetches full user from MongoDB +// - adminOnly: Checks if user has admin role +======= // Authentication is handled by middleware imported from './middleware/auth' // - protect: Verifies JWT and fetches full user from - adminOnly: MongoDB // Checks if user has admin role +>>>>>>> upstream/main // - authorizeBatchOwner: Verifies user owns the batch // - authorizeRoles: Role-based authorization @@ -343,6 +349,7 @@ async function generateBatchId(session = null) { return `CROP-${currentYear}-${String(counter.seq).padStart(4, '0')}`; } + async function generateQRCode(batchId) { try { return await QRCode.toDataURL(batchId, {