@@ -55,6 +55,7 @@ export class FirestoreDecisionsRepository implements DecisionsRepository {
5555 teamIds : data . teamIds || [ ] ,
5656 projectIds : data . projectIds || [ ] ,
5757 relationships : data . relationships || { } ,
58+ decisionNotes : data . decisionNotes || '' ,
5859 } ;
5960 return Decision . create ( props ) ;
6061 }
@@ -94,10 +95,10 @@ export class FirestoreDecisionsRepository implements DecisionsRepository {
9495 return this . decisionFromFirestore ( docSnap )
9596 }
9697
97- async create ( initialData : Partial < Omit < DecisionProps , "id" > > , scope : DecisionScope ) : Promise < Decision > {
98+ async create ( scope : DecisionScope , initialData : Partial < DecisionProps > = { } ) : Promise < Decision > {
9899 const docRef = doc ( collection ( db , this . getDecisionPath ( scope ) ) )
99100
100- const createData : Record < string , string | string [ ] | null | FieldValue | Record < string , unknown > | DecisionStakeholderRole [ ] | SupportingMaterial [ ] > = {
101+ const data : Record < string , string | string [ ] | null | FieldValue | Record < string , unknown > | DecisionStakeholderRole [ ] | SupportingMaterial [ ] > = {
101102 title : initialData . title ?? '' ,
102103 description : initialData . description ?? '' ,
103104 cost : initialData . cost ?? 'low' ,
@@ -110,16 +111,17 @@ export class FirestoreDecisionsRepository implements DecisionsRepository {
110111 organisationId : scope . organisationId ,
111112 teamIds : initialData . teamIds ?? [ ] ,
112113 projectIds : initialData . projectIds ?? [ ] ,
114+ decisionNotes : initialData . decisionNotes ?? '' ,
113115 createdAt : serverTimestamp ( ) ,
114116 updatedAt : serverTimestamp ( ) ,
115117 }
116118
117119 // Filter out any undefined values
118- const filteredCreateData = Object . fromEntries (
119- Object . entries ( createData ) . filter ( ( [ , value ] ) => value !== undefined )
120+ const filteredData = Object . fromEntries (
121+ Object . entries ( data ) . filter ( ( [ , value ] ) => value !== undefined )
120122 ) ;
121123
122- await setDoc ( docRef , filteredCreateData )
124+ await setDoc ( docRef , filteredData )
123125
124126 return this . getById ( docRef . id , scope )
125127 }
@@ -131,7 +133,7 @@ export class FirestoreDecisionsRepository implements DecisionsRepository {
131133
132134 const docRef = doc ( db , this . getDecisionPath ( scope ) , decision . id )
133135
134- const updateData : Record < string , FieldValue | Partial < unknown > | undefined > = {
136+ const data : Record < string , FieldValue | Partial < unknown > | undefined > = {
135137 title : decision . title ,
136138 description : decision . description ,
137139 cost : decision . cost ,
@@ -145,15 +147,16 @@ export class FirestoreDecisionsRepository implements DecisionsRepository {
145147 teamIds : decision . teamIds ,
146148 projectIds : decision . projectIds ,
147149 publishDate : decision . publishDate ,
150+ decisionNotes : decision . decisionNotes ,
148151 updatedAt : serverTimestamp ( )
149152 }
150153
151154 // Filter out any undefined values
152- const filteredUpdateData = Object . fromEntries (
153- Object . entries ( updateData ) . filter ( ( [ , value ] ) => value !== undefined )
155+ const filteredData = Object . fromEntries (
156+ Object . entries ( data ) . filter ( ( [ , value ] ) => value !== undefined )
154157 ) ;
155158
156- await updateDoc ( docRef , filteredUpdateData )
159+ await updateDoc ( docRef , filteredData )
157160 }
158161
159162 async delete ( id : string , scope : DecisionScope ) : Promise < void > {
0 commit comments