mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
chrone: sperate client and server to different repos.
This commit is contained in:
24
src/containers/Drawers/VendorDetailsDrawer/VendorDetails.js
Normal file
24
src/containers/Drawers/VendorDetailsDrawer/VendorDetails.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import clsx from 'classnames';
|
||||
|
||||
import { Card } from 'components';
|
||||
|
||||
import VendorDetailsActionsBar from './VendorDetailsActionsBar';
|
||||
import VendorDetailsHeader from './VendorDetailsHeader';
|
||||
|
||||
import Style from './VendorDetailsDrawer.module.scss';
|
||||
|
||||
/**
|
||||
* contact detail.
|
||||
*/
|
||||
export default function CustomerDetails() {
|
||||
return (
|
||||
<div className={clsx(Style.root)}>
|
||||
<VendorDetailsActionsBar />
|
||||
|
||||
<Card>
|
||||
<VendorDetailsHeader />
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import React from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import {
|
||||
Button,
|
||||
NavbarGroup,
|
||||
Classes,
|
||||
NavbarDivider,
|
||||
Intent,
|
||||
PopoverInteractionKind,
|
||||
Position,
|
||||
MenuItem,
|
||||
Menu,
|
||||
Popover,
|
||||
} from '@blueprintjs/core';
|
||||
import clsx from 'classnames';
|
||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||
|
||||
import { useVendorDetailsDrawerContext } from './VendorDetailsDrawerProvider';
|
||||
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
import { Icon, FormattedMessage as T } from 'components';
|
||||
|
||||
import { safeCallback, compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Vendor details actions bar.
|
||||
*/
|
||||
function VendorDetailsActionsBar({
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
|
||||
// #withDrawerActions
|
||||
closeDrawer,
|
||||
}) {
|
||||
const { vendor, vendorId } = useVendorDetailsDrawerContext();
|
||||
const history = useHistory();
|
||||
|
||||
// Handle edit vendor.
|
||||
const onEditContact = () => {
|
||||
history.push(`/vendors/${vendorId}/edit`);
|
||||
closeDrawer('vendor-details-drawer');
|
||||
};
|
||||
|
||||
// Handle delete vendor.
|
||||
const onDeleteContact = () => {
|
||||
openAlert(`vendor-delete`, { contactId: vendorId });
|
||||
closeDrawer('vendor-details-drawer');
|
||||
};
|
||||
|
||||
const handleNewInvoiceClick = () => {
|
||||
history.push('bills/new');
|
||||
closeDrawer('vendor-details-drawer');
|
||||
};
|
||||
|
||||
const handleNewPaymentClick = () => {
|
||||
history.push('payment-mades/new');
|
||||
closeDrawer('vendor-details-drawer');
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={<T id={'vendor.drawer.action.new_invoice'} />}
|
||||
onClick={handleNewInvoiceClick}
|
||||
/>
|
||||
<MenuItem
|
||||
text={<T id={'vendor.drawer.action.new_payment'} />}
|
||||
onClick={handleNewPaymentClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
className={clsx(Classes.MINIMAL)}
|
||||
text={<T id={'vendor.drawer.action.new_transaction'} />}
|
||||
icon={<Icon icon={'plus'} />}
|
||||
/>
|
||||
</Popover>
|
||||
|
||||
<NavbarDivider />
|
||||
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="pen-18" />}
|
||||
text={<T id={'vendor.drawer.action.edit_vendor'} />}
|
||||
onClick={safeCallback(onEditContact)}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||
text={<T id={'vendor.drawer.action.delete'} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDeleteContact)}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
</DashboardActionsBar>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDrawerActions,
|
||||
withAlertsActions,
|
||||
)(VendorDetailsActionsBar);
|
||||
@@ -0,0 +1,17 @@
|
||||
.root {
|
||||
|
||||
|
||||
&_content {
|
||||
|
||||
&_primary {
|
||||
padding-bottom: 15px;
|
||||
border-bottom: 1px solid #e2e2e2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
:global .card {
|
||||
margin: 15px;
|
||||
padding: 18px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
|
||||
import { DrawerBody } from 'components';
|
||||
import VendorDetails from './VendorDetails';
|
||||
import { VendorDetailsDrawerProvider } from './VendorDetailsDrawerProvider';
|
||||
|
||||
/**
|
||||
* Contact detail drawer content.
|
||||
*/
|
||||
export default function VendorDetailsDrawerContent({
|
||||
// #ownProp
|
||||
vendorId,
|
||||
}) {
|
||||
return (
|
||||
<VendorDetailsDrawerProvider vendorId={vendorId}>
|
||||
<DrawerBody>
|
||||
<VendorDetails />
|
||||
</DrawerBody>
|
||||
</VendorDetailsDrawerProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import { DrawerHeaderContent, DrawerLoading } from 'components';
|
||||
import { useVendor } from 'hooks/query';
|
||||
|
||||
const VendorDetailDrawerContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Contact detail provider.
|
||||
*/
|
||||
function VendorDetailsDrawerProvider({ vendorId, ...props }) {
|
||||
// Handle fetch vendor details.
|
||||
const { data: vendor, isLoading: isVendorLoading } = useVendor(vendorId, {
|
||||
enabled: !!vendorId,
|
||||
});
|
||||
// Provider.
|
||||
const provider = {
|
||||
vendor,
|
||||
vendorId,
|
||||
isVendorLoading,
|
||||
};
|
||||
|
||||
return (
|
||||
<DrawerLoading loading={isVendorLoading}>
|
||||
<DrawerHeaderContent
|
||||
name="vendor-details-drawer"
|
||||
title={vendor?.display_name}
|
||||
/>
|
||||
<VendorDetailDrawerContext.Provider value={provider} {...props} />
|
||||
</DrawerLoading>
|
||||
);
|
||||
}
|
||||
|
||||
const useVendorDetailsDrawerContext = () =>
|
||||
React.useContext(VendorDetailDrawerContext);
|
||||
|
||||
export { VendorDetailsDrawerProvider, useVendorDetailsDrawerContext };
|
||||
@@ -0,0 +1,74 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import clsx from 'classnames';
|
||||
import { defaultTo } from 'lodash';
|
||||
|
||||
import { T, DetailsMenu, DetailItem } from 'components';
|
||||
|
||||
import { useVendorDetailsDrawerContext } from './VendorDetailsDrawerProvider';
|
||||
|
||||
import Style from './VendorDetailsDrawer.module.scss';
|
||||
|
||||
/**
|
||||
* Vendor details header.
|
||||
*/
|
||||
export default function VendorDetailsHeader() {
|
||||
const { vendor } = useVendorDetailsDrawerContext();
|
||||
|
||||
return (
|
||||
<div className={clsx(Style.root_content)}>
|
||||
<DetailsMenu
|
||||
direction={'vertical'}
|
||||
className={clsx(Style.root_content_primary)}
|
||||
>
|
||||
<DetailItem
|
||||
name={'outstanding-payable'}
|
||||
label={<T id={'vendor.drawer.label.outstanding_payable'} />}
|
||||
>
|
||||
<h3 class="big-number">{vendor.formatted_balance}</h3>
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem
|
||||
label={<T id={'vendor.drawer.label.vendor'} />}
|
||||
name={'name'}
|
||||
children={vendor?.display_name}
|
||||
/>
|
||||
<DetailItem label={<T id={'vendor.drawer.label.unused_credits'} />}>
|
||||
0
|
||||
</DetailItem>
|
||||
</DetailsMenu>
|
||||
|
||||
<DetailsMenu direction={'horizantal'} minLabelSize={'175px'}>
|
||||
<DetailItem
|
||||
label={<T id={'vendor.drawer.label.company_name'} />}
|
||||
children={defaultTo(vendor?.company_name, '--')}
|
||||
/>
|
||||
<DetailItem
|
||||
label={intl.get('email')}
|
||||
children={defaultTo(vendor.email, '--')}
|
||||
/>
|
||||
<DetailItem label={<T id={'vendor.drawer.label.phone_number'} />}>
|
||||
<div>{vendor?.personal_phone} </div>
|
||||
<div>{vendor?.work_phone} </div>
|
||||
</DetailItem>
|
||||
|
||||
<DetailItem
|
||||
label={<T id={'vendor.drawer.label.website'} />}
|
||||
children={defaultTo(vendor?.website, '--')}
|
||||
/>
|
||||
<DetailItem
|
||||
label={<T id={'vendor.drawer.label.opening_balance'} />}
|
||||
children={vendor?.formatted_opening_balance}
|
||||
/>
|
||||
<DetailItem
|
||||
label={<T id={'vendor.drawer.label.opening_balance_at'} />}
|
||||
children={vendor?.formatted_opening_balance_at}
|
||||
/>
|
||||
<DetailItem
|
||||
label={<T id={'vendor.drawer.label.currency'} />}
|
||||
children={vendor?.currency_code}
|
||||
/>
|
||||
</DetailsMenu>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
30
src/containers/Drawers/VendorDetailsDrawer/index.js
Normal file
30
src/containers/Drawers/VendorDetailsDrawer/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 VendorDetailsDrawerContent = React.lazy(() =>
|
||||
import('./VendorDetailsDrawerContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Vendor details drawer.
|
||||
*/
|
||||
function VendorDetailsDrawer({
|
||||
name,
|
||||
|
||||
// #withDrawer
|
||||
isOpen,
|
||||
payload: { vendorId },
|
||||
}) {
|
||||
return (
|
||||
<Drawer isOpen={isOpen} name={name} size={'750px'}>
|
||||
<DrawerSuspense>
|
||||
<VendorDetailsDrawerContent vendorId={vendorId} />
|
||||
</DrawerSuspense>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDrawers())(VendorDetailsDrawer);
|
||||
Reference in New Issue
Block a user