From 1150cb48da65818202bf36f96683cdfe9596abd9 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Mon, 23 Aug 2021 19:31:02 +0200 Subject: [PATCH] feat: content & item detail. --- client/src/components/Details/index.js | 17 +---- client/src/components/DrawersContainer.js | 4 + .../Alerts/Customers/CustomerDeleteAlert.js | 6 +- .../Alerts/Vendors/VendorDeleteAlert.js | 6 +- .../CustomersLanding/CustomersTable.js | 16 +++- .../Customers/CustomersLanding/components.js | 10 ++- .../ContactDetailDrawer/ContactDetail.js | 18 +++++ .../ContactDetailActionsBar.js | 73 +++++++++++++++++++ .../ContactDetailDrawerContent.js | 20 +++++ .../ContactDetailDrawerProvider.js | 36 +++++++++ .../ContactDetailDrawer/ContactDetailList.js | 48 ++++++++++++ .../Drawers/ContactDetailDrawer/index.js | 30 ++++++++ .../Drawers/ItemDetailDrawer/ItemDetail.js | 21 ++++++ .../ItemDetailDrawer/ItemDetailActionsBar.js | 71 ++++++++++++++++++ .../ItemDetailDrawerContent.js | 20 +++++ .../ItemDetailDrawerProvider.js | 32 ++++++++ .../ItemDetailDrawer/ItemDetailList.js | 49 +++++++++++++ .../Drawers/ItemDetailDrawer/index.js | 29 ++++++++ client/src/containers/Items/ItemsDataTable.js | 11 +++ client/src/containers/Items/components.js | 5 +- .../Vendors/VendorsLanding/VendorsTable.js | 16 +++- .../Vendors/VendorsLanding/components.js | 10 ++- client/src/lang/en/index.json | 3 +- client/src/style/components/Details.scss | 16 ++-- .../Drawers/ViewDetail/ViewDetail.scss | 4 + 25 files changed, 535 insertions(+), 36 deletions(-) create mode 100644 client/src/containers/Drawers/ContactDetailDrawer/ContactDetail.js create mode 100644 client/src/containers/Drawers/ContactDetailDrawer/ContactDetailActionsBar.js create mode 100644 client/src/containers/Drawers/ContactDetailDrawer/ContactDetailDrawerContent.js create mode 100644 client/src/containers/Drawers/ContactDetailDrawer/ContactDetailDrawerProvider.js create mode 100644 client/src/containers/Drawers/ContactDetailDrawer/ContactDetailList.js create mode 100644 client/src/containers/Drawers/ContactDetailDrawer/index.js create mode 100644 client/src/containers/Drawers/ItemDetailDrawer/ItemDetail.js create mode 100644 client/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsBar.js create mode 100644 client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerContent.js create mode 100644 client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerProvider.js create mode 100644 client/src/containers/Drawers/ItemDetailDrawer/ItemDetailList.js create mode 100644 client/src/containers/Drawers/ItemDetailDrawer/index.js diff --git a/client/src/components/Details/index.js b/client/src/components/Details/index.js index c96252136..e427336ee 100644 --- a/client/src/components/Details/index.js +++ b/client/src/components/Details/index.js @@ -1,6 +1,5 @@ import React from 'react'; import classNames from 'classnames'; -import { Col, Row } from 'components'; import 'style/components/Details.scss'; @@ -22,7 +21,7 @@ export function DetailsMenu({ children, vertical = false }) { /** * Detail item vertical . */ -export function DetailItemVER({ label, children }) { +export function DetailItem({ label, children }) { return (
{label}
@@ -30,17 +29,3 @@ export function DetailItemVER({ label, children }) {
); } - -/** - * Detail item horizontal . - */ -export function DetailItemHOR({ label, children }) { - return ( - - - {label} - - {children} - - ); -} diff --git a/client/src/components/DrawersContainer.js b/client/src/components/DrawersContainer.js index acc556105..83af86bcd 100644 --- a/client/src/components/DrawersContainer.js +++ b/client/src/components/DrawersContainer.js @@ -12,6 +12,8 @@ import ReceiptDetailDrawer from 'containers/Drawers/ReceiptDetailDrawer'; import PaymentReceiveDetailDrawer from 'containers/Drawers/PaymentReceiveDetailDrawer'; import PaymentMadeDetailDrawer from 'containers/Drawers/PaymentMadeDetailDrawer'; import EstimateDetailDrawer from '../containers/Drawers/EstimateDetailDrawer'; +import ItemDetailDrawer from '../containers/Drawers/ItemDetailDrawer'; +import ContactDetailDrawer from '../containers/Drawers/ContactDetailDrawer'; export default function DrawersContainer() { return ( @@ -29,6 +31,8 @@ export default function DrawersContainer() { + + ); } diff --git a/client/src/containers/Alerts/Customers/CustomerDeleteAlert.js b/client/src/containers/Alerts/Customers/CustomerDeleteAlert.js index 2b826a9d7..3be974cd6 100644 --- a/client/src/containers/Alerts/Customers/CustomerDeleteAlert.js +++ b/client/src/containers/Alerts/Customers/CustomerDeleteAlert.js @@ -20,7 +20,7 @@ function CustomerDeleteAlert({ // #withAlertStoreConnect isOpen, - payload: { customerId }, + payload: { contactId }, // #withAlertActions closeAlert, @@ -38,7 +38,7 @@ function CustomerDeleteAlert({ // handle confirm delete customer. const handleConfirmDeleteCustomer = useCallback(() => { - deleteCustomerMutate(customerId) + deleteCustomerMutate(contactId) .then(() => { AppToaster.show({ message: intl.get('the_customer_has_been_deleted_successfully'), @@ -51,7 +51,7 @@ function CustomerDeleteAlert({ .finally(() => { closeAlert(name); }); - }, [deleteCustomerMutate, customerId, closeAlert, name]); + }, [deleteCustomerMutate, contactId, closeAlert, name]); return ( { - deleteVendorMutate(vendorId) + deleteVendorMutate(contactId) .then(() => { AppToaster.show({ message: intl.get('the_vendor_has_been_deleted_successfully'), @@ -54,7 +54,7 @@ function VendorDeleteAlert({ .finally(() => { closeAlert(name); }); - }, [deleteVendorMutate, name, closeAlert, vendorId]); + }, [deleteVendorMutate, name, closeAlert, contactId]); return ( { - openAlert('customer-delete', { customerId: customer.id }); + const handleCustomerDelete = ({ id }) => { + openAlert('customer-delete', { contactId: id }); }; // Handle the customer edit action. @@ -85,6 +90,11 @@ function CustomersTable({ openAlert('contact-activate', { contactId: id, service: contact_service }); }; + // Handle view detail contact. + const handleViewDetailCustomer = ({ id }) => { + openDrawer('contact-detail-drawer', { contactId: id }); + }; + if (isEmptyStatus) { return ; } @@ -117,6 +127,7 @@ function CustomersTable({ onDuplicate: handleContactDuplicate, onInactivate: handleInactiveCustomer, onActivate: handleActivateCustomer, + onViewDetails: handleViewDetailCustomer, }} ContextMenu={ActionsMenu} /> @@ -127,5 +138,6 @@ export default compose( withAlertsActions, withDialogActions, withCustomersActions, + withDrawerActions, withCustomers(({ customersTableState }) => ({ customersTableState })), )(CustomersTable); diff --git a/client/src/containers/Customers/CustomersLanding/components.js b/client/src/containers/Customers/CustomersLanding/components.js index 2c29c2112..8b23d3bbd 100644 --- a/client/src/containers/Customers/CustomersLanding/components.js +++ b/client/src/containers/Customers/CustomersLanding/components.js @@ -18,13 +18,21 @@ import intl from 'react-intl-universal'; */ export function ActionsMenu({ row: { original }, - payload: { onEdit, onDelete, onDuplicate, onInactivate, onActivate }, + payload: { + onEdit, + onDelete, + onDuplicate, + onInactivate, + onActivate, + onViewDetails, + }, }) { return ( } text={intl.get('view_details')} + onClick={safeCallback(onViewDetails, original)} /> + + + + + + ); +} diff --git a/client/src/containers/Drawers/ContactDetailDrawer/ContactDetailActionsBar.js b/client/src/containers/Drawers/ContactDetailDrawer/ContactDetailActionsBar.js new file mode 100644 index 000000000..7c4feb564 --- /dev/null +++ b/client/src/containers/Drawers/ContactDetailDrawer/ContactDetailActionsBar.js @@ -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 ( + + +