Overview
Quality Hub GINEZ uses Google Sheets as the data source for its product catalog. This approach provides:- ✅ Real-time updates without code deployment
- ✅ Familiar spreadsheet interface for non-technical users
- ✅ Easy collaboration on product data
- ✅ Version history and audit trail
- ✅ No database schema changes needed
- Materia Prima (MP) - Raw materials catalog
- Producto Terminado (PT) - Finished products catalog
Architecture
Data is fetched on-demand when users access the catalog. Consider implementing Next.js revalidation for production deployments.
Setup Instructions
Step 1: Create Google Sheets
Create two separate Google Sheets for your product data:Create Raw Materials Sheet
- Go to Google Sheets
- Create new spreadsheet: “Quality Hub - Materia Prima”
- Add columns (see schema below)
Create Finished Products Sheet
- Create another spreadsheet: “Quality Hub - Producto Terminado”
- Add columns (see schema below)
Step 2: Sheet Schema
Both sheets should follow this structure:Column Definitions
Product Code - Unique identifier (e.g., “LIMLIM”, “TRALIM”)
- Must be unique within the sheet
- Used for matching with production records
- Should match codes in
production-constants.ts
Product Name - Full descriptive nameExample: “Limpiador Multiusos Limón 5L”
Product Family - High-level categorizationCommon values:
- Cuidado del Hogar
- Cuidado Personal
- Lavandería
- Línea Automotriz
- Línea Antibacterial
- Productos Intermedios
Product Category - Specific product typeExamples:
- Limpiadores Multiusos
- Detergentes para Trastes
- Suavizantes de Telas
- Jabones Líquidos
- Shampoos
Type - Material classificationValues:
Materia Prima- Raw materialsProducto Terminado- Finished productsProducto Intermedio- Intermediate products
Technical Data Sheet URL - Link to product specification PDF
- Should be a Google Drive public link or direct download URL
- Example:
https://drive.google.com/file/d/ABC123/view?usp=sharing - Downloads are tracked in admin audit log
Safety Data Sheet (SDS) URL - Link to safety documentation
- Should be a Google Drive public link or direct download URL
- Critical for chemical products
- Downloads are tracked in admin audit log
Step 3: Publish to Web
Each sheet must be published as CSV to generate the URL needed for the application.Configure Publication
In the publish dialog:
- Link tab: Select the specific sheet/tab (e.g., “Sheet1”)
- Format: Choose Comma-separated values (.csv)
- ✅ Check “Automatically republish when changes are made”
- Click Publish
Document Storage (Google Drive)
Setting Up Document Links
TheFichaTecnica and HojaSeguridad columns should link to PDF documents stored in Google Drive.
Upload Documents
- Create a Google Drive folder: “Quality Hub - Documentos”
- Upload all technical data sheets and safety sheets as PDFs
- Organize in subfolders if needed (e.g., by product family)
Set Permissions
For each document:
- Right-click → Share
- Click Change to anyone with the link
- Set permission to Viewer
- Click Copy link
Data Validation
Implement these validation rules in your Google Sheets:Required Field Validation
Syncing and Caching
Current Behavior
Current implementation fetches fresh data on every page load. This ensures data is always current but may impact performance.
Recommended Production Setup
For better performance, implement server-side caching:Troubleshooting
Error: Failed to fetch catalog data
Error: Failed to fetch catalog data
Possible causes:Should return CSV text, not HTML.
- Sheet not published to web
- Wrong URL format (not CSV)
- Sheet permissions too restrictive
Products not showing in catalog
Products not showing in catalog
Check:
- CSV structure matches schema (headers in row 1)
- No empty required fields
- Encoding is UTF-8 (special characters display correctly)
- No duplicate
Codigovalues
Document links not working
Document links not working
Solutions:
- Verify Google Drive link permissions (“Anyone with the link can view”)
- Test links in incognito/private browser window
- Ensure URLs use
https://(nothttp://) - Check for trailing spaces in sheet cells
Special characters (é, ñ, á) display incorrectly
Special characters (é, ñ, á) display incorrectly
Cause: Encoding issueSolution:
- Google Sheets should auto-publish as UTF-8
- In your fetch code, ensure:
- If issues persist, manually specify:
Changes not appearing in app
Changes not appearing in app
If using caching:If no caching:
- Wait for revalidation period to expire
- Or manually clear cache:
- Hard refresh browser (Ctrl+Shift+R)
- Verify sheet has “auto-republish” enabled
- Check published URL returns latest data
Best Practices
Data Governance
- Limit edit access to quality/product managers
- Use protected ranges for critical columns
- Maintain change log sheet for audit trail
Performance
- Keep sheets under 10,000 rows for best performance
- Use separate sheets for historical/archived products
- Implement server-side caching for production
Data Quality
- Use data validation rules
- Standardize naming conventions
- Regularly audit for duplicates or inconsistencies
Documentation
- Include sheet instructions in first row (hide it)
- Maintain README sheet with schema definitions
- Document any custom formulas or validation rules
Migration to Database (Optional)
For large-scale deployments, consider migrating catalog data to Supabase:Next Steps
Environment Variables
Configure Google Sheets CSV URLs in your environment
Multi-Location
Learn about configuring production locations
