From 611244edeeafb41fc0dab0a46c938f4b6cfb3a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Thu, 29 Jul 2021 11:22:25 +0500 Subject: [PATCH] Add components factory --- src/components/factory.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/components/factory.js diff --git a/src/components/factory.js b/src/components/factory.js new file mode 100644 index 0000000..06269a0 --- /dev/null +++ b/src/components/factory.js @@ -0,0 +1,26 @@ +export const makeColumn = (title, key, other) => ({ + title: title, + key: key, + dataIndex: key, + ...other, +}); + +export const makeColumnsPlanFact = (title, keyPlan, keyFact, gruopOther) => +{ + let keyPlanLocal = keyPlan + let keyFactLocal = keyFact + + if(!keyFact){ + keyPlanLocal = keyPlan + 'Plan' + keyFactLocal = keyPlan + 'Fact' + } + + return { + title: title, + ...gruopOther, + children: [ + makeColumn('план', keyPlanLocal), + makeColumn('факт', keyFactLocal), + ] + } +} \ No newline at end of file