Feature/transfer/withdrawal/profile - #3
Conversation
756f314 to
d07a8d7
Compare
| <div> | ||
| <button | ||
| className="btn btn-primary text-xl mr-6 cursor-pointer" | ||
| e |
There was a problem hiding this comment.
Why did you add this?
| const currentUser = getUserByAccountNumber(currentUserAccountNumber); | ||
|
|
||
| const schema = yup.object({ | ||
| selectAccount: yup.string(), |
There was a problem hiding this comment.
A more appropriate name for this field would be selectedAccount, which is a noun. selectAccount sounds like an action (a verb), which is not appropriate for input names (and any entity by extension). All input names must be semantically a noun.
Secondly, yup.string() alone is not enough validation rule for this input (an empty string "" will pass this validation). It should have a required validation rule too. As it is, if a user is not selected, the form can still be submitted, which is not desirable.
| export const Transfer = () => { | ||
| const registeredUsers = getAllUsers(); | ||
| const navigate = useNavigate(); | ||
| const [inputValue, setInputValue] = useState(); |
There was a problem hiding this comment.
This is not needed. useForm hook is registering and handling the input changes.
| .length(4, "Account PIN must be exactly 4 digits"), | ||
| }); | ||
|
|
||
| const handleInputChange = (event) => { |
There was a problem hiding this comment.
This is not needed. useForm hook is registering and handling the input changes.
| type="password" | ||
| maxLength={4} | ||
| className="form-control" | ||
| onChange={handleInputChange} |
There was a problem hiding this comment.
This is not needed. useForm hook is registering and handling the input changes.
| .length(4, "Account PIN must be exactly 4 digits"), | ||
| }); | ||
|
|
||
| const handleInputChange = (event) => { |
There was a problem hiding this comment.
This is not needed. useForm hook is registering and handling the input changes.
| onChange={handleInputChange} | ||
| {...register("accountPin")} | ||
| /> | ||
| {inputValue} |
There was a problem hiding this comment.
This is not needed. useForm hook is registering and handling the input changes.
| maxLength={4} | ||
| className="form-control" | ||
| required | ||
| onChange={handleInputChange} |
There was a problem hiding this comment.
This is not needed. useForm hook is registering and handling the input changes.
|
|
||
| /** Spacing */ | ||
| .min-w-100 { | ||
| * Spacing */ .min-w-100 { |
There was a problem hiding this comment.
This is an invalid css comment. Everything after this line will not be processed.
| return user?.transactions || []; | ||
| } | ||
| }; | ||
| export const getUserAccountName = ( |
There was a problem hiding this comment.
This function adds unnecessary granularity to your code. You can get any user data from the user object returned by getUserByAccountNumber().

Added Transfer, Withdrawal, Profile Page