@@ -2,20 +2,22 @@ import { useLingui } from '@lingui/react/macro'
22import { useNavigation } from '@react-navigation/native'
33import { useForm } from '@tetherto/pear-apps-lib-ui-react-hooks'
44import { Validator } from '@tetherto/pear-apps-utils-validator'
5- import { RECORD_TYPES , useCreateRecord , useRecords } from '@tetherto/pearpass-lib-vault'
5+ import {
6+ RECORD_TYPES ,
7+ useCreateRecord ,
8+ useRecords
9+ } from '@tetherto/pearpass-lib-vault'
610import {
711 Button ,
812 InputField ,
913 MultiSlotInput ,
1014 PasswordField ,
1115 Text ,
16+ TextArea ,
1217 rawTokens ,
1318 useTheme
1419} from '@tetherto/pearpass-lib-ui-kit'
15- import {
16- Add ,
17- TrashOutlined
18- } from '@tetherto/pearpass-lib-ui-kit/icons'
20+ import { Add , TrashOutlined } from '@tetherto/pearpass-lib-ui-kit/icons'
1921import { StyleSheet , View } from 'react-native'
2022import Toast from 'react-native-toast-message'
2123
@@ -111,15 +113,15 @@ export const CreateOrEditNoteContent = ({
111113
112114 const { handleSubmit, registerArray, values, setValue, errors } =
113115 useForm < FormValues > ( {
114- initialValues : {
115- title : initialRecord ?. data ?. title ?? '' ,
116- note : initialRecord ?. data ?. note ?? '' ,
117- customFields : initialRecord ?. data ?. customFields ?? [ ] ,
118- folder : selectedFolder ?? initialRecord ?. folder ?? '' ,
119- attachments : initialRecord ?. attachments ?? [ ]
120- } ,
121- validate : ( formValues ) => schema . validate ( formValues )
122- } )
116+ initialValues : {
117+ title : initialRecord ?. data ?. title ?? '' ,
118+ note : initialRecord ?. data ?. note ?? '' ,
119+ customFields : initialRecord ?. data ?. customFields ?? [ ] ,
120+ folder : selectedFolder ?? initialRecord ?. folder ?? '' ,
121+ attachments : initialRecord ?. attachments ?? [ ]
122+ } ,
123+ validate : ( formValues ) => schema . validate ( formValues )
124+ } )
123125
124126 useGetMultipleFiles ( {
125127 fieldNames : [ 'attachments' ] ,
@@ -158,7 +160,9 @@ export const CreateOrEditNoteContent = ({
158160 data : {
159161 title : formValues . title ,
160162 note : formValues . note ,
161- customFields : formValues . customFields . filter ( ( f ) => f . note ?. trim ( ) . length ) ,
163+ customFields : formValues . customFields . filter (
164+ ( f ) => f . note ?. trim ( ) . length
165+ ) ,
162166 attachments : convertBase64FilesToUint8 (
163167 formValues . attachments . filter ( isUploadedNoteAttachment )
164168 )
@@ -189,7 +193,10 @@ export const CreateOrEditNoteContent = ({
189193 setValue ( 'attachments' , [ ...values . attachments , file ] )
190194 }
191195
192- const handleAttachmentReplace = ( index : number , file ?: NoteAttachment | null ) => {
196+ const handleAttachmentReplace = (
197+ index : number ,
198+ file ?: NoteAttachment | null
199+ ) => {
193200 if ( ! file ) {
194201 return
195202 }
@@ -246,11 +253,11 @@ export const CreateOrEditNoteContent = ({
246253 { t `Details` }
247254 </ Text >
248255
249- < InputField
256+ < TextArea
250257 label = { t `Note` }
251258 value = { values . note }
252259 placeholder = { t `Enter Note` }
253- onChangeText = { ( value ) => setValue ( 'note' , value ) }
260+ onChange = { ( value ) => setValue ( 'note' , value ) }
254261 testID = "note-field"
255262 />
256263 </ View >
@@ -292,34 +299,32 @@ export const CreateOrEditNoteContent = ({
292299 testID = "hidden-messages-multi-slot-input"
293300 >
294301 { customFieldsList . length ? (
295- customFieldsList . map (
296- ( field , index ) => (
297- < PasswordField
298- key = { `${ field . type } -${ index } ` }
299- label = { t `Hidden Message` }
300- value = { field . note ?? '' }
301- placeholder = { t `Enter Hidden Message` }
302- onChangeText = { ( value ) =>
303- setValue ( `customFields[${ index } ].note` , value )
304- }
305- isGrouped
306- testID = { `hidden-messages-multi-slot-input-slot-${ index } ` }
307- rightSlot = {
308- customFieldsList . length > 1 ? (
309- < Button
310- size = "small"
311- variant = "tertiary"
312- aria-label = "Delete hidden message"
313- iconBefore = {
314- < TrashOutlined color = { theme . colors . colorTextPrimary } />
315- }
316- onClick = { ( ) => removeCustomField ( index ) }
317- />
318- ) : undefined
319- }
320- />
321- )
322- )
302+ customFieldsList . map ( ( field , index ) => (
303+ < PasswordField
304+ key = { `${ field . type } -${ index } ` }
305+ label = { t `Hidden Message` }
306+ value = { field . note ?? '' }
307+ placeholder = { t `Enter Hidden Message` }
308+ onChangeText = { ( value ) =>
309+ setValue ( `customFields[${ index } ].note` , value )
310+ }
311+ isGrouped
312+ testID = { `hidden-messages-multi-slot-input-slot-${ index } ` }
313+ rightSlot = {
314+ customFieldsList . length > 1 ? (
315+ < Button
316+ size = "small"
317+ variant = "tertiary"
318+ aria-label = "Delete hidden message"
319+ iconBefore = {
320+ < TrashOutlined color = { theme . colors . colorTextPrimary } />
321+ }
322+ onClick = { ( ) => removeCustomField ( index ) }
323+ />
324+ ) : undefined
325+ }
326+ />
327+ ) )
323328 ) : (
324329 < PasswordField
325330 label = { t `Hidden Message` }
0 commit comments