mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
fix: merge conflict quick create list field.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
DrawerHeaderContent,
|
||||
DrawerBody,
|
||||
FormattedMessage as T,
|
||||
} from 'components';
|
||||
|
||||
import QuickCustomerFormDrawer from './QuickCustomerFormDrawer';
|
||||
|
||||
/**
|
||||
* Quick create/edit customer drawer.
|
||||
*/
|
||||
export default function QuickCreateCustomerDrawerContent({ displayName }) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<DrawerHeaderContent
|
||||
name="quick-create-customer"
|
||||
title={<T id={'create_a_new_customer'} />}
|
||||
/>
|
||||
<DrawerBody>
|
||||
<QuickCustomerFormDrawer displayName={displayName} />
|
||||
</DrawerBody>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Card, DrawerLoading } from 'components';
|
||||
|
||||
import {
|
||||
CustomerFormProvider,
|
||||
useCustomerFormContext,
|
||||
} from '../../Customers/CustomerForm/CustomerFormProvider';
|
||||
import CustomerFormFormik from '../../Customers/CustomerForm/CustomerFormFormik';
|
||||
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
/**
|
||||
* Drawer customer form loading wrapper.
|
||||
* @returns {JSX}
|
||||
*/
|
||||
function DrawerCustomerFormLoading({ children }) {
|
||||
const { isFormLoading } = useCustomerFormContext();
|
||||
|
||||
return <DrawerLoading loading={isFormLoading}>{children}</DrawerLoading>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick customer form of the drawer.
|
||||
*/
|
||||
function QuickCustomerFormDrawer({ displayName, closeDrawer, customerId }) {
|
||||
// Handle the form submit request success.
|
||||
const handleSubmitSuccess = () => {
|
||||
closeDrawer('quick-create-customer');
|
||||
};
|
||||
// Handle the form cancel action.
|
||||
const handleCancelForm = () => {
|
||||
closeDrawer('quick-create-customer');
|
||||
};
|
||||
|
||||
return (
|
||||
<CustomerFormProvider customerId={customerId}>
|
||||
<DrawerCustomerFormLoading>
|
||||
<CustomerFormCard>
|
||||
<CustomerFormFormik
|
||||
initialValues={{ display_name: displayName }}
|
||||
onSubmitSuccess={handleSubmitSuccess}
|
||||
onCancel={handleCancelForm}
|
||||
/>
|
||||
</CustomerFormCard>
|
||||
</DrawerCustomerFormLoading>
|
||||
</CustomerFormProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDrawerActions)(QuickCustomerFormDrawer);
|
||||
|
||||
const CustomerFormCard = styled(Card)`
|
||||
margin: 15px;
|
||||
margin-bottom: calc(15px + 65px);
|
||||
|
||||
.page-form {
|
||||
&__floating-actions {
|
||||
margin-left: -36px;
|
||||
margin-right: -36px;
|
||||
}
|
||||
}
|
||||
`;
|
||||
35
src/containers/Drawers/QuickCreateCustomerDrawer/index.js
Normal file
35
src/containers/Drawers/QuickCreateCustomerDrawer/index.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
import { Drawer, DrawerSuspense } from 'components';
|
||||
import withDrawers from 'containers/Drawer/withDrawers';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
const QuickCreateCustomerDrawerContent = React.lazy(() =>
|
||||
import('./QuickCreateCustomerDrawerContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Quick Create customer
|
||||
*/
|
||||
function QuickCreateCustomerDrawer({
|
||||
name,
|
||||
|
||||
// #withDrawer
|
||||
isOpen,
|
||||
payload,
|
||||
}) {
|
||||
return (
|
||||
<Drawer
|
||||
isOpen={isOpen}
|
||||
name={name}
|
||||
style={{ minWidth: '700px', maxWidth: '900px' }}
|
||||
size={'80%'}
|
||||
>
|
||||
<DrawerSuspense>
|
||||
<QuickCreateCustomerDrawerContent displayName={payload.displayName} />
|
||||
</DrawerSuspense>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDrawers())(QuickCreateCustomerDrawer);
|
||||
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
DrawerHeaderContent,
|
||||
DrawerBody,
|
||||
FormattedMessage as T,
|
||||
} from 'components';
|
||||
|
||||
import QuickCreateItemDrawerForm from './QuickCreateItemDrawerForm';
|
||||
|
||||
/**
|
||||
* Quick create/edit item drawer content.
|
||||
*/
|
||||
export default function QuickCreateItemDrawerContent({ itemName }) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<DrawerHeaderContent
|
||||
name="quick-create-item"
|
||||
title={<T id={'create_a_new_item'} />}
|
||||
/>
|
||||
<DrawerBody>
|
||||
<QuickCreateItemDrawerForm itemName={itemName} />
|
||||
</DrawerBody>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Card, DrawerLoading } from 'components';
|
||||
|
||||
import ItemFormFormik from '../../Items/ItemFormFormik';
|
||||
import {
|
||||
ItemFormProvider,
|
||||
useItemFormContext,
|
||||
} from '../../Items/ItemFormProvider';
|
||||
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
import withDashboardActions from '../../Dashboard/withDashboardActions';
|
||||
|
||||
import { useDrawerContext } from 'components/Drawer/DrawerProvider';
|
||||
|
||||
/**
|
||||
* Drawer item form loading.
|
||||
* @returns {JSX}
|
||||
*/
|
||||
function DrawerItemFormLoading({ children }) {
|
||||
const { isFormLoading } = useItemFormContext();
|
||||
|
||||
return <DrawerLoading loading={isFormLoading}>{children}</DrawerLoading>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick create/edit item drawer form.
|
||||
*/
|
||||
function QuickCreateItemDrawerForm({
|
||||
itemId,
|
||||
itemName,
|
||||
closeDrawer,
|
||||
|
||||
// #withDashboardActions
|
||||
addQuickActionEvent,
|
||||
}) {
|
||||
// Drawer context.
|
||||
const { payload } = useDrawerContext();
|
||||
|
||||
// Handle the form submit request success.
|
||||
const handleSubmitSuccess = (values, form, submitPayload, response) => {
|
||||
if (submitPayload.redirect) {
|
||||
closeDrawer('quick-create-item');
|
||||
}
|
||||
if (payload.quickActionEvent) {
|
||||
addQuickActionEvent(payload.quickActionEvent, {
|
||||
itemId: response.data.id,
|
||||
});
|
||||
}
|
||||
};
|
||||
// Handle the form cancel.
|
||||
const handleFormCancel = () => {
|
||||
closeDrawer('quick-create-item');
|
||||
};
|
||||
|
||||
return (
|
||||
<ItemFormProvider itemId={itemId}>
|
||||
<DrawerItemFormLoading>
|
||||
<ItemFormCard>
|
||||
<ItemFormFormik
|
||||
initialValues={{ name: itemName }}
|
||||
onSubmitSuccess={handleSubmitSuccess}
|
||||
onCancel={handleFormCancel}
|
||||
/>
|
||||
</ItemFormCard>
|
||||
</DrawerItemFormLoading>
|
||||
</ItemFormProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(
|
||||
withDrawerActions,
|
||||
withDashboardActions,
|
||||
)(QuickCreateItemDrawerForm);
|
||||
|
||||
const ItemFormCard = styled(Card)`
|
||||
margin: 15px;
|
||||
margin-bottom: calc(15px + 65px);
|
||||
|
||||
.page-form__floating-actions {
|
||||
margin-left: -36px;
|
||||
margin-right: -36px;
|
||||
}
|
||||
`;
|
||||
37
src/containers/Drawers/QuickCreateItemDrawer/index.js
Normal file
37
src/containers/Drawers/QuickCreateItemDrawer/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
import { Drawer, DrawerSuspense } from 'components';
|
||||
import withDrawers from 'containers/Drawer/withDrawers';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
const QuickCretaeItemDrawerContent = React.lazy(() =>
|
||||
import('./QuickCreateItemDrawerContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Quick create item.
|
||||
*/
|
||||
function QuickCreateItemDrawer({
|
||||
// #ownProps
|
||||
name,
|
||||
|
||||
// #withDrawer
|
||||
isOpen,
|
||||
payload,
|
||||
}) {
|
||||
return (
|
||||
<Drawer
|
||||
isOpen={isOpen}
|
||||
name={name}
|
||||
style={{ minWidth: '800px', maxWidth: '1000px' }}
|
||||
size={'72%'}
|
||||
payload={payload}
|
||||
>
|
||||
<DrawerSuspense>
|
||||
<QuickCretaeItemDrawerContent itemName={payload.name} />
|
||||
</DrawerSuspense>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDrawers())(QuickCreateItemDrawer);
|
||||
@@ -0,0 +1,85 @@
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Card, DrawerLoading } from 'components';
|
||||
|
||||
import {
|
||||
VendorFormProvider,
|
||||
useVendorFormContext,
|
||||
} from '../../Vendors/VendorForm/VendorFormProvider';
|
||||
import VendorFormFormik from '../../Vendors/VendorForm/VendorFormFormik';
|
||||
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
import withDashboardActions from '../../Dashboard/withDashboardActions';
|
||||
|
||||
import { useDrawerContext } from 'components/Drawer/DrawerProvider';
|
||||
|
||||
/**
|
||||
* Drawer vendor form loading wrapper.
|
||||
* @returns {JSX}
|
||||
*/
|
||||
function DrawerVendorFormLoading({ children }) {
|
||||
const { isFormLoading } = useVendorFormContext();
|
||||
|
||||
return <DrawerLoading loading={isFormLoading}>{children}</DrawerLoading>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick vendor form of the drawer.
|
||||
*/
|
||||
function QuickVendorFormDrawer({
|
||||
displayName,
|
||||
closeDrawer,
|
||||
vendorId,
|
||||
addQuickActionEvent,
|
||||
}) {
|
||||
const { payload } = useDrawerContext();
|
||||
|
||||
// Handle the form submit request success.
|
||||
const handleSubmitSuccess = (values, form, submitPayload, response) => {
|
||||
if (!submitPayload.noRedirect) {
|
||||
closeDrawer('quick-write-vendor');
|
||||
}
|
||||
if (payload.quickActionEvent) {
|
||||
addQuickActionEvent(payload.quickActionEvent, {
|
||||
vendorId: response.data.id,
|
||||
});
|
||||
}
|
||||
};
|
||||
// Handle the form cancel action.
|
||||
const handleCancelForm = () => {
|
||||
closeDrawer('quick-write-vendor');
|
||||
};
|
||||
|
||||
return (
|
||||
<VendorFormProvider vendorId={vendorId}>
|
||||
<DrawerVendorFormLoading>
|
||||
<VendorFormCard>
|
||||
<VendorFormFormik
|
||||
initialValues={{ display_name: displayName }}
|
||||
onSubmitSuccess={handleSubmitSuccess}
|
||||
onCancel={handleCancelForm}
|
||||
/>
|
||||
</VendorFormCard>
|
||||
</DrawerVendorFormLoading>
|
||||
</VendorFormProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(
|
||||
withDrawerActions,
|
||||
withDashboardActions,
|
||||
)(QuickVendorFormDrawer);
|
||||
|
||||
const VendorFormCard = styled(Card)`
|
||||
margin: 15px;
|
||||
margin-bottom: calc(15px + 65px);
|
||||
|
||||
.page-form {
|
||||
&__floating-actions {
|
||||
margin-left: -36px;
|
||||
margin-right: -36px;
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
DrawerHeaderContent,
|
||||
DrawerBody,
|
||||
FormattedMessage as T,
|
||||
} from 'components';
|
||||
|
||||
import QuickVendorFormDrawer from './QuickVendorFormDrawer';
|
||||
|
||||
/**
|
||||
* Quick create/edit vendor drawer.
|
||||
*/
|
||||
export default function QuickWriteVendorDrawerContent({ displayName }) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<DrawerHeaderContent
|
||||
name="quick-create-customer"
|
||||
title={"Create a new vendor"}
|
||||
/>
|
||||
<DrawerBody>
|
||||
<QuickVendorFormDrawer displayName={displayName} />
|
||||
</DrawerBody>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
36
src/containers/Drawers/QuickWriteVendorDrawer/index.js
Normal file
36
src/containers/Drawers/QuickWriteVendorDrawer/index.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import { Drawer, DrawerSuspense } from 'components';
|
||||
import withDrawers from 'containers/Drawer/withDrawers';
|
||||
|
||||
const QuickWriteVendorDrawerContent = React.lazy(() =>
|
||||
import('./QuickWriteVendorDrawerContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Quick Write vendor.
|
||||
*/
|
||||
function QuickWriteVendorDrawer({
|
||||
name,
|
||||
|
||||
// #withDrawer
|
||||
isOpen,
|
||||
payload,
|
||||
}) {
|
||||
return (
|
||||
<Drawer
|
||||
isOpen={isOpen}
|
||||
name={name}
|
||||
style={{ minWidth: '700px', maxWidth: '900px' }}
|
||||
size={'80%'}
|
||||
payload={payload}
|
||||
>
|
||||
<DrawerSuspense>
|
||||
<QuickWriteVendorDrawerContent displayName={payload.displayName} />
|
||||
</DrawerSuspense>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDrawers())(QuickWriteVendorDrawer);
|
||||
Reference in New Issue
Block a user