add success badge for result tab

This commit is contained in:
vchikalkin 2024-07-09 12:08:23 +03:00
parent 192bb089a0
commit ac76f7dcdb
2 changed files with 19 additions and 3 deletions

View File

@ -6,7 +6,7 @@ import { Component as Validation } from './Validation';
import { Notification } from '@/Components/Common';
import { NavigationBar, Tabs } from '@/Components/Layout/Navigation';
import { NavigationProvider } from '@/context/navigation';
import { useErrors } from '@/stores/hooks';
import { useErrors, useResults } from '@/stores/hooks';
import { Media } from '@/styles/media';
import { getPageTitle } from '@/utils/page';
import { observer } from 'mobx-react-lite';
@ -41,7 +41,15 @@ export const tabs = [
},
{
Component: Output,
Icon: () => <BarChartOutlined style={defaultIconStyle} />,
Icon: observer(() => {
const { hasResults } = useResults();
return (
<StyledBadge status="success" dot={hasResults}>
<BarChartOutlined style={defaultIconStyle} />
</StyledBadge>
);
}),
key: 'output',
title: 'Результаты',
},
@ -51,7 +59,7 @@ export const tabs = [
const { hasErrors } = useErrors();
return (
<StyledBadge dot={hasErrors}>
<StyledBadge status="error" dot={hasErrors}>
<WarningOutlined style={defaultIconStyle} />
</StyledBadge>
);

View File

@ -22,3 +22,11 @@ export function useErrors() {
hasErrors: hasElementsErrors || hasPaymentsErrors || hasInsuranceErrors || hasFingapErrors,
};
}
export function useResults() {
const { $results } = useStore();
return {
hasResults: $results.payments.length > 0,
};
}