summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/components/Odipar/common.js
blob: b6fb49db2ca96d4b0c53c1a218ecbd0cf7c4b2aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from "react"
import { Chip } from "@material-ui/core";
import { pedido, camion, bloqueo, almacen } from './EtiquetaData'
import Brightness1Icon from '@material-ui/icons/Brightness1';

export const etiquetaStyle = color => ({
  fontWeight: 'bold',
  color: '#FFF',
  backgroundColor: color
});


//Etiquetas
export function etiqueta(tipo , estado) { // eslint-disable-line
  let {color, text, icon} = ""
  switch(tipo){
    case 'etiq_pedido': 
      text = pedido[Object.keys(pedido)[estado]].text
      color = pedido[Object.keys(pedido)[estado]].color
      break;
    case 'etiq_camion': 
      text = camion[Object.keys(camion)[estado]].text
      color = camion[Object.keys(camion)[estado]].color
      break;
    case 'etiq_bloqueo': 
      text = bloqueo[Object.keys(bloqueo)[estado]].text
      color = bloqueo[Object.keys(bloqueo)[estado]].color
      break;
    case 'etiq_alma': 
      let {estadoNum} = 2
      estado === false? estadoNum = 0 : estadoNum = 1
      text = almacen[Object.keys(almacen)[estadoNum]].text
      color = almacen[Object.keys(almacen)[estadoNum]].color
      icon = almacen[Object.keys(almacen)[estadoNum]].icon
      break;
  }

  return (
    tipo == "etiq_alma" ?
      <Chip label={text} icon = {<Brightness1Icon style={{ fontSize: icon, color: "#B1ABAB" }}/>} style={{fontWeight: 'bold', backgroundColor: color}}/> :
      <Chip label={text} style={etiquetaStyle(color)}/>
  )
}