Skip to content

Commit

Permalink
fix(wallet): not possible anymore to choose an existing profilename d…
Browse files Browse the repository at this point in the history
…uring recovery (#2899)
  • Loading branch information
sstraatemans authored Mar 7, 2025
1 parent 2822382 commit 8dd1868
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-cougars-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kadena/dev-wallet': patch
---

not possible anymore to choose an existing profilename during recovery
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ export function RecoverFromMnemonic() {
control,
formState: { isValid, errors },
} = useForm<Inputs>({
mode: 'onChange',
defaultValues: {
mnemonic: '',
profileName:
profileList.length === 0
? 'default'
: `profile-${profileList.length + 1}`,
profileName: '',
accentColor:
config.colorList[profileList.length % config.colorList.length],
password: '',
Expand Down Expand Up @@ -295,13 +293,39 @@ export function RecoverFromMnemonic() {
)}
</Stack>

<TextField
label="Profile name"
id="name"
type="text"
defaultValue={profileName}
value={profileName}
{...register('profileName')}
<Controller
control={control}
name="profileName"
rules={{
required: {
value: true,
message: 'This field is required',
},
minLength: { value: 6, message: 'Minimum 6 symbols' },
maxLength: { value: 30, message: 'Maximym 30 symbols' },
validate: {
required: (value) => {
const existingProfile = profileList.find(
(profile) => profile.name === value,
);
if (existingProfile)
return `The profile name ${value} already exists. Please use another name.`;
return true;
},
},
}}
render={({ field }) => (
<TextField
label="Profile name"
id="name"
type="text"
defaultValue={profileName}
value={field.value}
{...register('profileName')}
isInvalid={!!errors.profileName}
errorMessage={errors.profileName?.message}
/>
)}
/>
</Stack>
<Stack flexDirection={'column'} gap={'lg'}>
Expand Down

0 comments on commit 8dd1868

Please sign in to comment.