mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat: content & item detail.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Col, Row } from 'components';
|
|
||||||
|
|
||||||
import 'style/components/Details.scss';
|
import 'style/components/Details.scss';
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ export function DetailsMenu({ children, vertical = false }) {
|
|||||||
/**
|
/**
|
||||||
* Detail item vertical .
|
* Detail item vertical .
|
||||||
*/
|
*/
|
||||||
export function DetailItemVER({ label, children }) {
|
export function DetailItem({ label, children }) {
|
||||||
return (
|
return (
|
||||||
<div class="detail-item">
|
<div class="detail-item">
|
||||||
<div class="detail-item__label">{label}</div>
|
<div class="detail-item__label">{label}</div>
|
||||||
@@ -30,17 +29,3 @@ export function DetailItemVER({ label, children }) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Detail item horizontal .
|
|
||||||
*/
|
|
||||||
export function DetailItemHOR({ label, children }) {
|
|
||||||
return (
|
|
||||||
<Row>
|
|
||||||
<Col className="label" xs={3}>
|
|
||||||
{label}
|
|
||||||
</Col>
|
|
||||||
<Col xs={3}>{children}</Col>
|
|
||||||
</Row>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import ReceiptDetailDrawer from 'containers/Drawers/ReceiptDetailDrawer';
|
|||||||
import PaymentReceiveDetailDrawer from 'containers/Drawers/PaymentReceiveDetailDrawer';
|
import PaymentReceiveDetailDrawer from 'containers/Drawers/PaymentReceiveDetailDrawer';
|
||||||
import PaymentMadeDetailDrawer from 'containers/Drawers/PaymentMadeDetailDrawer';
|
import PaymentMadeDetailDrawer from 'containers/Drawers/PaymentMadeDetailDrawer';
|
||||||
import EstimateDetailDrawer from '../containers/Drawers/EstimateDetailDrawer';
|
import EstimateDetailDrawer from '../containers/Drawers/EstimateDetailDrawer';
|
||||||
|
import ItemDetailDrawer from '../containers/Drawers/ItemDetailDrawer';
|
||||||
|
import ContactDetailDrawer from '../containers/Drawers/ContactDetailDrawer';
|
||||||
|
|
||||||
export default function DrawersContainer() {
|
export default function DrawersContainer() {
|
||||||
return (
|
return (
|
||||||
@@ -29,6 +31,8 @@ export default function DrawersContainer() {
|
|||||||
<ReceiptDetailDrawer name={'receipt-detail-drawer'} />
|
<ReceiptDetailDrawer name={'receipt-detail-drawer'} />
|
||||||
<PaymentReceiveDetailDrawer name={'payment-receive-detail-drawer'} />
|
<PaymentReceiveDetailDrawer name={'payment-receive-detail-drawer'} />
|
||||||
<PaymentMadeDetailDrawer name={'payment-made-detail-drawer'} />
|
<PaymentMadeDetailDrawer name={'payment-made-detail-drawer'} />
|
||||||
|
<ItemDetailDrawer name={'item-detail-drawer'} />
|
||||||
|
<ContactDetailDrawer name={'contact-detail-drawer'} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function CustomerDeleteAlert({
|
|||||||
|
|
||||||
// #withAlertStoreConnect
|
// #withAlertStoreConnect
|
||||||
isOpen,
|
isOpen,
|
||||||
payload: { customerId },
|
payload: { contactId },
|
||||||
|
|
||||||
// #withAlertActions
|
// #withAlertActions
|
||||||
closeAlert,
|
closeAlert,
|
||||||
@@ -38,7 +38,7 @@ function CustomerDeleteAlert({
|
|||||||
|
|
||||||
// handle confirm delete customer.
|
// handle confirm delete customer.
|
||||||
const handleConfirmDeleteCustomer = useCallback(() => {
|
const handleConfirmDeleteCustomer = useCallback(() => {
|
||||||
deleteCustomerMutate(customerId)
|
deleteCustomerMutate(contactId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: intl.get('the_customer_has_been_deleted_successfully'),
|
message: intl.get('the_customer_has_been_deleted_successfully'),
|
||||||
@@ -51,7 +51,7 @@ function CustomerDeleteAlert({
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
});
|
});
|
||||||
}, [deleteCustomerMutate, customerId, closeAlert, name]);
|
}, [deleteCustomerMutate, contactId, closeAlert, name]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Alert
|
<Alert
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function VendorDeleteAlert({
|
|||||||
|
|
||||||
// #withAlertStoreConnect
|
// #withAlertStoreConnect
|
||||||
isOpen,
|
isOpen,
|
||||||
payload: { vendorId },
|
payload: { contactId },
|
||||||
|
|
||||||
// #withAlertActions
|
// #withAlertActions
|
||||||
closeAlert,
|
closeAlert,
|
||||||
@@ -35,7 +35,7 @@ function VendorDeleteAlert({
|
|||||||
|
|
||||||
// Handle confirm delete vendor.
|
// Handle confirm delete vendor.
|
||||||
const handleConfirmDeleteVendor = useCallback(() => {
|
const handleConfirmDeleteVendor = useCallback(() => {
|
||||||
deleteVendorMutate(vendorId)
|
deleteVendorMutate(contactId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: intl.get('the_vendor_has_been_deleted_successfully'),
|
message: intl.get('the_vendor_has_been_deleted_successfully'),
|
||||||
@@ -54,7 +54,7 @@ function VendorDeleteAlert({
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
});
|
});
|
||||||
}, [deleteVendorMutate, name, closeAlert, vendorId]);
|
}, [deleteVendorMutate, name, closeAlert, contactId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Alert
|
<Alert
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import withCustomers from './withCustomers';
|
|||||||
import withCustomersActions from './withCustomersActions';
|
import withCustomersActions from './withCustomersActions';
|
||||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
import { useCustomersListContext } from './CustomersListProvider';
|
import { useCustomersListContext } from './CustomersListProvider';
|
||||||
import { ActionsMenu, useCustomersTableColumns } from './components';
|
import { ActionsMenu, useCustomersTableColumns } from './components';
|
||||||
@@ -29,6 +30,10 @@ function CustomersTable({
|
|||||||
|
|
||||||
// #withAlerts
|
// #withAlerts
|
||||||
openAlert,
|
openAlert,
|
||||||
|
|
||||||
|
// #withDrawerActions
|
||||||
|
openDrawer,
|
||||||
|
|
||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
openDialog,
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
@@ -59,8 +64,8 @@ function CustomersTable({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Handles the customer delete action.
|
// Handles the customer delete action.
|
||||||
const handleCustomerDelete = (customer) => {
|
const handleCustomerDelete = ({ id }) => {
|
||||||
openAlert('customer-delete', { customerId: customer.id });
|
openAlert('customer-delete', { contactId: id });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the customer edit action.
|
// Handle the customer edit action.
|
||||||
@@ -85,6 +90,11 @@ function CustomersTable({
|
|||||||
openAlert('contact-activate', { contactId: id, service: contact_service });
|
openAlert('contact-activate', { contactId: id, service: contact_service });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle view detail contact.
|
||||||
|
const handleViewDetailCustomer = ({ id }) => {
|
||||||
|
openDrawer('contact-detail-drawer', { contactId: id });
|
||||||
|
};
|
||||||
|
|
||||||
if (isEmptyStatus) {
|
if (isEmptyStatus) {
|
||||||
return <CustomersEmptyStatus />;
|
return <CustomersEmptyStatus />;
|
||||||
}
|
}
|
||||||
@@ -117,6 +127,7 @@ function CustomersTable({
|
|||||||
onDuplicate: handleContactDuplicate,
|
onDuplicate: handleContactDuplicate,
|
||||||
onInactivate: handleInactiveCustomer,
|
onInactivate: handleInactiveCustomer,
|
||||||
onActivate: handleActivateCustomer,
|
onActivate: handleActivateCustomer,
|
||||||
|
onViewDetails: handleViewDetailCustomer,
|
||||||
}}
|
}}
|
||||||
ContextMenu={ActionsMenu}
|
ContextMenu={ActionsMenu}
|
||||||
/>
|
/>
|
||||||
@@ -127,5 +138,6 @@ export default compose(
|
|||||||
withAlertsActions,
|
withAlertsActions,
|
||||||
withDialogActions,
|
withDialogActions,
|
||||||
withCustomersActions,
|
withCustomersActions,
|
||||||
|
withDrawerActions,
|
||||||
withCustomers(({ customersTableState }) => ({ customersTableState })),
|
withCustomers(({ customersTableState }) => ({ customersTableState })),
|
||||||
)(CustomersTable);
|
)(CustomersTable);
|
||||||
|
|||||||
@@ -18,13 +18,21 @@ import intl from 'react-intl-universal';
|
|||||||
*/
|
*/
|
||||||
export function ActionsMenu({
|
export function ActionsMenu({
|
||||||
row: { original },
|
row: { original },
|
||||||
payload: { onEdit, onDelete, onDuplicate, onInactivate, onActivate },
|
payload: {
|
||||||
|
onEdit,
|
||||||
|
onDelete,
|
||||||
|
onDuplicate,
|
||||||
|
onInactivate,
|
||||||
|
onActivate,
|
||||||
|
onViewDetails,
|
||||||
|
},
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={<Icon icon="reader-18" />}
|
icon={<Icon icon="reader-18" />}
|
||||||
text={intl.get('view_details')}
|
text={intl.get('view_details')}
|
||||||
|
onClick={safeCallback(onViewDetails, original)}
|
||||||
/>
|
/>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ContactDetailActionsBar from './ContactDetailActionsBar';
|
||||||
|
import ContactDetailList from './ContactDetailList';
|
||||||
|
import { Card } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* contact detail.
|
||||||
|
*/
|
||||||
|
export default function ContactDetail() {
|
||||||
|
return (
|
||||||
|
<div className="view-detail-drawer">
|
||||||
|
<ContactDetailActionsBar />
|
||||||
|
<Card>
|
||||||
|
<ContactDetailList />
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
NavbarGroup,
|
||||||
|
Classes,
|
||||||
|
NavbarDivider,
|
||||||
|
Intent,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||||
|
|
||||||
|
import { useContactDetailDrawerContext } from './ContactDetailDrawerProvider';
|
||||||
|
|
||||||
|
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||||
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
|
import { Icon, FormattedMessage as T } from 'components';
|
||||||
|
|
||||||
|
import { safeCallback, compose } from 'utils';
|
||||||
|
|
||||||
|
function ContactDetailActionsBar({
|
||||||
|
// #withAlertsActions
|
||||||
|
openAlert,
|
||||||
|
|
||||||
|
// #withDrawerActions
|
||||||
|
closeDrawer,
|
||||||
|
}) {
|
||||||
|
const { contact, contactId } = useContactDetailDrawerContext();
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
// Handle edit contact.
|
||||||
|
const onEditContact = () => {
|
||||||
|
return contactId
|
||||||
|
? (history.push(`/${contact?.contact_service}s/${contactId}/edit`),
|
||||||
|
closeDrawer('contact-detail-drawer'))
|
||||||
|
: null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle delete contact.
|
||||||
|
const onDeleteContact = () => {
|
||||||
|
return contactId
|
||||||
|
? (openAlert(`${contact?.contact_service}-delete`, { contactId }),
|
||||||
|
closeDrawer('contact-detail-drawer'))
|
||||||
|
: null;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="pen-18" />}
|
||||||
|
text={intl.get('edit_contact', { name: contact?.contact_service })}
|
||||||
|
onClick={safeCallback(onEditContact)}
|
||||||
|
/>
|
||||||
|
<NavbarDivider />
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
onClick={safeCallback(onDeleteContact)}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default compose(
|
||||||
|
withDrawerActions,
|
||||||
|
withAlertsActions,
|
||||||
|
)(ContactDetailActionsBar);
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import ContactDetail from './ContactDetail';
|
||||||
|
import { ContactDetailDrawerProvider } from './ContactDetailDrawerProvider';
|
||||||
|
|
||||||
|
import 'style/components/Drawers/ViewDetail/ViewDetail.scss';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contact detail drawer content.
|
||||||
|
*/
|
||||||
|
export default function ContactDetailDrawerContent({
|
||||||
|
// #ownProp
|
||||||
|
contact,
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<ContactDetailDrawerProvider contactId={contact}>
|
||||||
|
<ContactDetail />
|
||||||
|
</ContactDetailDrawerProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||||
|
import { useContact } from 'hooks/query';
|
||||||
|
|
||||||
|
const ContactDetailDrawerContext = React.createContext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contact detail provider.
|
||||||
|
*/
|
||||||
|
function ContactDetailDrawerProvider({ contactId, ...props }) {
|
||||||
|
// Handle fetch contact duplicate details.
|
||||||
|
const { data: contact, isLoading: isContactLoading } = useContact(contactId, {
|
||||||
|
enabled: !!contactId,
|
||||||
|
});
|
||||||
|
//provider.
|
||||||
|
const provider = {
|
||||||
|
contact,
|
||||||
|
contactId,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DashboardInsider loading={isContactLoading}>
|
||||||
|
<DrawerHeaderContent
|
||||||
|
name="contact-detail-drawer"
|
||||||
|
title={contact?.display_name}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ContactDetailDrawerContext.Provider value={provider} {...props} />
|
||||||
|
</DashboardInsider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const useContactDetailDrawerContext = () =>
|
||||||
|
React.useContext(ContactDetailDrawerContext);
|
||||||
|
|
||||||
|
export { ContactDetailDrawerProvider, useContactDetailDrawerContext };
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Money } from 'components';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import { useContactDetailDrawerContext } from './ContactDetailDrawerProvider';
|
||||||
|
import { DetailItem } from '../../../components/Details';
|
||||||
|
|
||||||
|
export default function ContactDetailList({}) {
|
||||||
|
const { contact } = useContactDetailDrawerContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="details-menu">
|
||||||
|
<div className="details-menu--vertical">
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('display_name')}
|
||||||
|
children={contact.display_name}
|
||||||
|
/>
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('balance')}
|
||||||
|
children={
|
||||||
|
<Money
|
||||||
|
amount={contact?.balance}
|
||||||
|
currency={contact?.currency_code}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="details-menu--horizontal">
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('closing_balance')}
|
||||||
|
children={
|
||||||
|
<Money
|
||||||
|
amount={contact.closing_balance}
|
||||||
|
currency={contact?.currency_code}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('contact_type')}
|
||||||
|
children={contact.contact_type}
|
||||||
|
/>
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('email')}
|
||||||
|
children={contact.email ? contact.email : '--'}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
30
client/src/containers/Drawers/ContactDetailDrawer/index.js
Normal file
30
client/src/containers/Drawers/ContactDetailDrawer/index.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Drawer, DrawerSuspense } from 'components';
|
||||||
|
import withDrawers from 'containers/Drawer/withDrawers';
|
||||||
|
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
const ContactDetailDrawerContent = React.lazy(() =>
|
||||||
|
import('./ContactDetailDrawerContent'),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contact detail drawer.
|
||||||
|
*/
|
||||||
|
function ContactDetailDrawer({
|
||||||
|
name,
|
||||||
|
|
||||||
|
// #withDrawer
|
||||||
|
isOpen,
|
||||||
|
payload: { contactId },
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Drawer isOpen={isOpen} name={name} size={'750px'}>
|
||||||
|
<DrawerSuspense>
|
||||||
|
<ContactDetailDrawerContent contact={contactId} />
|
||||||
|
</DrawerSuspense>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default compose(withDrawers())(ContactDetailDrawer);
|
||||||
21
client/src/containers/Drawers/ItemDetailDrawer/ItemDetail.js
Normal file
21
client/src/containers/Drawers/ItemDetailDrawer/ItemDetail.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { useItemDetailDrawerContext } from './ItemDetailDrawerProvider';
|
||||||
|
import ItemDetailActionsBar from './ItemDetailActionsBar';
|
||||||
|
import ItemDetailList from './ItemDetailList';
|
||||||
|
import { Card } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item detail.
|
||||||
|
*/
|
||||||
|
export default function ItemDetail() {
|
||||||
|
const { itemId, item } = useItemDetailDrawerContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="view-detail-drawer">
|
||||||
|
<ItemDetailActionsBar itemId={itemId} />
|
||||||
|
<Card>
|
||||||
|
<ItemDetailList item={item} />
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
NavbarGroup,
|
||||||
|
Classes,
|
||||||
|
NavbarDivider,
|
||||||
|
Intent,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||||
|
|
||||||
|
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||||
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
|
import { Icon, FormattedMessage as T } from 'components';
|
||||||
|
|
||||||
|
import { safeCallback, compose } from 'utils';
|
||||||
|
|
||||||
|
function ItemDetailActionsBar({
|
||||||
|
itemId,
|
||||||
|
|
||||||
|
// #withAlertsActions
|
||||||
|
openAlert,
|
||||||
|
|
||||||
|
// #withDrawerActions
|
||||||
|
closeDrawer,
|
||||||
|
}) {
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
// Handle edit item.
|
||||||
|
const onEditItem = () => {
|
||||||
|
return itemId
|
||||||
|
? (history.push(`/items/${itemId}/edit`),
|
||||||
|
closeDrawer('item-detail-drawer'))
|
||||||
|
: null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle delete item.
|
||||||
|
const onDeleteItem = () => {
|
||||||
|
return itemId
|
||||||
|
? (openAlert('item-delete', { itemId }),
|
||||||
|
closeDrawer('item-detail-drawer'))
|
||||||
|
: null;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DashboardActionsBar>
|
||||||
|
<NavbarGroup>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="pen-18" />}
|
||||||
|
text={<T id={'edit_item'} />}
|
||||||
|
onClick={safeCallback(onEditItem)}
|
||||||
|
/>
|
||||||
|
<NavbarDivider />
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||||
|
text={<T id={'delete'} />}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
onClick={safeCallback(onDeleteItem)}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
|
</DashboardActionsBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default compose(
|
||||||
|
withDrawerActions,
|
||||||
|
withAlertsActions,
|
||||||
|
)(ItemDetailActionsBar);
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import 'style/components/Drawers/ViewDetail/ViewDetail.scss';
|
||||||
|
|
||||||
|
import ItemDetail from './ItemDetail';
|
||||||
|
import { ItemDetailDrawerProvider } from './ItemDetailDrawerProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item detail drawer content.
|
||||||
|
*/
|
||||||
|
export default function ItemDetailDrawerContent({
|
||||||
|
// #ownProp
|
||||||
|
item,
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<ItemDetailDrawerProvider itemId={item}>
|
||||||
|
<ItemDetail />
|
||||||
|
</ItemDetailDrawerProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||||
|
import { useItem } from 'hooks/query';
|
||||||
|
|
||||||
|
const ItemDetailDrawerContext = React.createContext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item detail provider
|
||||||
|
*/
|
||||||
|
function ItemDetailDrawerProvider({ itemId, ...props }) {
|
||||||
|
// Fetches the given item detail.
|
||||||
|
const { isLoading: isItemLoading, data: item } = useItem(itemId, {
|
||||||
|
enabled: !!itemId,
|
||||||
|
});
|
||||||
|
|
||||||
|
//provider.
|
||||||
|
const provider = {
|
||||||
|
item,
|
||||||
|
itemId,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DashboardInsider loading={isItemLoading}>
|
||||||
|
<DrawerHeaderContent name="item-detail-drawer" title={item?.name} />
|
||||||
|
<ItemDetailDrawerContext.Provider value={provider} {...props} />
|
||||||
|
</DashboardInsider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const useItemDetailDrawerContext = () =>
|
||||||
|
React.useContext(ItemDetailDrawerContext);
|
||||||
|
|
||||||
|
export { ItemDetailDrawerProvider, useItemDetailDrawerContext };
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
|
import { DetailItem } from '../../../components/Details';
|
||||||
|
|
||||||
|
export default function ItemDetailList({
|
||||||
|
item: {
|
||||||
|
name,
|
||||||
|
code,
|
||||||
|
type,
|
||||||
|
category,
|
||||||
|
sell_price_formatted,
|
||||||
|
cost_price_formatted,
|
||||||
|
cost_account,
|
||||||
|
sell_account,
|
||||||
|
},
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="details-menu">
|
||||||
|
<div className="details-menu--vertical">
|
||||||
|
<DetailItem label={intl.get('item_name')} children={name} />
|
||||||
|
<DetailItem label={intl.get('item_code')} children={code} />
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('sell_price')}
|
||||||
|
children={sell_price_formatted}
|
||||||
|
/>
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('cost_price')}
|
||||||
|
children={cost_price_formatted}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="details-menu--horizontal">
|
||||||
|
<DetailItem label={intl.get('item_type')} children={type} />
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('category_name')}
|
||||||
|
children={category?.name ? category?.name : '--'}
|
||||||
|
/>
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('cost_account_id')}
|
||||||
|
children={cost_account?.name}
|
||||||
|
/>
|
||||||
|
<DetailItem
|
||||||
|
label={intl.get('sell_account_id')}
|
||||||
|
children={sell_account?.name}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
29
client/src/containers/Drawers/ItemDetailDrawer/index.js
Normal file
29
client/src/containers/Drawers/ItemDetailDrawer/index.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Drawer, DrawerSuspense } from 'components';
|
||||||
|
import withDrawers from 'containers/Drawer/withDrawers';
|
||||||
|
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
const ItemDetailDrawerContent = React.lazy(() =>
|
||||||
|
import('./ItemDetailDrawerContent'),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item Detail drawer.
|
||||||
|
*/
|
||||||
|
function ItemDetailDrawer({
|
||||||
|
name,
|
||||||
|
|
||||||
|
// #withDrawer
|
||||||
|
isOpen,
|
||||||
|
payload: { itemId },
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Drawer isOpen={isOpen} name={name} size={'750px'}>
|
||||||
|
<DrawerSuspense>
|
||||||
|
<ItemDetailDrawerContent item={itemId} />
|
||||||
|
</DrawerSuspense>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export default compose(withDrawers())(ItemDetailDrawer);
|
||||||
@@ -12,6 +12,7 @@ import withItems from 'containers/Items/withItems';
|
|||||||
import withItemsActions from 'containers/Items/withItemsActions';
|
import withItemsActions from 'containers/Items/withItemsActions';
|
||||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
import { useItemsListContext } from './ItemsListProvider';
|
import { useItemsListContext } from './ItemsListProvider';
|
||||||
import { useItemsTableColumns, ItemsActionMenuList } from './components';
|
import { useItemsTableColumns, ItemsActionMenuList } from './components';
|
||||||
@@ -30,6 +31,9 @@ function ItemsDataTable({
|
|||||||
// #withAlertsActions
|
// #withAlertsActions
|
||||||
openAlert,
|
openAlert,
|
||||||
|
|
||||||
|
// #withDrawerActions
|
||||||
|
openDrawer,
|
||||||
|
|
||||||
// #withItems
|
// #withItems
|
||||||
itemsTableState,
|
itemsTableState,
|
||||||
|
|
||||||
@@ -93,6 +97,11 @@ function ItemsDataTable({
|
|||||||
history.push(`/items/new?duplicate=${id}`, { action: id });
|
history.push(`/items/new?duplicate=${id}`, { action: id });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle view detail item.
|
||||||
|
const handleViewDetailItem = ({ id }) => {
|
||||||
|
openDrawer('item-detail-drawer', { itemId: id });
|
||||||
|
};
|
||||||
|
|
||||||
// Cannot continue in case the items has empty status.
|
// Cannot continue in case the items has empty status.
|
||||||
if (isEmptyStatus) {
|
if (isEmptyStatus) {
|
||||||
return <ItemsEmptyStatus />;
|
return <ItemsEmptyStatus />;
|
||||||
@@ -129,6 +138,7 @@ function ItemsDataTable({
|
|||||||
onActivateItem: handleActivateItem,
|
onActivateItem: handleActivateItem,
|
||||||
onMakeAdjustment: handleMakeAdjustment,
|
onMakeAdjustment: handleMakeAdjustment,
|
||||||
onDuplicate: handleDuplicate,
|
onDuplicate: handleDuplicate,
|
||||||
|
onViewDetails: handleViewDetailItem,
|
||||||
}}
|
}}
|
||||||
noResults={<T id={'there_is_no_items_in_the_table_yet'} />}
|
noResults={<T id={'there_is_no_items_in_the_table_yet'} />}
|
||||||
{...tableProps}
|
{...tableProps}
|
||||||
@@ -139,6 +149,7 @@ function ItemsDataTable({
|
|||||||
export default compose(
|
export default compose(
|
||||||
withItemsActions,
|
withItemsActions,
|
||||||
withAlertsActions,
|
withAlertsActions,
|
||||||
|
withDrawerActions,
|
||||||
withDialogActions,
|
withDialogActions,
|
||||||
withItems(({ itemsTableState }) => ({ itemsTableState })),
|
withItems(({ itemsTableState }) => ({ itemsTableState })),
|
||||||
)(ItemsDataTable);
|
)(ItemsDataTable);
|
||||||
|
|||||||
@@ -80,14 +80,15 @@ export function ItemsActionMenuList({
|
|||||||
onMakeAdjustment,
|
onMakeAdjustment,
|
||||||
onDeleteItem,
|
onDeleteItem,
|
||||||
onDuplicate,
|
onDuplicate,
|
||||||
|
onViewDetails,
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={<Icon icon="reader-18" />}
|
icon={<Icon icon="reader-18" />}
|
||||||
text={<T id={'view_details'} />}
|
text={<T id={'view_details'} />}
|
||||||
|
onClick={safeCallback(onViewDetails, original)}
|
||||||
/>
|
/>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import withVendorsActions from './withVendorsActions';
|
|||||||
import withVendors from './withVendors';
|
import withVendors from './withVendors';
|
||||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
import { ActionsMenu, useVendorsTableColumns } from './components';
|
import { ActionsMenu, useVendorsTableColumns } from './components';
|
||||||
@@ -28,6 +29,10 @@ function VendorsTable({
|
|||||||
|
|
||||||
// #withAlertsActions
|
// #withAlertsActions
|
||||||
openAlert,
|
openAlert,
|
||||||
|
|
||||||
|
// #withDrawerActions
|
||||||
|
openDrawer,
|
||||||
|
|
||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
openDialog,
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
@@ -66,7 +71,7 @@ function VendorsTable({
|
|||||||
|
|
||||||
// Handle click delete vendor.
|
// Handle click delete vendor.
|
||||||
const handleDeleteVendor = ({ id }) => {
|
const handleDeleteVendor = ({ id }) => {
|
||||||
openAlert('vendor-delete', { vendorId: id });
|
openAlert('vendor-delete', { contactId: id });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle contact duplicate .
|
// Handle contact duplicate .
|
||||||
@@ -75,6 +80,12 @@ function VendorsTable({
|
|||||||
contactId: id,
|
contactId: id,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle view detail item.
|
||||||
|
const handleViewDetailVendor = ({ id }) => {
|
||||||
|
openDrawer('contact-detail-drawer', { contactId: id });
|
||||||
|
};
|
||||||
|
|
||||||
// Handle fetch data once the page index, size or sort by of the table change.
|
// Handle fetch data once the page index, size or sort by of the table change.
|
||||||
const handleFetchData = React.useCallback(
|
const handleFetchData = React.useCallback(
|
||||||
({ pageSize, pageIndex, sortBy }) => {
|
({ pageSize, pageIndex, sortBy }) => {
|
||||||
@@ -119,6 +130,7 @@ function VendorsTable({
|
|||||||
onDuplicate: handleContactDuplicate,
|
onDuplicate: handleContactDuplicate,
|
||||||
onInactivate: handleInactiveVendor,
|
onInactivate: handleInactiveVendor,
|
||||||
onActivate: handleActivateVendor,
|
onActivate: handleActivateVendor,
|
||||||
|
onViewDetails: handleViewDetailVendor,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -128,5 +140,7 @@ export default compose(
|
|||||||
withVendorsActions,
|
withVendorsActions,
|
||||||
withAlertsActions,
|
withAlertsActions,
|
||||||
withDialogActions,
|
withDialogActions,
|
||||||
|
withDrawerActions,
|
||||||
|
|
||||||
withVendors(({ vendorsTableState }) => ({ vendorsTableState })),
|
withVendors(({ vendorsTableState }) => ({ vendorsTableState })),
|
||||||
)(VendorsTable);
|
)(VendorsTable);
|
||||||
|
|||||||
@@ -17,13 +17,21 @@ import { safeCallback, firstLettersArgs } from 'utils';
|
|||||||
*/
|
*/
|
||||||
export function ActionsMenu({
|
export function ActionsMenu({
|
||||||
row: { original },
|
row: { original },
|
||||||
payload: { onEdit, onDelete, onDuplicate, onInactivate, onActivate },
|
payload: {
|
||||||
|
onEdit,
|
||||||
|
onDelete,
|
||||||
|
onDuplicate,
|
||||||
|
onInactivate,
|
||||||
|
onActivate,
|
||||||
|
onViewDetails,
|
||||||
|
},
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={<Icon icon="reader-18" />}
|
icon={<Icon icon="reader-18" />}
|
||||||
text={intl.get('view_details')}
|
text={intl.get('view_details')}
|
||||||
|
onClick={safeCallback(onViewDetails, original)}
|
||||||
/>
|
/>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|||||||
@@ -1208,5 +1208,6 @@
|
|||||||
"pdf_preview.preview.button": "Preview",
|
"pdf_preview.preview.button": "Preview",
|
||||||
"invoice_preview.dialog.title": "Invoice PDF Preview",
|
"invoice_preview.dialog.title": "Invoice PDF Preview",
|
||||||
"estimate_preview.dialog.title":"Estimate PDF Preview",
|
"estimate_preview.dialog.title":"Estimate PDF Preview",
|
||||||
"receipt_preview.dialog.title":"Receipt PDF Preview"
|
"receipt_preview.dialog.title":"Receipt PDF Preview",
|
||||||
|
"edit_contact":"Edit {name}"
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
.details-menu {
|
.details-menu {
|
||||||
margin: 15px;
|
margin: 15px;
|
||||||
border: 1px solid #d2dce2;
|
|
||||||
|
|
||||||
&--vertical {
|
&--vertical {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -8,7 +7,7 @@
|
|||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
// border-bottom: 1px solid #d2dce2;
|
border-bottom: 1px solid #d2dce2;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--horizontal {
|
&--horizontal {
|
||||||
@@ -17,17 +16,22 @@
|
|||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
.label {
|
.detail-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
&__label {
|
||||||
|
flex-basis: 25%;
|
||||||
color: #666666;
|
color: #666666;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.is-vertical {
|
&.is-vertical {
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-item {
|
.detail-item {
|
||||||
flex: 1;
|
flex: 0 0 25%;
|
||||||
line-height: 1.3rem;
|
line-height: 1.3rem;
|
||||||
&__label {
|
&__label {
|
||||||
color: #666666;
|
color: #666666;
|
||||||
|
|||||||
@@ -61,4 +61,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
margin: 15px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user