1
0
This commit is contained in:
Ahmed Bouhuolia
2026-03-26 17:40:24 +02:00
parent aa89484b64
commit 8b59f28125
15 changed files with 28 additions and 69 deletions
@@ -1,5 +1,6 @@
import { IsEmail, IsOptional, IsString } from 'class-validator'; import { IsEmail, IsString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { IsOptional } from '@/common/decorators/Validators';
export class ContactAddressDto { export class ContactAddressDto {
@ApiProperty({ required: false, description: 'Billing address line 1' }) @ApiProperty({ required: false, description: 'Billing address line 1' })
@@ -1,6 +1,7 @@
import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator'; import { IsBoolean, IsEmail, IsNotEmpty, IsString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { ContactAddressDto } from './ContactAddress.dto'; import { ContactAddressDto } from './ContactAddress.dto';
import { IsOptional } from '@/common/decorators/Validators';
export class EditCustomerDto extends ContactAddressDto { export class EditCustomerDto extends ContactAddressDto {
@ApiProperty({ required: true, description: 'Customer type' }) @ApiProperty({ required: true, description: 'Customer type' })
@@ -12,7 +12,7 @@ import CustomerDetailsDrawer from '@/containers/Drawers/CustomerDetailsDrawer';
import VendorDetailsDrawer from '@/containers/Drawers/VendorDetailsDrawer'; import VendorDetailsDrawer from '@/containers/Drawers/VendorDetailsDrawer';
import InventoryAdjustmentDetailDrawer from '@/containers/Drawers/InventoryAdjustmentDetailDrawer'; import InventoryAdjustmentDetailDrawer from '@/containers/Drawers/InventoryAdjustmentDetailDrawer';
import CashflowTransactionDetailDrawer from '@/containers/Drawers/CashflowTransactionDetailDrawer'; import CashflowTransactionDetailDrawer from '@/containers/Drawers/CashflowTransactionDetailDrawer';
// import QuickCreateCustomerDrawer from '@/containers/Drawers/QuickCreateCustomerDrawer'; import QuickCreateCustomerDrawer from '@/containers/Drawers/QuickCreateCustomerDrawer';
import QuickCreateItemDrawer from '@/containers/Drawers/QuickCreateItemDrawer'; import QuickCreateItemDrawer from '@/containers/Drawers/QuickCreateItemDrawer';
import QuickWriteVendorDrawer from '@/containers/Drawers/QuickWriteVendorDrawer'; import QuickWriteVendorDrawer from '@/containers/Drawers/QuickWriteVendorDrawer';
import CreditNoteDetailDrawer from '@/containers/Drawers/CreditNoteDetailDrawer'; import CreditNoteDetailDrawer from '@/containers/Drawers/CreditNoteDetailDrawer';
@@ -59,7 +59,7 @@ export default function DrawersContainer() {
<CashflowTransactionDetailDrawer <CashflowTransactionDetailDrawer
name={DRAWERS.CASHFLOW_TRNASACTION_DETAILS} name={DRAWERS.CASHFLOW_TRNASACTION_DETAILS}
/> />
{/* <QuickCreateCustomerDrawer name={DRAWERS.QUICK_CREATE_CUSTOMER} /> */} <QuickCreateCustomerDrawer name={DRAWERS.QUICK_CREATE_CUSTOMER} />
<QuickCreateItemDrawer name={DRAWERS.QUICK_CREATE_ITEM} /> <QuickCreateItemDrawer name={DRAWERS.QUICK_CREATE_ITEM} />
<QuickWriteVendorDrawer name={DRAWERS.QUICK_WRITE_VENDOR} /> <QuickWriteVendorDrawer name={DRAWERS.QUICK_WRITE_VENDOR} />
<CreditNoteDetailDrawer name={DRAWERS.CREDIT_NOTE_DETAILS} /> <CreditNoteDetailDrawer name={DRAWERS.CREDIT_NOTE_DETAILS} />
@@ -92,7 +92,6 @@ export function CustomerFormBasicSection({}) {
/> />
</FFormGroup> </FFormGroup>
<Divider style={{ margin: '20px 0' }} /> <Divider style={{ margin: '20px 0' }} />
{/*------------ Vendor email -----------*/} {/*------------ Vendor email -----------*/}
@@ -6,15 +6,8 @@ import { css } from '@emotion/css';
import { CustomerFloatingActions } from "./CustomerFloatingActions"; import { CustomerFloatingActions } from "./CustomerFloatingActions";
import { CustomerFormSections } from "./CustomerFormFields"; import { CustomerFormSections } from "./CustomerFormFields";
const customerFormSections = {
primary: 'primary',
financial: 'financial',
billingAddress: 'billingAddress',
shippingAddress: 'shippingAddress',
notes: 'notes',
};
export function CustomerFormContent() { export function CustomerFormContent() {
const [selectedTabId, setSelectedTabId] = useState(customerFormSections.primary); const [selectedTabId, setSelectedTabId] = useState('primary');
const handleTabChange = (tabId: string) => { const handleTabChange = (tabId: string) => {
const sectionId = String(tabId); const sectionId = String(tabId);
@@ -38,11 +31,11 @@ export function CustomerFormContent() {
onChange={handleTabChange} onChange={handleTabChange}
className={css`position: sticky; top: 20px; .bp4-large > .bp4-tab{font-size: 14px;} `} className={css`position: sticky; top: 20px; .bp4-large > .bp4-tab{font-size: 14px;} `}
> >
<Tab id={customerFormSections.primary} title={'Basic'} /> <Tab id={'primary'} title={'Basic'} />
<Tab id={customerFormSections.financial} title={'Financial'} /> <Tab id={'financial'} title={'Financial'} />
<Tab id={customerFormSections.billingAddress} title={'Billing address'} /> <Tab id={'billingAddress'} title={'Billing address'} />
<Tab id={customerFormSections.shippingAddress} title={'Ship address'} /> <Tab id={'shippingAddress'} title={'Ship address'} />
<Tab id={customerFormSections.notes} title={'Notes'} /> <Tab id={'notes'} title={'Notes'} />
</Tabs> </Tabs>
<CustomerFormSections /> <CustomerFormSections />
@@ -3,13 +3,11 @@ import intl from 'react-intl-universal';
import { Formik, Form, FormikHelpers } from 'formik'; import { Formik, Form, FormikHelpers } from 'formik';
import { Intent } from '@blueprintjs/core'; import { Intent } from '@blueprintjs/core';
import styled from 'styled-components'; import styled from 'styled-components';
import { CreateCustomerForm, EditCustomerForm } from './CustomerForm.schema'; import { CreateCustomerForm, EditCustomerForm } from './CustomerForm.schema';
import { compose, transformToForm, saveInvoke, parseBoolean } from '@/utils'; import { compose, transformToForm, saveInvoke, parseBoolean } from '@/utils';
import { useCustomerFormContext } from './CustomerFormProvider'; import { useCustomerFormContext } from './CustomerFormProvider';
import { defaultInitialValues } from './utils'; import { defaultInitialValues } from './utils';
import { AppToaster } from '@/components';
import { AppToaster, Box } from '@/components';
import { withCurrentOrganization } from '@/containers/Organization/withCurrentOrganization'; import { withCurrentOrganization } from '@/containers/Organization/withCurrentOrganization';
import { CustomerFormContent } from './CustomerFormContent'; import { CustomerFormContent } from './CustomerFormContent';
@@ -140,7 +138,6 @@ function CustomerFormFormikRoot({
setSubmitting(false); setSubmitting(false);
saveInvoke(onSubmitError, values, formArgs, submitPayload); saveInvoke(onSubmitError, values, formArgs, submitPayload);
}; };
if (isNewMode) { if (isNewMode) {
createCustomerMutate(formValues).then(onSuccess).catch(onError); createCustomerMutate(formValues).then(onSuccess).catch(onError);
} else { } else {
@@ -150,7 +147,6 @@ function CustomerFormFormikRoot({
}; };
return ( return (
<Box mx={'auto'} maxWidth={800}>
<Formik<CustomerFormValues> <Formik<CustomerFormValues>
validationSchema={isNewMode ? CreateCustomerForm : EditCustomerForm} validationSchema={isNewMode ? CreateCustomerForm : EditCustomerForm}
initialValues={initialValues} initialValues={initialValues}
@@ -162,7 +158,6 @@ function CustomerFormFormikRoot({
</CustomerFormFields> </CustomerFormFields>
</Form> </Form>
</Formik> </Formik>
</Box>
); );
} }
@@ -171,7 +166,6 @@ const CustomerFormFields = styled.div`
.bp6-form-content { .bp6-form-content {
min-width: 300px; min-width: 300px;
} }
.bp4-form-group.bp4-inline label.bp4-label { .bp4-form-group.bp4-inline label.bp4-label {
min-width: 140px; min-width: 140px;
} }
@@ -2,9 +2,7 @@
import React from 'react'; import React from 'react';
import { useParams, useHistory } from 'react-router-dom'; import { useParams, useHistory } from 'react-router-dom';
import styled from 'styled-components'; import styled from 'styled-components';
import { Box, DashboardCard, DashboardInsider } from '@/components';
import { DashboardCard, DashboardInsider } from '@/components';
import { CustomerFormFormik } from './CustomerFormFormik'; import { CustomerFormFormik } from './CustomerFormFormik';
import { import {
CustomerFormProvider, CustomerFormProvider,
@@ -49,10 +47,12 @@ export default function CustomerFormPage() {
return ( return (
<CustomerFormProvider customerId={customerId}> <CustomerFormProvider customerId={customerId}>
<CustomerFormPageLoading> <CustomerFormPageLoading>
<Box mx={'auto'} maxWidth={800}>
<CustomerFormFormik <CustomerFormFormik
onSubmitSuccess={handleSubmitSuccess} onSubmitSuccess={handleSubmitSuccess}
onCancel={handleFormCancel} onCancel={handleFormCancel}
/> />
</Box>
</CustomerFormPageLoading> </CustomerFormPageLoading>
</CustomerFormProvider> </CustomerFormProvider>
); );
@@ -53,34 +53,14 @@ function QuickCustomerFormDrawer({
return ( return (
<CustomerFormProvider customerId={customerId}> <CustomerFormProvider customerId={customerId}>
<DrawerCustomerFormLoading> <DrawerCustomerFormLoading>
<CustomerFormCard> <CustomerFormFormik
{/* <CustomerFormFormik
initialValues={{ first_name: displayName }} initialValues={{ first_name: displayName }}
onSubmitSuccess={handleSubmitSuccess} onSubmitSuccess={handleSubmitSuccess}
onCancel={handleCancelForm} onCancel={handleCancelForm}
/> */} />
</CustomerFormCard>
</DrawerCustomerFormLoading> </DrawerCustomerFormLoading>
</CustomerFormProvider> </CustomerFormProvider>
); );
} }
export default R.compose(withDrawerActions)(QuickCustomerFormDrawer); export default R.compose(withDrawerActions)(QuickCustomerFormDrawer);
const CustomerFormCard = styled(Card)`
margin: 15px;
padding: 25px;
margin-bottom: calc(15px + 65px);
// ${CustomerFormHeaderPrimary} {
// padding-top: 0;
// }
.page-form {
padding: 0;
&__floating-actions {
margin-left: -41px;
margin-right: -41px;
}
}
`;
@@ -5,7 +5,7 @@ import { Dragzone, FormattedMessage as T } from '@/components';
/** /**
* Vendor Attachment Tab. * Vendor Attachment Tab.
*/ */
function VendorAttachmentTab() { export function VendorAttachmentTab() {
return ( return (
<div> <div>
<Dragzone <Dragzone
@@ -17,5 +17,3 @@ function VendorAttachmentTab() {
</div> </div>
); );
} }
export default VendorAttachmentTab;
@@ -28,7 +28,7 @@ import { useCurrentOrganization } from '@/hooks/state';
/** /**
* Vendor Finaniceal Panel Tab. * Vendor Finaniceal Panel Tab.
*/ */
export default function VendorFinanicalPanelTab() { export function VendorFinanicalPanelTab() {
const { currencies, branches } = useVendorFormContext(); const { currencies, branches } = useVendorFormContext();
// Sets the primary branch to form. // Sets the primary branch to form.
@@ -7,7 +7,7 @@ import { FormattedMessage as T, FFormGroup, FInputGroup } from '@/components';
/** /**
* Vendor form after primary section. * Vendor form after primary section.
*/ */
function VendorFormAfterPrimarySection() { export function VendorFormAfterPrimarySection() {
return ( return (
<div className={'customer-form__after-primary-section-content'}> <div className={'customer-form__after-primary-section-content'}>
{/*------------ Vendor email -----------*/} {/*------------ Vendor email -----------*/}
@@ -42,5 +42,3 @@ function VendorFormAfterPrimarySection() {
</div> </div>
); );
} }
export default VendorFormAfterPrimarySection;
@@ -24,7 +24,7 @@ import { defaultInitialValues } from './utils';
/** /**
* Vendor form. * Vendor form.
*/ */
function VendorFormFormik({ function VendorFormFormikBase({
// #withCurrentOrganization // #withCurrentOrganization
organization: { base_currency }, organization: { base_currency },
@@ -131,4 +131,4 @@ const VendorFormFields = styled.div`
} }
`; `;
export default compose(withCurrentOrganization())(VendorFormFormik); export const VendorFormFormik = compose(withCurrentOrganization())(VendorFormFormikBase);
@@ -2,12 +2,9 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { useParams, useHistory } from 'react-router-dom'; import { useParams, useHistory } from 'react-router-dom';
import '@/style/pages/Vendors/PageForm.scss';
import { DashboardCard, DashboardInsider } from '@/components'; import { DashboardCard, DashboardInsider } from '@/components';
import { VendorFormProvider, useVendorFormContext } from './VendorFormProvider'; import { VendorFormProvider, useVendorFormContext } from './VendorFormProvider';
import VendorFormFormik from './VendorFormFormik'; import { VendorFormFormik } from './VendorFormFormik';
/** /**
* Vendor form page loading wrapper. * Vendor form page loading wrapper.
@@ -26,7 +23,7 @@ function VendorFormPageLoading({ children }) {
/** /**
* Vendor form page. * Vendor form page.
*/ */
export default function VendorFormPage() { export function VendorFormPage() {
const history = useHistory(); const history = useHistory();
const { id } = useParams(); const { id } = useParams();
@@ -18,7 +18,7 @@ import { useAutofocus } from '@/hooks';
/** /**
* Vendor form primary section. * Vendor form primary section.
*/ */
function VendorFormPrimarySection() { export function VendorFormPrimarySection() {
const firstNameFieldRef = useAutofocus(); const firstNameFieldRef = useAutofocus();
return ( return (
@@ -80,5 +80,3 @@ function VendorFormPrimarySection() {
</div> </div>
); );
} }
export default VendorFormPrimarySection;
@@ -5,7 +5,7 @@ import classNames from 'classnames';
import { Tabs, Tab } from '@blueprintjs/core'; import { Tabs, Tab } from '@blueprintjs/core';
import { CLASSES } from '@/constants/classes'; import { CLASSES } from '@/constants/classes';
import VendorFinanicalPanelTab from './VendorFinanicalPanelTab'; import { VendorFinanicalPanelTab } from './VendorFinanicalPanelTab';
import CustomerAddressTabs from '@/containers/Customers/CustomerForm/CustomerAddressTabs'; import CustomerAddressTabs from '@/containers/Customers/CustomerForm/CustomerAddressTabs';
import CustomerNotePanel from '@/containers/Customers/CustomerForm/CustomerNotePanel'; import CustomerNotePanel from '@/containers/Customers/CustomerForm/CustomerNotePanel';
@@ -13,7 +13,7 @@ import CustomerNotePanel from '@/containers/Customers/CustomerForm/CustomerNoteP
/** /**
* Vendor form tabs. * Vendor form tabs.
*/ */
export default function VendorTabs() { export function VendorsTabs() {
return ( return (
<div className={classNames(CLASSES.PAGE_FORM_TABS)}> <div className={classNames(CLASSES.PAGE_FORM_TABS)}>
<Tabs <Tabs