-
-
Notifications
You must be signed in to change notification settings - Fork 937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: removes ability to have duplicate account names on front-end #2776
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Overall looks very good and solves 50% of the problem. The other 50% is: we should also catch this issue when an account is renamed.
@@ -49,7 +55,12 @@ export function CreateLocalAccountModal({ | |||
event.preventDefault(); | |||
|
|||
const nameError = !name; | |||
setNameError(nameError); | |||
setNameError({ error: nameError, message: 'Name is required' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 suggestion: we can put this in a conditional and return early if the error is encountered. Saves us a tiny amount of compute.
setNameError({ error: nameError, message: 'Name is required' }); | |
if (!name) { | |
setNameError({ error: true, message: 'Name is required' }); | |
return; | |
} |
const [nameError, setNameError] = useState(false); | ||
const [nameError, setNameError] = useState({ | ||
error: false, | ||
message: 'Name is required', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 suggestion: initially there should be no error
message: 'Name is required', | |
message: '', |
@@ -75,15 +86,17 @@ export function CreateLocalAccountModal({ | |||
const name = event.target.value.trim(); | |||
setName(name); | |||
if (name && nameError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 suggestion: since we now have multiple types of errors: I think we can reset to the "no error" state if there previously was an error instead of using the name
var
if (name && nameError) { | |
if (nameError.error) { |
setNameError(nameError); | ||
setNameError({ error: nameError, message: 'Name is required' }); | ||
|
||
if (accounts.some(account => account.name === name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 thought: I wonder if we should make this case insensitive. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave that up to the user. I'd say more control is better than less control, but that is just my opinion. LMK if we should change. Can always be done later.
I changed a couple things, added the editing name error functionality as well to check for duplicated and add an error if found. Screen.Recording.2024-05-18.at.4.07.59.PM.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks really good! Just two small comments. Let me know your thoughts.
if (nameError.error) { | ||
setNameError(nameError); | ||
} else { | ||
setNameError({ error: false, message: '' }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 suggestion: could simplify this further
if (nameError.error) { | |
setNameError(nameError); | |
} else { | |
setNameError({ error: false, message: '' }); | |
} | |
setNameError(nameError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can take a look at that, I think when I tried that maybe it needed to get un-set, if not, I'm not sure why I didn't do that in the first place haha
return { error: true, message: `Name: “${name}” already exists.` }; | ||
} | ||
|
||
return { error: false, message: '' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥜 nitpick: what if we always returned a string
in this util? Then we could re-use it in both this modal and the account page. Slightly less duplication of logic.
What do you guys think about putting the error message on the right of the input to avoid shifting the position of the transactions table? |
@joel-jeremy I did think of the position to the right, but I'm not too sure how that would work mobile-y. Maybe could look into a popup of some sort? |
Does this affect setting up bank sync? Here is a scenario (based on real world): I have 10 accounts that SimpleFIN lists with identical names (ugg...). I want to import two of them from the dialog, so I select 'Create new account' next to both. Currently, this would create two identically named accounts in Actual. If I want to then disambiguate them, I could rename one/both. Or, as in my case, maybe I don't really care and leave them the same because there will not be transfers to/from them. |
ref: #316