@@ -18,13 +18,15 @@ interface PaymentEditFormProps {
1818 releaseDate, grossAmount, paymentStatus, auditNote,
1919 } : {
2020 releaseDate ?: Date
21+ description ?: string
2122 grossAmount ?: number
2223 paymentStatus ?: string
2324 auditNote ?: string
2425 } ) => void
2526}
2627
2728const PaymentEdit : React . FC < PaymentEditFormProps > = ( props : PaymentEditFormProps ) => {
29+ const [ description , setDescription ] = useState ( '' )
2830 const [ paymentStatus , setPaymentStatus ] = useState ( '' )
2931 const [ releaseDate , setReleaseDate ] = useState ( new Date ( ) )
3032 const [ grossAmount , setGrossAmount ] = useState ( 0 )
@@ -35,6 +37,7 @@ const PaymentEdit: React.FC<PaymentEditFormProps> = (props: PaymentEditFormProps
3537
3638 const initialValues = useMemo ( ( ) => ( {
3739 auditNote : '' ,
40+ description : props . payment . description ,
3841 grossAmount : props . payment . grossAmountNumber ,
3942 paymentStatus : props . payment . status ,
4043 releaseDate : props . payment . releaseDateObj ,
@@ -85,6 +88,15 @@ const PaymentEdit: React.FC<PaymentEditFormProps> = (props: PaymentEditFormProps
8588 } )
8689 }
8790
91+ break
92+ case 'description' :
93+ setDescription ( value as string )
94+ if ( props . onValueUpdated ) {
95+ props . onValueUpdated ( {
96+ description : value as string ,
97+ } )
98+ }
99+
88100 break
89101 case 'releaseDate' :
90102 setReleaseDate ( value as Date )
@@ -110,13 +122,17 @@ const PaymentEdit: React.FC<PaymentEditFormProps> = (props: PaymentEditFormProps
110122 }
111123
112124 useEffect ( ( ) => {
125+ setDescription ( props . payment . description )
113126 setPaymentStatus ( props . payment . status )
114127 setReleaseDate ( props . payment . releaseDateObj )
115128 setGrossAmount ( props . payment . grossAmountNumber )
116129 } , [ props . payment ] )
117130
118131 useEffect ( ( ) => {
119132 const valuesToCheck = [ {
133+ key : 'description' ,
134+ value : description ,
135+ } , {
120136 key : 'grossPayment' ,
121137 value : grossAmount ,
122138 } , {
@@ -132,14 +148,17 @@ const PaymentEdit: React.FC<PaymentEditFormProps> = (props: PaymentEditFormProps
132148
133149 const isDirty = valuesToCheck . some ( x => x . value !== initialValues [ x . key as keyof typeof initialValues ] )
134150 setDirty ( isDirty )
135- } , [ grossAmount , paymentStatus , releaseDate , auditNote , initialValues ] )
151+ } , [ description , grossAmount , paymentStatus , releaseDate , auditNote , initialValues ] )
136152
137153 useEffect ( ( ) => {
138154 if ( props . canSave ) {
139155 if ( ! dirty ) {
140156 props . canSave ( false )
141157 } else {
142158 const valuesToCheck = [ {
159+ key : 'description' ,
160+ value : description ,
161+ } , {
143162 key : 'grossPayment' ,
144163 value : grossAmount ,
145164 } , {
@@ -154,7 +173,7 @@ const PaymentEdit: React.FC<PaymentEditFormProps> = (props: PaymentEditFormProps
154173 props . canSave ( haveChange && grossAmountErrorString . length === 0 && auditNote . length > 0 )
155174 }
156175 }
157- } , [ dirty , auditNote , props , grossAmountErrorString . length , grossAmount , paymentStatus , releaseDate , initialValues ] )
176+ } , [ dirty , auditNote , props , grossAmountErrorString . length , description , grossAmount , paymentStatus , releaseDate , initialValues ] )
158177
159178 const getLink = ( externalId : string ) : string => `${ TOPCODER_URL } /challenges/${ externalId } `
160179
@@ -208,8 +227,21 @@ const PaymentEdit: React.FC<PaymentEditFormProps> = (props: PaymentEditFormProps
208227 error = { grossAmountErrorString }
209228 value = { props . payment . grossAmountNumber . toString ( ) }
210229 onChange = { e => handleInputChange ( 'grossPayment' , parseFloat ( e . target . value ) ) }
230+ />
211231
232+ < InputText
233+ name = 'description'
234+ label = 'Description'
235+ type = 'text'
236+ disabled = { disableEdits }
237+ placeholder = 'Modify Description'
238+ dirty
239+ tabIndex = { 0 }
240+ error = { ! description ?. length ? 'Description can\'t be empty' : '' }
241+ value = { props . payment . description . toString ( ) }
242+ onChange = { e => handleInputChange ( 'description' , e . target . value ) }
212243 />
244+
213245 < InputSelect
214246 tabIndex = { - 1 }
215247 dirty
0 commit comments