diff --git a/frontend/src/components/project/EditProject.tsx b/frontend/src/components/project/EditProject.tsx index 0c0ad48e..7fbb899a 100644 --- a/frontend/src/components/project/EditProject.tsx +++ b/frontend/src/components/project/EditProject.tsx @@ -9,7 +9,7 @@ import {StickyFooter} from '../controls/other/StickyFooter'; import {BusyButton} from '../controls/form-controls/BusyButton'; import {IProjectModel, ProjectClientInvoiceLine} from './models/IProjectModel'; import {projectFormConfig} from './models/ProjectFormConfig'; -import {getNewProject} from './models/getNewProject'; +import {getNewProject, getNewProjectEndCustomer} from './models/getNewProject'; import {ConfacState} from '../../reducers/app-state'; import {getDefaultProjectMonthConfig} from './models/ProjectMonthModel'; import {useDocumentTitle} from '../hooks/useDocumentTitle'; @@ -83,10 +83,18 @@ export const EditProject = () => { setProject(newProject); } - - const setProjectInterceptor = (value: IProjectModel) => { + const newProject = {...project, ...value}; + + if(!newProject.forEndCustomer && newProject.endCustomer) { + newProject.endCustomer = null; + } + + if(newProject.forEndCustomer && !newProject.endCustomer) { + newProject.endCustomer = getNewProjectEndCustomer(); + } + setProject(newProject); // Set a flag to update fields that receive default values from the @@ -120,7 +128,7 @@ export const EditProject = () => {
- + { - const projectEndCustomer : ProjectEndCustomerModel = value || getNewProjectEndCustomer(); + console.log("loading cmp"); + const projectEndCustomer : ProjectEndCustomerModel | undefined | null = value; + + if(!projectEndCustomer){ + return null; + } + return ; } \ No newline at end of file diff --git a/frontend/src/components/project/models/ProjectFormConfig.ts b/frontend/src/components/project/models/ProjectFormConfig.ts index 669d5f31..572715ba 100644 --- a/frontend/src/components/project/models/ProjectFormConfig.ts +++ b/frontend/src/components/project/models/ProjectFormConfig.ts @@ -17,7 +17,7 @@ export const projectFormConfig: FullFormConfig = [ {key: 'projectMonthConfig.inboundInvoice', component: 'switch'}, {key: 'projectMonthConfig.changingOrderNr', component: 'switch'}, {key: 'client.advancedInvoicing', component: 'switch'}, - {key: 'projectMonthConfig.forEndCustomer', component: 'switch'}, + {key: 'forEndCustomer', component: 'switch'}, {title: 'client.notes'}, {key: 'notes', label: '', component: 'TextEditor', cols: 12}, diff --git a/frontend/src/trans.en.ts b/frontend/src/trans.en.ts index edb1619e..dcd748bc 100644 --- a/frontend/src/trans.en.ts +++ b/frontend/src/trans.en.ts @@ -449,6 +449,7 @@ export const trans = { consultantType: 'Type', startDate: 'Start date', endDate: 'End date', + forEndCustomer: 'Project is at end customer', deleteConfirm: { title: 'Delete project', content: 'Project will be permanently deleted.', @@ -483,8 +484,7 @@ export const trans = { titleConfig: 'Monthly invoicing', timesheetCheck: 'Timesheets: Check report', inboundInvoice: 'Has inbound invoice', - changingOrderNr: 'Order nr changes for each invocie', - forEndCustomer: 'Project is at end customer' + changingOrderNr: 'Order nr changes for each invocie' }, copy: { buttonText: 'Verlenging', diff --git a/frontend/src/trans.nl.ts b/frontend/src/trans.nl.ts index 4aeba7d5..df141ac8 100644 --- a/frontend/src/trans.nl.ts +++ b/frontend/src/trans.nl.ts @@ -449,6 +449,7 @@ export const trans = { consultantType: 'Type', startDate: 'Start datum', endDate: 'Eind datum', + forEndCustomer: 'Project is bij eindklant', deleteConfirm: { title: 'Project verwijderen', content: 'Project wordt definitief verwijderd.', @@ -483,8 +484,7 @@ export const trans = { titleConfig: 'Maandelijkse facturatie', timesheetCheck: 'Timesheets: SDWorx rapport check', inboundInvoice: 'Heeft inkomende factuur', - changingOrderNr: 'Het bestelbon nr wijzigt voor elke factuur', - forEndCustomer: 'Project is bij eindklant' + changingOrderNr: 'Het bestelbon nr wijzigt voor elke factuur' }, copy: { buttonText: 'Verlenging',