@@ -58,6 +58,7 @@ class MilestoneTypeDelivery extends React.Component {
5858 this . onFinalFixRemove = this . onFinalFixRemove . bind ( this )
5959 this . onFinalFixChange = this . onFinalFixChange . bind ( this )
6060 this . submitFinalFixesRequest = this . submitFinalFixesRequest . bind ( this )
61+ this . completeMilestone = this . completeMilestone . bind ( this )
6162 }
6263
6364 componentWillReceiveProps ( nextProps ) {
@@ -120,19 +121,11 @@ class MilestoneTypeDelivery extends React.Component {
120121 }
121122
122123 acceptDesign ( ) {
123- const { completeMilestone, milestone } = this . props
124-
125- const content = _ . get ( milestone , 'details.content' , { } )
126-
127- completeMilestone ( {
128- details : {
129- ...milestone . details ,
130- content : {
131- ...content ,
132- isAccepted : true ,
133- isDeclined : false ,
134- }
135- }
124+ const { updateMilestoneContent } = this . props
125+
126+ updateMilestoneContent ( {
127+ isAccepted : true ,
128+ isDeclined : false
136129 } )
137130 }
138131
@@ -178,24 +171,41 @@ class MilestoneTypeDelivery extends React.Component {
178171 )
179172 }
180173
174+ completeMilestone ( ) {
175+ const { completeMilestone } = this . props
176+
177+ completeMilestone ( )
178+ }
179+
181180 getDescription ( ) {
182181 const { milestone } = this . props
183182
184183 return milestone [ `${ milestone . status } Text` ]
185184 }
186185
187186 render ( ) {
188- const { milestone, theme, currentUser } = this . props
187+ const { milestone, theme, currentUser, previousMilestone } = this . props
189188 const { isShowFinalFixesRequestForm, finalFixRequests } = this . state
190- const links = _ . get ( milestone , 'details.prevMilestoneContent.links' , [ ] )
191189 const isAccepted = _ . get ( milestone , 'details.content.isAccepted' , false )
192190 const isDeclined = _ . get ( milestone , 'details.content.isDeclined' , false )
193191 const isFinalFixesSubmitted = _ . get ( milestone , 'details.content.isFinalFixesSubmitted' , false )
194192 const isActive = milestone . status === MILESTONE_STATUS . ACTIVE
195193 const isCompleted = milestone . status === MILESTONE_STATUS . COMPLETED
194+ //console.log(" ", milestone.details.content, " : ", isAccepted, " : ", milestone.name)
196195
197196 const canSubmitFinalFixes = _ . some ( finalFixRequests , ( finalFixRequest ) => ! ! finalFixRequest . value )
198197
198+ const isFinalFixPresent = previousMilestone === 'final-fix'
199+ let links = ''
200+ const deliveryButtons = [ { title : acceptDialogue [ milestone . type ] . button , onClick : this . acceptDesign , type : 'primary' } ]
201+ if ( isFinalFixPresent ) {
202+ deliveryButtons . push ( { title : 'Request fixes' , onClick : this . showFinalFixesRequestForm , type : 'default' } )
203+ }
204+ if ( isFinalFixesSubmitted ) {
205+ links = _ . get ( milestone , 'details.prevMilestoneContent.links' , [ ] )
206+ } else {
207+ links = _ . get ( milestone , 'details.content.links' , [ ] )
208+ }
199209 return (
200210 < div styleName = { cn ( 'milestone-post' , theme ) } >
201211 < DotIndicator hideDot >
@@ -242,10 +252,7 @@ class MilestoneTypeDelivery extends React.Component {
242252 theme = "primary"
243253 message = { acceptDialogue [ milestone . type ] . text }
244254 isShowSelection = { false }
245- buttons = { [
246- { title : 'Request fixes' , onClick : this . showFinalFixesRequestForm , type : 'default' } ,
247- { title : acceptDialogue [ milestone . type ] . button , onClick : this . acceptDesign , type : 'primary' } ,
248- ] }
255+ buttons = { deliveryButtons }
249256 />
250257 </ div >
251258 </ DotIndicator >
@@ -284,6 +291,42 @@ class MilestoneTypeDelivery extends React.Component {
284291 </ DotIndicator >
285292 </ div >
286293 ) }
294+
295+ { ( isAccepted ) && (
296+ < div >
297+ { ! currentUser . isCustomer && (
298+ < DotIndicator >
299+ < LinkList
300+ links = { links }
301+ onAddLink = { this . updatedUrl }
302+ onRemoveLink = { this . removeUrl }
303+ onUpdateLink = { this . updatedUrl }
304+ fields = { [ { name : 'url' } ] }
305+ addButtonTitle = "Add link"
306+ formAddTitle = "Adding a link"
307+ formAddButtonTitle = "Add a link"
308+ formUpdateTitle = "Editing a link"
309+ formUpdateButtonTitle = "Save changes"
310+ isUpdating = { milestone . isUpdating }
311+ canAddLink
312+ />
313+ < div styleName = "top-space" >
314+ < div styleName = "button-layer" >
315+ < button
316+ className = "tc-btn tc-btn-primary tc-btn-sm action-btn"
317+ onClick = { this . completeMilestone }
318+ disabled = { links . length === 0 }
319+ >
320+ Mark as completed
321+ </ button >
322+ </ div >
323+ </ div >
324+ </ DotIndicator >
325+ ) }
326+ </ div >
327+ ) }
328+
329+
287330 </ div >
288331 ) }
289332
0 commit comments