Skip to content

Conversation

@qiyi-jiang
Copy link
Collaborator

No description provided.

@qiyi-jiang qiyi-jiang requested a review from fny January 13, 2021 15:30
Copy link
Owner

@fny fny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some changes. I'll look at the front end shortly.


ensure_or_forbidden! { current_user.admin_at?(location) }

location_account.destroy
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use destroy! so that this doesn't silently fail

is_mobile_taken = User.mobile_taken?(request_json[:mobile_number])
is_email_taken = User.email_taken?(request_json[:email])

puts request_json[:mobile_number]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here!?

user = User.find(params[:user_id])

ensure_or_forbidden! { current_user.admin_at? location }
ensure_or_forbidden! { user.location_accounts.exists?(location_id: location.id) }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You shouldn't use a forbidden for this. This should be a not found error.
  2. You don't need this given the check above


patch '/v1/locations/:location_id/users/:user_id' do
location = Location.find_by_id_or_permalink!(params[:location_id])
user = User.find(params[:user_id])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

location.users.find(params[:user_id])

puts is_mobile_taken
puts is_email_taken

if is_mobile_taken || is_email_taken
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this check, create the user with the location account embedded. You should add a checkbox in the view to allow people to decide whether to send an invite.

user = User.new(...., location_accounts: LocationAccount.new(...))
if user.save
   ....
else
  error_response(user)
end


delete '/v1/locations/:location_id/users/:user_id' do
location = Location.find_by_id_or_permalink!(params[:location_id])
user = User.find(params[:user_id])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing as before location.users.find(...)

locationAccount?: LocationAccount | null
}

export default function AdminUserEditPage(props: F7Props) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add return types to exports: here it's JSX.Element

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants