mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat: locking transaction page.
This commit is contained in:
@@ -2,45 +2,24 @@ import React from 'react';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import clsx from 'classnames';
|
import clsx from 'classnames';
|
||||||
import { TransactionsLockingProvider } from './TransactionsLockingProvider';
|
|
||||||
import { TransactionLockingContent } from './components';
|
import { TransactionLockingContent } from './components';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
import { useTransactionsLockingContext } from './TransactionsLockingProvider';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
const DataTest = [
|
|
||||||
{
|
|
||||||
isEnabled: true,
|
|
||||||
name: 'sales',
|
|
||||||
module: 'sales',
|
|
||||||
description:
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
isEnabled: false,
|
|
||||||
name: 'purchases',
|
|
||||||
module: 'purchases',
|
|
||||||
description:
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
isEnabled: false,
|
|
||||||
name: 'financial',
|
|
||||||
description:
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
function Paragraph({ className, children }) {
|
function Paragraph({ className, children }) {
|
||||||
return <p className={clsx('paragraph', className)}>{children}</p>;
|
return <p className={clsx('paragraph', className)}>{children}</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TransactionsLockingList({ items }) {
|
function TransactionsLockingList({ items, onlock, onUnlock, onUnlockPartial }) {
|
||||||
return items.map(({ isEnabled, name, description }) => (
|
return items.map(({ is_enabled, formatted_module, description }) => (
|
||||||
<TransactionLockingContent
|
<TransactionLockingContent
|
||||||
name={name}
|
name={formatted_module}
|
||||||
description={description}
|
description={description}
|
||||||
isEnabled={isEnabled}
|
isEnabled={is_enabled}
|
||||||
|
onLock={onlock}
|
||||||
|
onUnlockPartial={onUnlockPartial}
|
||||||
|
onEditLock={onUnlock}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -52,28 +31,44 @@ function TransactionsLockingListPage({
|
|||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
openDialog,
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
// Handle switch transactions locking.
|
// Handle locking transactions.
|
||||||
const handleSwitchTransactionsLocking = () => {
|
const handleLockingTransactions = () => {
|
||||||
openDialog('locking-transactions', {});
|
openDialog('locking-transactions', {});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
// Handle unlocking transactions
|
||||||
<TransactionsLockingProvider>
|
const handleUnlockTransactions = () => {
|
||||||
<TransactionsLocking>
|
openDialog('unlocking-transactions', {});
|
||||||
<TransactionsLockingParagraph>
|
};
|
||||||
<TransLockingDesc>
|
// Handle unlocking transactions
|
||||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
|
const handleUnlockingPartial = () => {
|
||||||
eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem
|
openDialog('unlocking-partial-transactions', {});
|
||||||
ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
};
|
||||||
tempor incididunt ut labore et dolore magna aliqua.
|
|
||||||
</TransLockingDesc>
|
|
||||||
Lock All Transactions At Once.{' '}
|
|
||||||
<Link to={'/'}> {''}Lock All Transactions At Once →</Link>
|
|
||||||
</TransactionsLockingParagraph>
|
|
||||||
|
|
||||||
<TransactionsLockingList items={DataTest} />
|
const {
|
||||||
</TransactionsLocking>
|
transactionsLocking: { modules },
|
||||||
</TransactionsLockingProvider>
|
} = useTransactionsLockingContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TransactionsLocking>
|
||||||
|
<TransactionsLockingParagraph>
|
||||||
|
<TransLockingDesc>
|
||||||
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
|
||||||
|
eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem
|
||||||
|
ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
||||||
|
tempor incididunt ut labore et dolore magna aliqua.
|
||||||
|
</TransLockingDesc>
|
||||||
|
Lock All Transactions At Once.{' '}
|
||||||
|
<Link to={'/'}> {''}Lock All Transactions At Once →</Link>
|
||||||
|
</TransactionsLockingParagraph>
|
||||||
|
|
||||||
|
<TransactionsLockingList
|
||||||
|
items={modules}
|
||||||
|
onlock={handleLockingTransactions}
|
||||||
|
onUnlock={handleUnlockTransactions}
|
||||||
|
onUnlockPartial={handleUnlockingPartial}
|
||||||
|
/>
|
||||||
|
</TransactionsLocking>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default compose(withDialogActions)(TransactionsLockingListPage);
|
export default compose(withDialogActions)(TransactionsLockingListPage);
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { TransactionsLockingProvider } from './TransactionsLockingProvider';
|
||||||
|
import TransactionsLockingList from './TransactionsLockingList';
|
||||||
|
|
||||||
|
export default function TransactionsLockingPage() {
|
||||||
|
return (
|
||||||
|
<TransactionsLockingProvider>
|
||||||
|
<TransactionsLockingList />
|
||||||
|
</TransactionsLockingProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
|
import { useTransactionsLocking } from 'hooks/query';
|
||||||
|
|
||||||
const TransactionsLockingContext = React.createContext();
|
const TransactionsLockingContext = React.createContext();
|
||||||
|
|
||||||
@@ -7,13 +8,22 @@ const TransactionsLockingContext = React.createContext();
|
|||||||
* Transactions locking data provider.
|
* Transactions locking data provider.
|
||||||
*/
|
*/
|
||||||
function TransactionsLockingProvider({ ...props }) {
|
function TransactionsLockingProvider({ ...props }) {
|
||||||
|
// Fetch
|
||||||
|
const {
|
||||||
|
data: transactionsLocking,
|
||||||
|
isFetching: isTransactionLockingFetching,
|
||||||
|
isLoading: isTransactionLockingLoading,
|
||||||
|
} = useTransactionsLocking();
|
||||||
|
|
||||||
|
console.log(transactionsLocking, 'XX');
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {};
|
const provider = {
|
||||||
|
transactionsLocking,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider
|
<DashboardInsider loading={isTransactionLockingLoading}>
|
||||||
// loading={}
|
|
||||||
>
|
|
||||||
<TransactionsLockingContext.Provider value={provider} {...props} />
|
<TransactionsLockingContext.Provider value={provider} {...props} />
|
||||||
</DashboardInsider>
|
</DashboardInsider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export const TransactionLockingContent = ({
|
|||||||
const handleUnlockFull = (event) => {
|
const handleUnlockFull = (event) => {
|
||||||
safeInvoke(onUnlockFull, module, event);
|
safeInvoke(onUnlockFull, module, event);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransactionLockingWrapp>
|
<TransactionLockingWrapp>
|
||||||
<TransLockingInner>
|
<TransLockingInner>
|
||||||
@@ -44,15 +45,10 @@ export const TransactionLockingContent = ({
|
|||||||
|
|
||||||
<TransLockingContent>
|
<TransLockingContent>
|
||||||
<TransLockingItemTitle>
|
<TransLockingItemTitle>
|
||||||
<T id={name} />{' '}
|
{name}
|
||||||
<Hint
|
<Hint content={description} position={Position.BOTTOM_LEFT} />
|
||||||
content={
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do'
|
|
||||||
}
|
|
||||||
position={Position.BOTTOM_LEFT}
|
|
||||||
/>
|
|
||||||
</TransLockingItemTitle>
|
</TransLockingItemTitle>
|
||||||
<TransLockingItemDesc>{description}</TransLockingItemDesc>
|
<TransLockingItemDesc>{''}</TransLockingItemDesc>
|
||||||
</TransLockingContent>
|
</TransLockingContent>
|
||||||
|
|
||||||
<TransLockingActions>
|
<TransLockingActions>
|
||||||
|
|||||||
@@ -85,3 +85,18 @@ export function useCancelUnlockingPartialTransactions(props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrive the transactions locking.
|
||||||
|
*/
|
||||||
|
export function useTransactionsLocking(query, props) {
|
||||||
|
return useRequestQuery(
|
||||||
|
[t.TRANSACTIONS_LOCKING, query],
|
||||||
|
{ method: 'get', url: 'transactions-locking', params: query },
|
||||||
|
{
|
||||||
|
select: (res) => res.data.data,
|
||||||
|
defaultData: [],
|
||||||
|
...props,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -875,7 +875,7 @@ export const getDashboardRoutes = () => [
|
|||||||
{
|
{
|
||||||
path: `/transactions-locking`,
|
path: `/transactions-locking`,
|
||||||
component: lazy(() =>
|
component: lazy(() =>
|
||||||
import('../containers/TransactionsLocking/TransactionsLockingList'),
|
import('../containers/TransactionsLocking/TransactionsLockingPage'),
|
||||||
),
|
),
|
||||||
pageTitle: intl.get('sidebar.transactions_locaking'),
|
pageTitle: intl.get('sidebar.transactions_locaking'),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user