Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 29 additions & 44 deletions src/screens/CreateRecord/CreateOrEditCreditCardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ export const CreateOrEditCreditCardContent = ({
securityCode: initialRecord?.data?.securityCode ?? '',
pinCode: initialRecord?.data?.pinCode ?? '',
note: initialRecord?.data?.note ?? '',
customFields: initialRecord?.data?.customFields ?? [],
customFields: initialRecord?.data?.customFields?.length
? initialRecord.data.customFields
: [{ type: 'note', note: '' }],
folder: selectedFolder ?? initialRecord?.folder,
attachments: getRecordAttachments(initialRecord)
},
Expand Down Expand Up @@ -203,10 +205,6 @@ export const CreateOrEditCreditCardContent = ({
removeItem: removeCustomField
} = registerArray('customFields')

const handleFirstHiddenMessageChange = (value: string) => {
setValue('customFields', value ? [{ type: 'note', note: value }] : [])
}

const handleExpireDateChange = (inputValue: string) => {
let value = inputValue.replace(/\D/g, '')

Expand Down Expand Up @@ -385,45 +383,32 @@ export const CreateOrEditCreditCardContent = ({
}
testID="hidden-messages-multi-slot-input"
>
{values.customFields.length
? values.customFields.map(
(field, index) => (
<PasswordField
key={index}
label={t`Hidden Message`}
value={field.note ?? ''}
placeholder={t`Enter Hidden Message`}
onChangeText={(val) =>
setValue(`customFields[${index}].note`, val)
}
isGrouped
testID={`hidden-messages-multi-slot-input-slot-${index}`}
rightSlot={
values.customFields.length > 1 ? (
<Button
size="small"
variant="tertiary"
aria-label="Delete hidden message"
iconBefore={
<TrashOutlined color={theme.colors.colorTextPrimary} />
}
onClick={() => removeCustomField(index)}
/>
) : undefined
}
/>
)
)
: (
<PasswordField
label={t`Hidden Message`}
value=""
placeholder={t`Enter Hidden Message`}
onChangeText={handleFirstHiddenMessageChange}
isGrouped
testID="hidden-messages-multi-slot-input-slot-0"
/>
)}
{values.customFields.map((field, index) => (
<PasswordField
key={index}
label={t`Hidden Message`}
value={field.note ?? ''}
placeholder={t`Enter Hidden Message`}
onChangeText={(val) =>
setValue(`customFields[${index}].note`, val)
}
isGrouped
testID={`hidden-messages-multi-slot-input-slot-${index}`}
rightSlot={
values.customFields.length > 1 ? (
<Button
size="small"
variant="tertiary"
aria-label="Delete hidden message"
iconBefore={
<TrashOutlined color={theme.colors.colorTextPrimary} />
}
onClick={() => removeCustomField(index)}
/>
) : undefined
}
/>
))}
</MultiSlotInput>
</View>
</Layout>
Expand Down
65 changes: 26 additions & 39 deletions src/screens/CreateRecord/CreateOrEditIdentityContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ export const CreateOrEditIdentityContent = ({
region: initialRecord?.data?.region ?? '',
country: initialRecord?.data?.country ?? '',
note: initialRecord?.data?.note ?? '',
customFields: initialRecord?.data?.customFields ?? [],
customFields: initialRecord?.data?.customFields?.length
? initialRecord.data.customFields
: [{ type: 'note', note: '' }],
folder: selectedFolder ?? initialRecord?.folder ?? '',
passportFullName: initialRecord?.data?.passportFullName ?? '',
passportNumber: initialRecord?.data?.passportNumber ?? '',
Expand Down Expand Up @@ -318,10 +320,6 @@ export const CreateOrEditIdentityContent = ({
removeItem: removeCustomField
} = registerArray('customFields')

const handleFirstHiddenMessageChange = (value: string) => {
setValue('customFields', value ? [{ type: 'note', note: value }] : [])
}

const identityAttachmentSources = useMemo(
() =>
buildIdentityAttachmentSources({
Expand Down Expand Up @@ -739,45 +737,34 @@ export const CreateOrEditIdentityContent = ({
}
testID="hidden-messages-multi-slot-input"
>
{(values.customFields as Array<{ type: string; note?: string }>).length
? (values.customFields as Array<{ type: string; note?: string }>).map(
(field, index) => (
<PasswordField
key={`${field.type}-${index}`}
label={t`Hidden Message`}
value={field.note ?? ''}
placeholder={t`Enter Hidden Message`}
onChangeText={(val) =>
setValue(`customFields[${index}].note`, val)
}
isGrouped
testID={`hidden-messages-multi-slot-input-slot-${index}`}
rightSlot={
(values.customFields as Array<{ type: string; note?: string }>).length > 1 ? (
<Button
size="small"
variant="tertiary"
aria-label="Delete hidden message"
iconBefore={
<TrashOutlined color={theme.colors.colorTextPrimary} />
}
onClick={() => removeCustomField(index)}
/>
) : undefined
}
/>
)
)
: (
{(values.customFields as Array<{ type: string; note?: string }>).map(
(field, index) => (
<PasswordField
key={`${field.type}-${index}`}
label={t`Hidden Message`}
value=""
value={field.note ?? ''}
placeholder={t`Enter Hidden Message`}
onChangeText={handleFirstHiddenMessageChange}
onChangeText={(val) =>
setValue(`customFields[${index}].note`, val)
}
isGrouped
testID="hidden-messages-multi-slot-input-slot-0"
testID={`hidden-messages-multi-slot-input-slot-${index}`}
rightSlot={
(values.customFields as Array<{ type: string; note?: string }>).length > 1 ? (
<Button
size="small"
variant="tertiary"
aria-label="Delete hidden message"
iconBefore={
<TrashOutlined color={theme.colors.colorTextPrimary} />
}
onClick={() => removeCustomField(index)}
/>
) : undefined
}
/>
)}
)
)}
</MultiSlotInput>
</View>
</Layout>
Expand Down
63 changes: 25 additions & 38 deletions src/screens/CreateRecord/CreateOrEditLoginContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ export const CreateOrEditLoginContent = ({
websites: initialRecord?.data?.websites?.length
? initialRecord.data.websites.map((website) => ({ website }))
: [{ website: '' }],
customFields: initialRecord?.data?.customFields ?? [],
customFields: initialRecord?.data?.customFields?.length
? initialRecord.data.customFields
: [{ type: 'note', note: '' }],
folder: selectedFolder ?? initialRecord?.folder,
attachments: getRecordAttachments(initialRecord),
credential: initialRecord?.data?.credential?.id ?? '',
Expand Down Expand Up @@ -268,10 +270,6 @@ export const CreateOrEditLoginContent = ({
removeItem: removeCustomField
} = registerArray('customFields')

const handleFirstHiddenMessageChange = (value: string) => {
setValue('customFields', value ? [{ type: 'note', note: value }] : [])
}

const openPasswordGenerator = () => {
Keyboard.dismiss()
navigation.navigate('CreatePasswordItem', {
Expand Down Expand Up @@ -505,39 +503,28 @@ export const CreateOrEditLoginContent = ({
errorMessage={(errors as Record<string, { error?: { note?: string } }[]>)?.customFields?.find(Boolean)?.error?.note}
testID="hidden-messages-multi-slot-input"
>
{values.customFields.length
? values.customFields.map((field, index) => (
<PasswordField
key={index}
label={t`Hidden Message`}
value={field.note ?? ''}
placeholder={t`Enter Hidden Message`}
onChangeText={(val) => setValue(`customFields[${index}].note`, val)}
isGrouped
testID={`hidden-messages-multi-slot-input-slot-${index}`}
rightSlot={
values.customFields.length > 1 ? (
<Button
size='small'
variant="tertiary"
aria-label="Delete hidden message"
iconBefore={<TrashOutlined color={theme.colors.colorTextPrimary} />}
onClick={() => removeCustomField(index)}
/>
) : undefined
}
/>
))
: (
<PasswordField
label={t`Hidden Message`}
value=""
placeholder={t`Enter Hidden Message`}
onChangeText={handleFirstHiddenMessageChange}
isGrouped
testID="hidden-messages-multi-slot-input-slot-0"
/>
)}
{values.customFields.map((field, index) => (
<PasswordField
key={index}
label={t`Hidden Message`}
value={field.note ?? ''}
placeholder={t`Enter Hidden Message`}
onChangeText={(val) => setValue(`customFields[${index}].note`, val)}
isGrouped
testID={`hidden-messages-multi-slot-input-slot-${index}`}
rightSlot={
values.customFields.length > 1 ? (
<Button
size='small'
variant="tertiary"
aria-label="Delete hidden message"
iconBefore={<TrashOutlined color={theme.colors.colorTextPrimary} />}
onClick={() => removeCustomField(index)}
/>
) : undefined
}
/>
))}
</MultiSlotInput>
</View>
</Layout>
Expand Down
67 changes: 27 additions & 40 deletions src/screens/CreateRecord/CreateOrEditWifiPasswordContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export const CreateOrEditWifiPasswordContent = ({
title: initialRecord?.data?.title ?? '',
password: initialRecord?.data?.password ?? '',
note: initialRecord?.data?.note ?? '',
customFields: initialRecord?.data?.customFields ?? [],
customFields: initialRecord?.data?.customFields?.length
? initialRecord.data.customFields
: [{ type: 'note', note: '' }],
folder: selectedFolder ?? initialRecord?.folder
},
validate: (formValues) => schema.validate(formValues)
Expand Down Expand Up @@ -149,10 +151,6 @@ export const CreateOrEditWifiPasswordContent = ({
removeItem: removeCustomField
} = registerArray('customFields')

const handleFirstHiddenMessageChange = (value: string) => {
setValue('customFields', value ? [{ type: 'note', note: value }] : [])
}

const openPasswordGenerator = () => {
Keyboard.dismiss()
navigation.navigate('CreatePasswordItem', {
Expand Down Expand Up @@ -254,46 +252,35 @@ export const CreateOrEditWifiPasswordContent = ({
}
testID="hidden-messages-multi-slot-input"
>
{(values.customFields as Array<{ type: string; note: string }>).length
? (values.customFields as Array<{ type: string; note: string }>).map(
(field, index) => (
<PasswordField
key={index}
label={t`Hidden Message`}
value={field.note ?? ''}
placeholder={t`Enter Hidden Message`}
onChangeText={(val) =>
setValue(`customFields[${index}].note`, val)
}
isGrouped
testID={`hidden-messages-multi-slot-input-slot-${index}`}
rightSlot={
(values.customFields as Array<{ type: string; note: string }>)
.length > 1 ? (
<Button
size="small"
variant="tertiary"
aria-label="Delete hidden message"
iconBefore={
<TrashOutlined color={theme.colors.colorTextPrimary} />
}
onClick={() => removeCustomField(index)}
/>
) : undefined
}
/>
)
)
: (
{(values.customFields as Array<{ type: string; note: string }>).map(
(field, index) => (
<PasswordField
key={index}
label={t`Hidden Message`}
value=""
value={field.note ?? ''}
placeholder={t`Enter Hidden Message`}
onChangeText={handleFirstHiddenMessageChange}
onChangeText={(val) =>
setValue(`customFields[${index}].note`, val)
}
isGrouped
testID="hidden-messages-multi-slot-input-slot-0"
testID={`hidden-messages-multi-slot-input-slot-${index}`}
rightSlot={
(values.customFields as Array<{ type: string; note: string }>)
.length > 1 ? (
<Button
size="small"
variant="tertiary"
aria-label="Delete hidden message"
iconBefore={
<TrashOutlined color={theme.colors.colorTextPrimary} />
}
onClick={() => removeCustomField(index)}
/>
) : undefined
}
/>
)}
)
)}
</MultiSlotInput>
</View>
</Layout>
Expand Down
Loading