Open whatSocks opened 2 years ago
The API should throw a Validation Error and the frontend should display a message saying something like "you can't send voice credits to yourself"
Does this issue still need work? I see TransferModal.tsx has code aiming address it upon user submission...
} else if (recipient === userobj().public_username || recipient === userobj().email) {
alert.error("You cannot send credits to yourself");
}
If there is more to be done @alexrandaccio, I can give it a try (maybe with some assistance).
sorry for the late reply--busy week last week. let me replicate this
Describe the bug
the API is throwing a ValidationError as expected, but the frontend is not displaying an error message to the user. instead, you hit the "submit" button, and nothing happens at all.
Steps to Reproduce
Expected Behavior
the frontend should display a message saying "you cannot send voice credits to yourself"
@ChrisCoastal identified the correct code snippet in a comment above. This code snippet checks the id of the recipient against the id of the logged in delegate.
The problem is, when you click "+ Invite Someone Else", you enter an email address, so recipient.id === undefined. As a result, this check does not catch the error.
The solution is to add an additional check:
else if (recipient === userDelegate.profile.user.email) { alert.error("You cannot send credits to yourself"); }
@ChrisCoastal thanks for volunteering! I'll go ahead and assign this to you for now, but feel free to let me know if you need more help or don't have time
@whatSocks if you are following the steps above and seeing a different result, let us know
Thanks both for your help 🤠 🚀
Thanks @alexrandaccio; I'll have time for this over the weekend. Very much appreciate your extra guidance and time getting me setup. 🙏
Hey @alexrandaccio, was just taking a look at this and unfortunately am a little lost. 🦑
I'm not sure what the userDelegate object you are referring to in your solution is (and subsequently how the check is meant to function).
I checked the props Delegation.tsx is passing to TransferModal.tsx and some of the other imports in TransferModal, but still can't follow your fix.
Thanks for the extra support! 💫
@ChrisCoastal no problem! Here's some relevant info (disclaimer: I am using "event" and "process" interchangeably here. That's because the model is currently called Process but I am transitioning to Event because it will be clearer. sorry for the confusion)
userDelegate
contains information about the logged in user that pertains to the currently selected event/process selectedProcess
.User
, Profile
, and Delegate
objects, i'll refer you to #80 Process
object is loaded and stored in StateContext
. See the selectProcess()
function call in ProcessPage.tsx and definition in AppProvider.tsx.selectProcess()
, we also set a value for delegate
. The value of delegate
is then passed as a prop to DelegationPage, and from there, it is passed as a prop to TransferModal. When it appears in props, it is called userDelegate
to differentiate it from the delegate objects corresponding to other participants in the selected event/process. i.e. delegate
= someone participating in this event | userDelegate
= the logged in user.recipient
is passed as a prop to TransferModal
. It represents the person to whom the logged in user is trying to send a transfer.Delegate
object selected by the logged in user sorry the variable naming is not super clear, I'm gradually trying to fix that. Hope this is helpful, let me know if you have any follow up questions!
not sure if this is expected behavior, but what should happen if I try to send credits to the email that I'm currently logged in with? Right now it seems like credits get taken out, but I can't re-claim them.