mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat: ability reports home page.
This commit is contained in:
23
src/containers/FinancialStatements/FilterFinancialReports.js
Normal file
23
src/containers/FinancialStatements/FilterFinancialReports.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { isEmpty } from 'lodash';
|
||||||
|
import { useAbilityContext } from '../../hooks';
|
||||||
|
|
||||||
|
function useFilterFinancialReports(financial) {
|
||||||
|
const ability = useAbilityContext();
|
||||||
|
|
||||||
|
const seaction = financial
|
||||||
|
.map((seaction) => {
|
||||||
|
const reports = seaction.reports.filter((report) => {
|
||||||
|
return ability.can(report.ability, report.subject);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
sectionTitle: seaction.sectionTitle,
|
||||||
|
reports,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter(({ reports }) => !isEmpty(reports));
|
||||||
|
|
||||||
|
return seaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useFilterFinancialReports;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { For } from 'components';
|
import { For } from 'components';
|
||||||
|
import useFilterFinancialReports from './FilterFinancialReports';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import {
|
import {
|
||||||
financialReportMenus,
|
financialReportMenus,
|
||||||
@@ -37,13 +37,18 @@ function FinancialReportsSection({ sectionTitle, reports }) {
|
|||||||
* Financial reports.
|
* Financial reports.
|
||||||
*/
|
*/
|
||||||
export default function FinancialReports() {
|
export default function FinancialReports() {
|
||||||
|
const financialReportMenu = useFilterFinancialReports(financialReportMenus);
|
||||||
|
const SalesAndPurchasesReportMenu = useFilterFinancialReports(
|
||||||
|
SalesAndPurchasesReportMenus,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider name={'financial-reports'}>
|
<DashboardInsider name={'financial-reports'}>
|
||||||
<div class="financial-reports">
|
<div class="financial-reports">
|
||||||
<For render={FinancialReportsSection} of={financialReportMenus} />
|
<For render={FinancialReportsSection} of={financialReportMenu} />
|
||||||
<For
|
<For
|
||||||
render={FinancialReportsSection}
|
render={FinancialReportsSection}
|
||||||
of={SalesAndPurchasesReportMenus}
|
of={SalesAndPurchasesReportMenu}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</DashboardInsider>
|
</DashboardInsider>
|
||||||
|
|||||||
Reference in New Issue
Block a user