From 10a0618d17d47574a72362d3d944bcd67f246a88 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Tue, 28 Mar 2023 20:12:29 +0300 Subject: [PATCH] add dot badge for validation tab --- apps/web/Components/Output/index.jsx | 38 ++++++++++++++++++----- apps/web/stores/calculation/index.ts | 6 ++++ apps/web/stores/tables/fingap/index.ts | 4 +++ apps/web/stores/tables/insurance/index.ts | 4 +++ apps/web/stores/tables/payments/index.ts | 4 +++ packages/ui/elements/badge.js | 1 + packages/ui/elements/index.ts | 1 + 7 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 packages/ui/elements/badge.js diff --git a/apps/web/Components/Output/index.jsx b/apps/web/Components/Output/index.jsx index c15e8fd..055e5ce 100644 --- a/apps/web/Components/Output/index.jsx +++ b/apps/web/Components/Output/index.jsx @@ -2,11 +2,39 @@ import PaymentsTable from './PaymentsTable'; import Results from './Results'; import Validation from './Validation'; import Background from '@/Components/Layout/Background'; +import { useStore } from '@/stores/hooks'; import { min } from '@/styles/mq'; +import { observer } from 'mobx-react-lite'; import styled from 'styled-components'; -import Tabs from 'ui/elements/layout/Tabs'; +import { Badge, Tabs } from 'ui'; const outputTabs = [PaymentsTable, Results, Validation]; +const items = outputTabs.map(({ Component, id, title }) => { + let Label = () => title; + + if (id === 'validation') { + Label = observer(() => { + const { $calculation, $tables } = useStore(); + const hasErrors = + $calculation.hasErrors || + $tables.fingap.hasErrors || + $tables.insurance.hasErrors || + $tables.payments.hasErrors; + + return ( + + {title} + + ); + }); + } + + return { + children: , + key: id, + label: