diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index 8bdb053ef0251f8841eca38a04a18595aa80aefb..2913e411214e4bd42e70662d9439b050fee103e0 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -187,11 +187,12 @@ export class Structure { } public getLabelTypeStructure(): StructureTypeEnum | '' { - return StructureTypeEnum[this.structureType.value] || ''; + if (this.structureType) return StructureTypeEnum[this.structureType.value] || ''; + return ''; } public getTypeStructureIcon(): StructureCategoryIconEnum { - switch (this.structureType.category) { + switch (this.structureType?.category) { case StructureCategoryEnum.public: return StructureCategoryIconEnum['public']; case StructureCategoryEnum.private: diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index f8d6af25f0c9b91260018f612461ca34207e5d42..0224f445a2de3000ab262b163b77216c7488047b 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -35,9 +35,6 @@ export class StructureService { public editStructure(structure: Partial<Structure>, structureId?: string): Observable<Structure> { structure.updatedAt = new Date().toString(); - if (structure.dataShareConsentDate) { - structure.dataShareConsentDate = new Date().toString(); - } if (!structureId) structureId = structure._id; delete structure._id; // id should not be provided for update return this.http diff --git a/src/app/shared/components/data-share-consent/data-share-consent.component.ts b/src/app/shared/components/data-share-consent/data-share-consent.component.ts index 04717b46d6a0120e25af9cd5ebcbcd838a8b2154..476e73811b784474c3f3b39996365c8635f5dbaf 100644 --- a/src/app/shared/components/data-share-consent/data-share-consent.component.ts +++ b/src/app/shared/components/data-share-consent/data-share-consent.component.ts @@ -78,9 +78,17 @@ export class DataShareConsentComponent implements OnInit { this.submitted = true; this.loading = true; for (let structure of this.dataConsentPendingStructures) { - this.structureService.editStructure(structure).subscribe((_s: Structure) => {}); + this.structureService + .editStructure( + { + dataShareConsentDate: structure.dataShareConsentDate, + }, + structure._id + ) + .subscribe((_s: Structure) => { + this.loading = false; + this.openned = false; + }); } - this.loading = false; - this.openned = false; } } diff --git a/src/app/utils/formUtils.ts b/src/app/utils/formUtils.ts index 005b30292b8a111283e43c875aabb0f10e6aa3cf..40e915ce0210c2e2af3940f83e420acf989e0dea 100644 --- a/src/app/utils/formUtils.ts +++ b/src/app/utils/formUtils.ts @@ -125,7 +125,7 @@ export class formUtils { handicaps: this.loadArrayForCheckbox(structure.categories.handicaps, false), age: this.loadArrayForCheckbox(structure.categories.age, true), languageAndIlliteracy: this.loadArrayForCheckbox(structure.categories.languageAndIlliteracy, false), - selfServiceMaterial: this.loadArrayForCheckbox(structure.categories.selfServiceMaterial, true), + selfServiceMaterial: this.loadArrayForCheckbox(structure.categories.selfServiceMaterial, false), publicOthers: this.loadArrayForCheckbox(structure.categories.publicOthers, false), equipmentsAndServices: this.loadArrayForCheckbox(structure.categories.equipmentsServices, false), baseSkills: new UntypedFormControl(structure.categories.baseSkills),