Skip to main content
GET
/
api
/
catalogs
/
cadenas
Production Chains Catalog
curl --request GET \
  --url https://api.example.com/api/catalogs/cadenas
{
  "id": 123,
  "nombre": "<string>",
  "descripcion": "<string>",
  "activo": 123
}

Overview

The Production Chains catalog (Cadenas) defines manufacturing chains or cells within the facility. Chains typically represent distinct production flows or product families.
Chains are high-level organizational units that contain multiple production lines.

Endpoints

List All Chains

curl -X GET http://localhost:3001/api/catalogs/cadenas \
  -H "Authorization: Bearer YOUR_TOKEN"

Create Chain

curl -X POST http://localhost:3001/api/catalogs/cadenas \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "GNT1",
    "descripcion": "Cadena de arneses para General Motors",
    "activo": 1
  }'

Update Chain

curl -X PUT http://localhost:3001/api/catalogs/cadenas/1 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"descripcion": "Cadena GNT1 - GM Arneses Actualizados"}'

Delete Chain (Soft)

curl -X DELETE http://localhost:3001/api/catalogs/cadenas/1 \
  -H "Authorization: Bearer YOUR_TOKEN"

Data Structure

id
number
Unique identifier
nombre
string
required
Chain name or code (e.g., “GNT1”, “FCA2”, “TOYOTA-A”)
descripcion
string
required
Detailed description of the production chain
activo
number
Status: 1 = active, 0 = inactive

Response Example

[
  {
    "id": 1,
    "nombre": "GNT1",
    "descripcion": "Cadena de arneses para General Motors",
    "activo": 1
  },
  {
    "id": 2,
    "nombre": "FCA2",
    "descripcion": "Cadena de conectores para FCA",
    "activo": 1
  },
  {
    "id": 3,
    "nombre": "TOYOTA-A",
    "descripcion": "Cadena de arneses Toyota - Plataforma A",
    "activo": 1
  }
]

TypeScript Interface

export interface Cadena {
  id: number;
  nombre: string;
  descripcion: string;
  activo: number;
}

Relationship with Lines

Chains contain multiple production lines:
// Get all lines for a specific chain
const getLinesByChain = (chainId, linesCatalog) => {
  return linesCatalog.filter(line => 
    line.cadena_id === chainId && line.activo === 1
  );
};

// Usage
const gnt1Lines = getLinesByChain(1, lineasCatalog);
console.log(`GNT1 has ${gnt1Lines.length} production lines`);

Chain-Level Reports

Generate reports aggregated by production chain:
const getChainReport = async (startDate, endDate) => {
  const response = await fetch(
    `http://localhost:3001/api/reports/by-cadena?` +
    `fecha_inicio=${startDate}&fecha_fin=${endDate}`,
    {
      headers: { 'Authorization': `Bearer ${getToken()}` }
    }
  );
  return await response.json();
};

// Get scrap data for specific chain
const getChainScrap = async (chainName, startDate, endDate) => {
  const response = await fetch(
    `http://localhost:3001/api/scrap?` +
    `cadena=${chainName}&desde=${startDate}&hasta=${endDate}`,
    {
      headers: { 'Authorization': `Bearer ${getToken()}` }
    }
  );
  return await response.json();
};

Hierarchical Navigation

Implement cascading dropdowns for chain → line selection:
interface ChainLineSelector {
  selectedChain: Cadena | null;
  availableLines: Linea[];
}

const ChainLineSelector: React.FC = () => {
  const [selectedChain, setSelectedChain] = useState<Cadena | null>(null);
  const [availableLines, setAvailableLines] = useState<Linea[]>([]);
  
  useEffect(() => {
    if (selectedChain) {
      const lines = getLinesByChain(selectedChain.id, lineasCatalog);
      setAvailableLines(lines);
    } else {
      setAvailableLines([]);
    }
  }, [selectedChain]);
  
  return (
    <>
      <select onChange={e => setSelectedChain(chains[e.target.value])}>
        <option value="">Seleccionar cadena...</option>
        {chains.map(chain => (
          <option key={chain.id} value={chain.id}>{chain.nombre}</option>
        ))}
      </select>
      
      {availableLines.length > 0 && (
        <select>
          <option value="">Seleccionar línea...</option>
          {availableLines.map(line => (
            <option key={line.id} value={line.id}>{line.nombre}</option>
          ))}
        </select>
      )}
    </>
  );
};

Permissions

View

All authenticated users

Create/Edit

admin, calidad roles only

Best Practices

Naming Convention: Use customer/project codes for chain names (GNT1, FCA2) for easy identification.
Hierarchy: Plan your organizational hierarchy: Facility → Chains → Lines → Areas

Build docs developers (and LLMs) love