mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: handle switch button item transaction.
This commit is contained in:
@@ -1,30 +1,22 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import { Card } from 'components';
|
||||||
import { Card, FormattedMessage as T } from 'components';
|
|
||||||
import { ItemManuTransaction } from './utils';
|
import { ItemManuTransaction } from './utils';
|
||||||
import { useItemDetailDrawerContext } from '../ItemDetailDrawerProvider';
|
import { useItemDetailDrawerContext } from '../ItemDetailDrawerProvider';
|
||||||
import ItemPaymentTransactionContent from './ItemPaymentTransactionContent';
|
import ItemPaymentTransactionContent from './ItemPaymentTransactionContent';
|
||||||
|
|
||||||
export const ItemPaymentTransactions = () => {
|
export const ItemPaymentTransactions = () => {
|
||||||
const { value } = useItemDetailDrawerContext();
|
const { value, setValue } = useItemDetailDrawerContext();
|
||||||
|
|
||||||
|
// handle item change.
|
||||||
|
const handleItemChange = (item) => {
|
||||||
|
setValue(item);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<ItemManuTransactions>
|
<ItemManuTransaction onChange={handleItemChange} />
|
||||||
<T id={'item.drawer_transactions_by'} />
|
|
||||||
<ItemManuTransaction />
|
|
||||||
</ItemManuTransactions>
|
|
||||||
<ItemPaymentTransactionContent tansactionType={value} />
|
<ItemPaymentTransactionContent tansactionType={value} />
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ItemManuTransactions = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
color: #727983;
|
|
||||||
.bp3-button {
|
|
||||||
padding-left: 6px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -7,19 +7,20 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
import styled from 'styled-components';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
import { useItemDetailDrawerContext } from '../ItemDetailDrawerProvider';
|
import { useItemDetailDrawerContext } from '../ItemDetailDrawerProvider';
|
||||||
import transactions from '../../../../common/itemPaymentTranactionsOption';
|
import transactions from '../../../../common/itemPaymentTranactionsOption';
|
||||||
|
|
||||||
export const ItemManuTransaction = () => {
|
export const ItemManuTransaction = ({ onChange }) => {
|
||||||
const { value, setValue } = useItemDetailDrawerContext();
|
const { value, setValue } = useItemDetailDrawerContext();
|
||||||
|
|
||||||
// const handleClickItem = (item) => {
|
const handleClickItem = (item) => {
|
||||||
// onChange && onChange(item);
|
onChange && onChange(item);
|
||||||
// };
|
};
|
||||||
|
|
||||||
const content = transactions.map(({ name, label }) => (
|
const content = transactions.map(({ name, label }) => (
|
||||||
<MenuItem onClick={() => setValue(name)} text={label} />
|
<MenuItem onClick={() => handleClickItem(name)} text={label} />
|
||||||
));
|
));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -32,7 +33,28 @@ export const ItemManuTransaction = () => {
|
|||||||
}}
|
}}
|
||||||
content={<Menu>{content}</Menu>}
|
content={<Menu>{content}</Menu>}
|
||||||
>
|
>
|
||||||
<Button minimal={true} text={<T id={value} />} rightIcon={'caret-down'} />
|
<ItemSwitchButton
|
||||||
|
minimal={true}
|
||||||
|
text={<T id={'item.drawer_transactions_by'} />}
|
||||||
|
rightIcon={'caret-down'}
|
||||||
|
>
|
||||||
|
<ItemSwitchText>
|
||||||
|
<T id={value} />
|
||||||
|
</ItemSwitchText>
|
||||||
|
</ItemSwitchButton>
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ItemSwitchButton = styled(Button)`
|
||||||
|
.bp3-button-text {
|
||||||
|
display: flex;
|
||||||
|
color: #727983;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ItemSwitchText = styled.span`
|
||||||
|
font-weight: 600;
|
||||||
|
color: #33304a;
|
||||||
|
padding-left: 3px;
|
||||||
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user