From 8b59f28125da699df9d79c0a594160613e4a9efe Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Thu, 26 Mar 2026 17:40:24 +0200 Subject: [PATCH] wip --- .../Customers/dtos/ContactAddress.dto.ts | 3 ++- .../Customers/dtos/EditCustomer.dto.ts | 3 ++- .../src/components/DrawersContainer.tsx | 4 ++-- .../CustomerForm/CustomerFormBasicSection.tsx | 1 - .../CustomerForm/CustomerFormContent.tsx | 19 +++++---------- .../CustomerForm/CustomerFormFormik.tsx | 8 +------ .../CustomerForm/CustomerFormPage.tsx | 6 ++--- .../QuickCustomerFormDrawer.tsx | 24 ++----------------- .../VendorForm/VendorAttachmentTab.tsx | 4 +--- .../VendorForm/VendorFinanicalPanelTab.tsx | 2 +- .../VendorFormAfterPrimarySection.tsx | 4 +--- .../Vendors/VendorForm/VendorFormFormik.tsx | 4 ++-- .../Vendors/VendorForm/VendorFormPage.tsx | 7 ++---- .../VendorForm/VendorFormPrimarySection.tsx | 4 +--- .../Vendors/VendorForm/VendorsTabs.tsx | 4 ++-- 15 files changed, 28 insertions(+), 69 deletions(-) diff --git a/packages/server/src/modules/Customers/dtos/ContactAddress.dto.ts b/packages/server/src/modules/Customers/dtos/ContactAddress.dto.ts index 8fc4da490..da963c9a6 100644 --- a/packages/server/src/modules/Customers/dtos/ContactAddress.dto.ts +++ b/packages/server/src/modules/Customers/dtos/ContactAddress.dto.ts @@ -1,5 +1,6 @@ -import { IsEmail, IsOptional, IsString } from 'class-validator'; +import { IsEmail, IsString } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; +import { IsOptional } from '@/common/decorators/Validators'; export class ContactAddressDto { @ApiProperty({ required: false, description: 'Billing address line 1' }) diff --git a/packages/server/src/modules/Customers/dtos/EditCustomer.dto.ts b/packages/server/src/modules/Customers/dtos/EditCustomer.dto.ts index 4e633bed4..44f7b31d6 100644 --- a/packages/server/src/modules/Customers/dtos/EditCustomer.dto.ts +++ b/packages/server/src/modules/Customers/dtos/EditCustomer.dto.ts @@ -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 { ContactAddressDto } from './ContactAddress.dto'; +import { IsOptional } from '@/common/decorators/Validators'; export class EditCustomerDto extends ContactAddressDto { @ApiProperty({ required: true, description: 'Customer type' }) diff --git a/packages/webapp/src/components/DrawersContainer.tsx b/packages/webapp/src/components/DrawersContainer.tsx index 8a7d04074..05d2b3413 100644 --- a/packages/webapp/src/components/DrawersContainer.tsx +++ b/packages/webapp/src/components/DrawersContainer.tsx @@ -12,7 +12,7 @@ import CustomerDetailsDrawer from '@/containers/Drawers/CustomerDetailsDrawer'; import VendorDetailsDrawer from '@/containers/Drawers/VendorDetailsDrawer'; import InventoryAdjustmentDetailDrawer from '@/containers/Drawers/InventoryAdjustmentDetailDrawer'; 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 QuickWriteVendorDrawer from '@/containers/Drawers/QuickWriteVendorDrawer'; import CreditNoteDetailDrawer from '@/containers/Drawers/CreditNoteDetailDrawer'; @@ -59,7 +59,7 @@ export default function DrawersContainer() { - {/* */} + diff --git a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormBasicSection.tsx b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormBasicSection.tsx index bf22c5645..44145eb99 100644 --- a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormBasicSection.tsx +++ b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormBasicSection.tsx @@ -92,7 +92,6 @@ export function CustomerFormBasicSection({}) { /> - {/*------------ Vendor email -----------*/} diff --git a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormContent.tsx b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormContent.tsx index cb10674bc..368e14bc3 100644 --- a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormContent.tsx +++ b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormContent.tsx @@ -6,15 +6,8 @@ import { css } from '@emotion/css'; import { CustomerFloatingActions } from "./CustomerFloatingActions"; import { CustomerFormSections } from "./CustomerFormFields"; -const customerFormSections = { - primary: 'primary', - financial: 'financial', - billingAddress: 'billingAddress', - shippingAddress: 'shippingAddress', - notes: 'notes', -}; export function CustomerFormContent() { - const [selectedTabId, setSelectedTabId] = useState(customerFormSections.primary); + const [selectedTabId, setSelectedTabId] = useState('primary'); const handleTabChange = (tabId: string) => { const sectionId = String(tabId); @@ -38,11 +31,11 @@ export function CustomerFormContent() { onChange={handleTabChange} className={css`position: sticky; top: 20px; .bp4-large > .bp4-tab{font-size: 14px;} `} > - - - - - + + + + + diff --git a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormFormik.tsx b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormFormik.tsx index cfb1865b5..c56ecfc5d 100644 --- a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormFormik.tsx +++ b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormFormik.tsx @@ -3,13 +3,11 @@ import intl from 'react-intl-universal'; import { Formik, Form, FormikHelpers } from 'formik'; import { Intent } from '@blueprintjs/core'; import styled from 'styled-components'; - import { CreateCustomerForm, EditCustomerForm } from './CustomerForm.schema'; import { compose, transformToForm, saveInvoke, parseBoolean } from '@/utils'; import { useCustomerFormContext } from './CustomerFormProvider'; import { defaultInitialValues } from './utils'; - -import { AppToaster, Box } from '@/components'; +import { AppToaster } from '@/components'; import { withCurrentOrganization } from '@/containers/Organization/withCurrentOrganization'; import { CustomerFormContent } from './CustomerFormContent'; @@ -140,7 +138,6 @@ function CustomerFormFormikRoot({ setSubmitting(false); saveInvoke(onSubmitError, values, formArgs, submitPayload); }; - if (isNewMode) { createCustomerMutate(formValues).then(onSuccess).catch(onError); } else { @@ -150,7 +147,6 @@ function CustomerFormFormikRoot({ }; return ( - validationSchema={isNewMode ? CreateCustomerForm : EditCustomerForm} initialValues={initialValues} @@ -162,7 +158,6 @@ function CustomerFormFormikRoot({ - ); } @@ -171,7 +166,6 @@ const CustomerFormFields = styled.div` .bp6-form-content { min-width: 300px; } - .bp4-form-group.bp4-inline label.bp4-label { min-width: 140px; } diff --git a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormPage.tsx b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormPage.tsx index 68d791c44..8ab5e1a42 100644 --- a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormPage.tsx +++ b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormPage.tsx @@ -2,9 +2,7 @@ import React from 'react'; import { useParams, useHistory } from 'react-router-dom'; import styled from 'styled-components'; - -import { DashboardCard, DashboardInsider } from '@/components'; - +import { Box, DashboardCard, DashboardInsider } from '@/components'; import { CustomerFormFormik } from './CustomerFormFormik'; import { CustomerFormProvider, @@ -49,10 +47,12 @@ export default function CustomerFormPage() { return ( + + ); diff --git a/packages/webapp/src/containers/Drawers/QuickCreateCustomerDrawer/QuickCustomerFormDrawer.tsx b/packages/webapp/src/containers/Drawers/QuickCreateCustomerDrawer/QuickCustomerFormDrawer.tsx index c966e5939..7c4330a91 100644 --- a/packages/webapp/src/containers/Drawers/QuickCreateCustomerDrawer/QuickCustomerFormDrawer.tsx +++ b/packages/webapp/src/containers/Drawers/QuickCreateCustomerDrawer/QuickCustomerFormDrawer.tsx @@ -53,34 +53,14 @@ function QuickCustomerFormDrawer({ return ( - - {/* */} - + /> ); } 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; - } - } -`; diff --git a/packages/webapp/src/containers/Vendors/VendorForm/VendorAttachmentTab.tsx b/packages/webapp/src/containers/Vendors/VendorForm/VendorAttachmentTab.tsx index 7cbb5735f..325b32f35 100644 --- a/packages/webapp/src/containers/Vendors/VendorForm/VendorAttachmentTab.tsx +++ b/packages/webapp/src/containers/Vendors/VendorForm/VendorAttachmentTab.tsx @@ -5,7 +5,7 @@ import { Dragzone, FormattedMessage as T } from '@/components'; /** * Vendor Attachment Tab. */ -function VendorAttachmentTab() { +export function VendorAttachmentTab() { return (
); } - -export default VendorAttachmentTab; diff --git a/packages/webapp/src/containers/Vendors/VendorForm/VendorFinanicalPanelTab.tsx b/packages/webapp/src/containers/Vendors/VendorForm/VendorFinanicalPanelTab.tsx index 9c0616664..dec7bf8c8 100644 --- a/packages/webapp/src/containers/Vendors/VendorForm/VendorFinanicalPanelTab.tsx +++ b/packages/webapp/src/containers/Vendors/VendorForm/VendorFinanicalPanelTab.tsx @@ -28,7 +28,7 @@ import { useCurrentOrganization } from '@/hooks/state'; /** * Vendor Finaniceal Panel Tab. */ -export default function VendorFinanicalPanelTab() { +export function VendorFinanicalPanelTab() { const { currencies, branches } = useVendorFormContext(); // Sets the primary branch to form. diff --git a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormAfterPrimarySection.tsx b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormAfterPrimarySection.tsx index 050275ba5..5d1678a6c 100644 --- a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormAfterPrimarySection.tsx +++ b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormAfterPrimarySection.tsx @@ -7,7 +7,7 @@ import { FormattedMessage as T, FFormGroup, FInputGroup } from '@/components'; /** * Vendor form after primary section. */ -function VendorFormAfterPrimarySection() { +export function VendorFormAfterPrimarySection() { return (
{/*------------ Vendor email -----------*/} @@ -42,5 +42,3 @@ function VendorFormAfterPrimarySection() {
); } - -export default VendorFormAfterPrimarySection; diff --git a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormFormik.tsx b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormFormik.tsx index 4854fbd32..64848827f 100644 --- a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormFormik.tsx +++ b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormFormik.tsx @@ -24,7 +24,7 @@ import { defaultInitialValues } from './utils'; /** * Vendor form. */ -function VendorFormFormik({ +function VendorFormFormikBase({ // #withCurrentOrganization organization: { base_currency }, @@ -131,4 +131,4 @@ const VendorFormFields = styled.div` } `; -export default compose(withCurrentOrganization())(VendorFormFormik); +export const VendorFormFormik = compose(withCurrentOrganization())(VendorFormFormikBase); diff --git a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormPage.tsx b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormPage.tsx index 6e5e8bf7f..ea0e09700 100644 --- a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormPage.tsx +++ b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormPage.tsx @@ -2,12 +2,9 @@ import React from 'react'; import styled from 'styled-components'; import { useParams, useHistory } from 'react-router-dom'; - -import '@/style/pages/Vendors/PageForm.scss'; - import { DashboardCard, DashboardInsider } from '@/components'; import { VendorFormProvider, useVendorFormContext } from './VendorFormProvider'; -import VendorFormFormik from './VendorFormFormik'; +import { VendorFormFormik } from './VendorFormFormik'; /** * Vendor form page loading wrapper. @@ -26,7 +23,7 @@ function VendorFormPageLoading({ children }) { /** * Vendor form page. */ -export default function VendorFormPage() { +export function VendorFormPage() { const history = useHistory(); const { id } = useParams(); diff --git a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormPrimarySection.tsx b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormPrimarySection.tsx index dcdac551e..7da371b84 100644 --- a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormPrimarySection.tsx +++ b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormPrimarySection.tsx @@ -18,7 +18,7 @@ import { useAutofocus } from '@/hooks'; /** * Vendor form primary section. */ -function VendorFormPrimarySection() { +export function VendorFormPrimarySection() { const firstNameFieldRef = useAutofocus(); return ( @@ -80,5 +80,3 @@ function VendorFormPrimarySection() {
); } - -export default VendorFormPrimarySection; diff --git a/packages/webapp/src/containers/Vendors/VendorForm/VendorsTabs.tsx b/packages/webapp/src/containers/Vendors/VendorForm/VendorsTabs.tsx index 7870c4000..e3aeafd78 100644 --- a/packages/webapp/src/containers/Vendors/VendorForm/VendorsTabs.tsx +++ b/packages/webapp/src/containers/Vendors/VendorForm/VendorsTabs.tsx @@ -5,7 +5,7 @@ import classNames from 'classnames'; import { Tabs, Tab } from '@blueprintjs/core'; import { CLASSES } from '@/constants/classes'; -import VendorFinanicalPanelTab from './VendorFinanicalPanelTab'; +import { VendorFinanicalPanelTab } from './VendorFinanicalPanelTab'; import CustomerAddressTabs from '@/containers/Customers/CustomerForm/CustomerAddressTabs'; import CustomerNotePanel from '@/containers/Customers/CustomerForm/CustomerNotePanel'; @@ -13,7 +13,7 @@ import CustomerNotePanel from '@/containers/Customers/CustomerForm/CustomerNoteP /** * Vendor form tabs. */ -export default function VendorTabs() { +export function VendorsTabs() { return (