mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat(webapp): rule form
This commit is contained in:
@@ -51,6 +51,7 @@ import EstimateMailDialog from '@/containers/Sales/Estimates/EstimateMailDialog/
|
|||||||
import ReceiptMailDialog from '@/containers/Sales/Receipts/ReceiptMailDialog/ReceiptMailDialog';
|
import ReceiptMailDialog from '@/containers/Sales/Receipts/ReceiptMailDialog/ReceiptMailDialog';
|
||||||
import PaymentMailDialog from '@/containers/Sales/PaymentReceives/PaymentMailDialog/PaymentMailDialog';
|
import PaymentMailDialog from '@/containers/Sales/PaymentReceives/PaymentMailDialog/PaymentMailDialog';
|
||||||
import { ExportDialog } from '@/containers/Dialogs/ExportDialog';
|
import { ExportDialog } from '@/containers/Dialogs/ExportDialog';
|
||||||
|
import { RuleFormDialog } from '@/containers/Banking/Rules/RuleFormDialog/RuleFormDialog';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialogs container.
|
* Dialogs container.
|
||||||
@@ -147,6 +148,7 @@ export default function DialogsContainer() {
|
|||||||
<ReceiptMailDialog dialogName={DialogsName.ReceiptMail} />
|
<ReceiptMailDialog dialogName={DialogsName.ReceiptMail} />
|
||||||
<PaymentMailDialog dialogName={DialogsName.PaymentMail} />
|
<PaymentMailDialog dialogName={DialogsName.PaymentMail} />
|
||||||
<ExportDialog dialogName={DialogsName.Export} />
|
<ExportDialog dialogName={DialogsName.Export} />
|
||||||
|
<RuleFormDialog dialogName={DialogsName.BankRuleForm} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,4 +75,5 @@ export enum DialogsName {
|
|||||||
GeneralLedgerPdfPreview = 'GeneralLedgerPdfPreview',
|
GeneralLedgerPdfPreview = 'GeneralLedgerPdfPreview',
|
||||||
SalesTaxLiabilitySummaryPdfPreview = 'SalesTaxLiabilitySummaryPdfPreview',
|
SalesTaxLiabilitySummaryPdfPreview = 'SalesTaxLiabilitySummaryPdfPreview',
|
||||||
Export = 'Export',
|
Export = 'Export',
|
||||||
|
BankRuleForm = 'BankRuleForm'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
import { RuleFormBoot } from "./RuleFormBoot";
|
import { RuleFormBoot } from './RuleFormBoot';
|
||||||
|
import { RuleFormContentForm } from './RuleFormContentForm';
|
||||||
|
|
||||||
interface RuleFormContentProps {
|
interface RuleFormContentProps {
|
||||||
dialogName: string;
|
dialogName: string;
|
||||||
bankRuleId?: number;
|
bankRuleId?: number;
|
||||||
}
|
}
|
||||||
export function RuleFormContent({
|
|
||||||
|
export default function RuleFormContent({
|
||||||
dialogName,
|
dialogName,
|
||||||
bankRuleId,
|
bankRuleId,
|
||||||
}: RuleFormContentProps) {
|
}: RuleFormContentProps) {
|
||||||
return (
|
return (
|
||||||
<RuleFormBoot
|
<div>
|
||||||
bankRuleId={bankRuleId}
|
<RuleFormBoot bankRuleId={bankRuleId}>
|
||||||
>
|
<RuleFormContentForm />
|
||||||
|
|
||||||
</RuleFormBoot>
|
</RuleFormBoot>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Form, Formik, useFormikContext } from 'formik';
|
import { Form, Formik, useFormikContext } from 'formik';
|
||||||
import { Button, Radio } from '@blueprintjs/core';
|
import { Button, Classes, Intent, Radio } from '@blueprintjs/core';
|
||||||
import { CreateRuleFormSchema } from './RuleFormContentForm.schema';
|
import { CreateRuleFormSchema } from './RuleFormContentForm.schema';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
@@ -61,7 +61,10 @@ export function RuleFormContentForm() {
|
|||||||
<FSelect name={'conditionsType'} items={[]} />
|
<FSelect name={'conditionsType'} items={[]} />
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
<FFormGroup name={''} label={'Categorize the transactions when'}>
|
<FFormGroup
|
||||||
|
name={'conditionsType'}
|
||||||
|
label={'Categorize the transactions when'}
|
||||||
|
>
|
||||||
<FRadioGroup name={'conditionsType'}>
|
<FRadioGroup name={'conditionsType'}>
|
||||||
<Radio value={'and'} label={'All the following criteria matches'} />
|
<Radio value={'and'} label={'All the following criteria matches'} />
|
||||||
<Radio
|
<Radio
|
||||||
@@ -72,7 +75,6 @@ export function RuleFormContentForm() {
|
|||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
<RuleFormConditions />
|
<RuleFormConditions />
|
||||||
|
|
||||||
<h3>Then Assign</h3>
|
<h3>Then Assign</h3>
|
||||||
|
|
||||||
<FFormGroup name={'assignCategory'} label={'Transaction type'}>
|
<FFormGroup name={'assignCategory'} label={'Transaction type'}>
|
||||||
@@ -86,6 +88,8 @@ export function RuleFormContentForm() {
|
|||||||
<FFormGroup name={'assignRef'} label={'Reference'}>
|
<FFormGroup name={'assignRef'} label={'Reference'}>
|
||||||
<FInputGroup name={'assignRef'} />
|
<FInputGroup name={'assignRef'} />
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
|
<RuleFormActions />
|
||||||
</Form>
|
</Form>
|
||||||
</Formik>
|
</Formik>
|
||||||
);
|
);
|
||||||
@@ -132,3 +136,25 @@ function RuleFormConditions() {
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function RuleFormActions() {
|
||||||
|
const { isSubmitting, submitForm } = useFormikContext<RuleFormValues>();
|
||||||
|
|
||||||
|
const handleSaveBtnClick = () => {
|
||||||
|
submitForm();
|
||||||
|
};
|
||||||
|
const handleCancelBtnClick = () => {};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box className={Classes.DIALOG_FOOTER}>
|
||||||
|
<Button
|
||||||
|
intent={Intent.PRIMARY}
|
||||||
|
loading={isSubmitting}
|
||||||
|
onClick={handleSaveBtnClick}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleCancelBtnClick}>Cancel</Button>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ const RuleFormContent = React.lazy(() => import('./RuleFormContent'));
|
|||||||
/**
|
/**
|
||||||
* Payment mail dialog.
|
* Payment mail dialog.
|
||||||
*/
|
*/
|
||||||
function RuleFormDialog({
|
function RuleFormDialogRoot({
|
||||||
dialogName,
|
dialogName,
|
||||||
payload: { bankRuleId = null },
|
payload: { bankRuleId = null },
|
||||||
isOpen,
|
isOpen,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
name={dialogName}
|
name={dialogName}f
|
||||||
title={'New Bank Rule'}
|
title={'New Bank Rule'}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
canEscapeJeyClose={true}
|
canEscapeJeyClose={true}
|
||||||
@@ -30,4 +30,6 @@ function RuleFormDialog({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default compose(withDialogRedux())(RuleFormDialog);
|
export const RuleFormDialog = compose(withDialogRedux())(RuleFormDialogRoot);
|
||||||
|
|
||||||
|
RuleFormDialog.displayName = 'RuleFormDialog';
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { RulesList } from './RulesList';
|
||||||
|
|
||||||
|
export default RulesList;
|
||||||
@@ -1,10 +1,37 @@
|
|||||||
import { DashboardActionsBar } from '@/components';
|
// @ts-nocheck
|
||||||
import { NavbarGroup } from '@blueprintjs/core';
|
import { Button, Classes, NavbarGroup } from '@blueprintjs/core';
|
||||||
|
import * as R from 'ramda';
|
||||||
|
import { Can, DashboardActionsBar, Icon } from '@/components';
|
||||||
|
import { AbilitySubject, BankRuleAction } from '@/constants/abilityOption';
|
||||||
|
import withAlertActions from '@/containers/Alert/withAlertActions';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
|
function RulesListActionsBarRoot({
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
|
}) {
|
||||||
|
const handleCreateBtnClick = () => {
|
||||||
|
openDialog(DialogsName.BankRuleForm);
|
||||||
|
};
|
||||||
|
|
||||||
export function RulesListActionsBar() {
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup></NavbarGroup>
|
<NavbarGroup>
|
||||||
|
<Can I={BankRuleAction.Create} a={AbilitySubject.BankRule}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="plus" />}
|
||||||
|
text={'New Bank Rule'}
|
||||||
|
onClick={handleCreateBtnClick}
|
||||||
|
/>
|
||||||
|
</Can>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const RulesListActionsBar = R.compose(
|
||||||
|
withDialogActions,
|
||||||
|
withAlertActions,
|
||||||
|
)(RulesListActionsBarRoot);
|
||||||
|
|||||||
@@ -38,8 +38,10 @@ function RulesTable({
|
|||||||
// Handle delete bank rule.
|
// Handle delete bank rule.
|
||||||
const handleEditBankRule = () => {};
|
const handleEditBankRule = () => {};
|
||||||
|
|
||||||
|
const isEmptyState = false;
|
||||||
|
|
||||||
// Display invoice empty status instead of the table.
|
// Display invoice empty status instead of the table.
|
||||||
if (isEmptyStatus) {
|
if (isEmptyState) {
|
||||||
return <BankRulesLandingEmptyState />;
|
return <BankRulesLandingEmptyState />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,11 +64,11 @@ function RulesTable({
|
|||||||
TableLoadingRenderer={TableSkeletonRows}
|
TableLoadingRenderer={TableSkeletonRows}
|
||||||
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
||||||
ContextMenu={BankRulesTableActionsMenu}
|
ContextMenu={BankRulesTableActionsMenu}
|
||||||
onCellClick={handleCellClick}
|
// onCellClick={handleCellClick}
|
||||||
size={'medium'}
|
size={'medium'}
|
||||||
payload={{
|
payload={{
|
||||||
onDelete: handleDeleteTaxRate,
|
onDelete: handleDeleteBankRule,
|
||||||
onEdit: handleEditTaxRate,
|
onEdit: handleEditBankRule,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</DashboardContentTable>
|
</DashboardContentTable>
|
||||||
|
|||||||
@@ -1225,7 +1225,7 @@ export const getDashboardRoutes = () => [
|
|||||||
{
|
{
|
||||||
path: '/bank-rules',
|
path: '/bank-rules',
|
||||||
component: lazy(
|
component: lazy(
|
||||||
() => import('@/containers/Banking/Rules/RulesList/RulesList'),
|
() => import('@/containers/Banking/Rules/RulesList/RulesLandingPage'),
|
||||||
),
|
),
|
||||||
pageTitle: 'Bank Rules',
|
pageTitle: 'Bank Rules',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user