summaryrefslogtreecommitdiff
path: root/src/components/Rule.tsx
blob: b8ff70f154c5fce39312b428fec1328f20bf7e68 (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
import React from 'react';

import s0 from './Rule.module.scss';

const colorMap = {
  _default: '#59caf9',
  DIRECT: '#f5bc41',
  REJECT: '#cb3166',
};

function getStyleFor({ proxy }) {
  let color = colorMap._default;
  if (colorMap[proxy]) {
    color = colorMap[proxy];
  }
  return { color };
}

type Props = {
  id?: number;
  type?: string;
  payload?: string;
  proxy?: string;
};

function Rule({ type, payload, proxy, id }: Props) {
  const styleProxy = getStyleFor({ proxy });
  return (
    <div className={s0.rule}>
      <div className={s0.left}>{id}</div>
      <div>
        <div className={s0.b}>{payload}</div>
        <div className={s0.a}>
          <div className={s0.type}>{type}</div>
          <div style={styleProxy}>{proxy}</div>
        </div>
      </div>
    </div>
  );
}

export default Rule;