mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +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 styled from 'styled-components';
|
||||
import clsx from 'classnames';
|
||||
import { TransactionsLockingProvider } from './TransactionsLockingProvider';
|
||||
import { TransactionLockingContent } from './components';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
import { useTransactionsLockingContext } from './TransactionsLockingProvider';
|
||||
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 }) {
|
||||
return <p className={clsx('paragraph', className)}>{children}</p>;
|
||||
}
|
||||
|
||||
function TransactionsLockingList({ items }) {
|
||||
return items.map(({ isEnabled, name, description }) => (
|
||||
function TransactionsLockingList({ items, onlock, onUnlock, onUnlockPartial }) {
|
||||
return items.map(({ is_enabled, formatted_module, description }) => (
|
||||
<TransactionLockingContent
|
||||
name={name}
|
||||
name={formatted_module}
|
||||
description={description}
|
||||
isEnabled={isEnabled}
|
||||
isEnabled={is_enabled}
|
||||
onLock={onlock}
|
||||
onUnlockPartial={onUnlockPartial}
|
||||
onEditLock={onUnlock}
|
||||
/>
|
||||
));
|
||||
}
|
||||
@@ -52,28 +31,44 @@ function TransactionsLockingListPage({
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
}) {
|
||||
// Handle switch transactions locking.
|
||||
const handleSwitchTransactionsLocking = () => {
|
||||
// Handle locking transactions.
|
||||
const handleLockingTransactions = () => {
|
||||
openDialog('locking-transactions', {});
|
||||
};
|
||||
|
||||
return (
|
||||
<TransactionsLockingProvider>
|
||||
<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>
|
||||
// Handle unlocking transactions
|
||||
const handleUnlockTransactions = () => {
|
||||
openDialog('unlocking-transactions', {});
|
||||
};
|
||||
// Handle unlocking transactions
|
||||
const handleUnlockingPartial = () => {
|
||||
openDialog('unlocking-partial-transactions', {});
|
||||
};
|
||||
|
||||
<TransactionsLockingList items={DataTest} />
|
||||
</TransactionsLocking>
|
||||
</TransactionsLockingProvider>
|
||||
const {
|
||||
transactionsLocking: { modules },
|
||||
} = 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);
|
||||
|
||||
@@ -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 DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||
import { useTransactionsLocking } from 'hooks/query';
|
||||
|
||||
const TransactionsLockingContext = React.createContext();
|
||||
|
||||
@@ -7,13 +8,22 @@ const TransactionsLockingContext = React.createContext();
|
||||
* Transactions locking data provider.
|
||||
*/
|
||||
function TransactionsLockingProvider({ ...props }) {
|
||||
// Fetch
|
||||
const {
|
||||
data: transactionsLocking,
|
||||
isFetching: isTransactionLockingFetching,
|
||||
isLoading: isTransactionLockingLoading,
|
||||
} = useTransactionsLocking();
|
||||
|
||||
console.log(transactionsLocking, 'XX');
|
||||
|
||||
// Provider
|
||||
const provider = {};
|
||||
const provider = {
|
||||
transactionsLocking,
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardInsider
|
||||
// loading={}
|
||||
>
|
||||
<DashboardInsider loading={isTransactionLockingLoading}>
|
||||
<TransactionsLockingContext.Provider value={provider} {...props} />
|
||||
</DashboardInsider>
|
||||
);
|
||||
|
||||
@@ -35,6 +35,7 @@ export const TransactionLockingContent = ({
|
||||
const handleUnlockFull = (event) => {
|
||||
safeInvoke(onUnlockFull, module, event);
|
||||
};
|
||||
|
||||
return (
|
||||
<TransactionLockingWrapp>
|
||||
<TransLockingInner>
|
||||
@@ -44,15 +45,10 @@ export const TransactionLockingContent = ({
|
||||
|
||||
<TransLockingContent>
|
||||
<TransLockingItemTitle>
|
||||
<T id={name} />{' '}
|
||||
<Hint
|
||||
content={
|
||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do'
|
||||
}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
/>
|
||||
{name}
|
||||
<Hint content={description} position={Position.BOTTOM_LEFT} />
|
||||
</TransLockingItemTitle>
|
||||
<TransLockingItemDesc>{description}</TransLockingItemDesc>
|
||||
<TransLockingItemDesc>{''}</TransLockingItemDesc>
|
||||
</TransLockingContent>
|
||||
|
||||
<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`,
|
||||
component: lazy(() =>
|
||||
import('../containers/TransactionsLocking/TransactionsLockingList'),
|
||||
import('../containers/TransactionsLocking/TransactionsLockingPage'),
|
||||
),
|
||||
pageTitle: intl.get('sidebar.transactions_locaking'),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user