mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
Merge branch 'featrue/roles-permission' of https://github.com/bigcapitalhq/client into featrue/roles-permission
This commit is contained in:
@@ -115,6 +115,7 @@ export const Cashflow_Abilities = {
|
||||
};
|
||||
|
||||
export const Report_Abilities = {
|
||||
ALL:'all',
|
||||
READ_BALANCE_SHEET: 'read-balance-sheet',
|
||||
READ_TRIAL_BALANCE_SHEET: 'read-trial-balance-sheet',
|
||||
READ_PROFIT_LOSS: 'read-profit-loss',
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
Manual_Journal_Abilities,
|
||||
Expense_Abilities,
|
||||
Item_Abilities,
|
||||
Report_Abilities,
|
||||
} from '../common/abilityOption';
|
||||
|
||||
export const accountsReceivable = [
|
||||
@@ -135,6 +136,8 @@ export const financialAccounting = [
|
||||
<T id={'show_financial_reports_about_your_organization'} />
|
||||
),
|
||||
link: '/financial-reports',
|
||||
subject: AbilitySubject.Report,
|
||||
ability: Report_Abilities.ALL,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import { isEmpty } from 'lodash';
|
||||
import { useAbilityContext } from '../../hooks';
|
||||
|
||||
function useFilterFinancialReports(financial) {
|
||||
function useFilterFinancialReports(financialSection) {
|
||||
const ability = useAbilityContext();
|
||||
|
||||
const seaction = financial
|
||||
.map((seaction) => {
|
||||
const reports = seaction.reports.filter((report) => {
|
||||
const section = financialSection
|
||||
.map((section) => {
|
||||
const reports = section.reports.filter((report) => {
|
||||
return ability.can(report.ability, report.subject);
|
||||
});
|
||||
|
||||
return {
|
||||
sectionTitle: seaction.sectionTitle,
|
||||
sectionTitle: section.sectionTitle,
|
||||
reports,
|
||||
};
|
||||
})
|
||||
.filter(({ reports }) => !isEmpty(reports));
|
||||
|
||||
return seaction;
|
||||
return section;
|
||||
}
|
||||
|
||||
export default useFilterFinancialReports;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
|
||||
import { For } from 'components';
|
||||
|
||||
import 'style/pages/FinancialStatements/FinancialSheets.scss';
|
||||
import { useFilterShortcutBoxesSection } from './components';
|
||||
|
||||
function ShortcutBox({ title, link, description }) {
|
||||
return (
|
||||
@@ -27,5 +28,6 @@ function ShortcutBoxes({ sectionTitle, shortcuts }) {
|
||||
}
|
||||
|
||||
export default function ShortcutBoxesSection({ section }) {
|
||||
return <For render={ShortcutBoxes} of={section} />;
|
||||
const BoxSection = useFilterShortcutBoxesSection(section);
|
||||
return <For render={ShortcutBoxes} of={BoxSection} />;
|
||||
}
|
||||
|
||||
18
src/containers/Homepage/components.js
Normal file
18
src/containers/Homepage/components.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { isEmpty } from 'lodash';
|
||||
import { useAbilityContext } from '../../hooks';
|
||||
|
||||
export const useFilterShortcutBoxesSection = (section) => {
|
||||
const ability = useAbilityContext();
|
||||
|
||||
return section
|
||||
.map(({ sectionTitle, shortcuts }) => {
|
||||
const shortcut = shortcuts.filter((shortcuts) => {
|
||||
return ability.can(shortcuts.ability, shortcuts.subject);
|
||||
});
|
||||
return {
|
||||
sectionTitle: sectionTitle,
|
||||
shortcuts: shortcut,
|
||||
};
|
||||
})
|
||||
.filter(({ shortcuts }) => !isEmpty(shortcuts));
|
||||
};
|
||||
Reference in New Issue
Block a user