raahinaez commited on
Commit
4ff445d
·
verified ·
1 Parent(s): 457e969

Update frontend/src/pages/Repository.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/pages/Repository.jsx +31 -9
frontend/src/pages/Repository.jsx CHANGED
@@ -185,8 +185,20 @@
185
  }
186
  }
187
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  return {
189
- id: String(asset.id), // Explicitly convert to string to preserve precision
190
  name: asset.name || 'Unknown',
191
  type: asset.file_type || 'unknown',
192
  product: asset.product_category || 'ocr',
@@ -257,14 +269,24 @@
257
  }
258
  };
259
 
260
- // Load PDF pages when previewing a PDF
261
- const loadPdfPages = async (assetId) => {
262
- setIsLoadingPdf(true);
263
- setPdfPages(null);
264
- try {
265
- // Ensure assetId is a string to preserve precision
266
- const assetIdStr = String(assetId);
267
- const response = await fetch(`/api/assets/${assetIdStr}/pdf-pages`);
 
 
 
 
 
 
 
 
 
 
268
 
269
  if (response.ok) {
270
  const data = await response.json();
 
185
  }
186
  }
187
 
188
+ // CRITICAL: Keep ID as string - never convert to number (precision loss for large IDs)
189
+ // If asset.id is already a number, convert it carefully to preserve precision
190
+ let assetIdStr;
191
+ if (typeof asset.id === 'string') {
192
+ assetIdStr = asset.id;
193
+ } else if (typeof asset.id === 'number') {
194
+ // For very large numbers, use BigInt to preserve precision, then convert to string
195
+ assetIdStr = BigInt(asset.id).toString();
196
+ } else {
197
+ assetIdStr = String(asset.id);
198
+ }
199
+
200
  return {
201
+ id: assetIdStr, // Always keep as string to preserve precision for large CockroachDB IDs
202
  name: asset.name || 'Unknown',
203
  type: asset.file_type || 'unknown',
204
  product: asset.product_category || 'ocr',
 
269
  }
270
  };
271
 
272
+ // Load PDF pages when previewing a PDF
273
+ const loadPdfPages = async (assetId) => {
274
+ setIsLoadingPdf(true);
275
+ setPdfPages(null);
276
+ try {
277
+ // CRITICAL: Ensure assetId is a string to preserve precision for large IDs
278
+ // Never convert to number - JavaScript loses precision for numbers > Number.MAX_SAFE_INTEGER
279
+ let assetIdStr;
280
+ if (typeof assetId === 'string') {
281
+ assetIdStr = assetId;
282
+ } else if (typeof assetId === 'number') {
283
+ // Use BigInt to preserve precision, then convert to string
284
+ assetIdStr = BigInt(assetId).toString();
285
+ } else {
286
+ assetIdStr = String(assetId);
287
+ }
288
+ console.log(`Loading PDF for asset ID: ${assetIdStr} (original type: ${typeof assetId})`);
289
+ const response = await fetch(`/api/assets/${assetIdStr}/pdf-pages`);
290
 
291
  if (response.ok) {
292
  const data = await response.json();