Skip to content
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

displaying "-" when user type not defined #10190

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Users/UserListAndCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const UserCard = ({ user }: { user: UserBase }) => {
<div>
<div className="text-gray-500">{t("role")}</div>
<div className="font-medium truncate">
{user.user_type ?? "-"}
{user.user_type ? user.user_type : "-"}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Remove unnecessary falsy value check for user_type

The type system guarantees that user_type is always defined as it's a required field in the UserBase type. The current defensive check is unnecessary and can be simplified to just {user.user_type}.

  • src/components/Users/UserListAndCard.tsx:113: Replace {user.user_type ? user.user_type : "-"} with {user.user_type}
🔗 Analysis chain

Verify the necessity of falsy value handling for user_type.

According to previous learnings from PR #9080, user.user_type should always be defined. However, this change suggests otherwise by handling falsy values. Could you clarify if there's been a change in the data contract?

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances where user_type might be undefined
rg -A 2 "user_type\s*[?:]" --type ts

Length of output: 1773


Script:

#!/bin/bash
# Search for API response handling or data transformation related to user_type
rg -A 3 "interface.*User|type.*User" --type ts
ast-grep --pattern 'interface User {
  $$$
}'

Length of output: 7348

🧰 Tools
🪛 eslint

[error] 113-113: Insert ··

(prettier/prettier)

</div>
</div>
<div>
Expand Down