Conversation
…nd WeaponRequestCard components
There was a problem hiding this comment.
Pull request overview
This PR refines the weapon-related UI by improving how weapon names/images are derived and by adjusting styling across several screens/components.
Changes:
- Update
WeaponCardto derive a display name fallback (“Unknown”) and to use a local fallback image when no weapon image URL is available. - Adjust styling in weapon cards (image container + status pill background) and simplify an icon background color in
WeaponRequestCard. - Replace the login “Forgot Password” press handler with a user-facing message and reduce language options in Translate.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/WeaponRequestCard.tsx | Tweaks icon container background styling. |
| src/components/WeaponCard.tsx | Adds image/name fallback logic and updates UI styling around the image and status badge. |
| app/login.tsx | Changes “Forgot Password” behavior to show a user message instead of logging. |
| app/Translate.tsx | Removes several language options from the selection list. |
| app/(screens)/Weapon.tsx | Enhances weapon name selection logic and passes weapon data through to WeaponCard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| weapon, | ||
| }: WeaponCardProps) => { | ||
| const { colors } = useTheme(); | ||
| const displayName = name?.trim() ? name : "Unknown"; |
There was a problem hiding this comment.
displayName checks name.trim() but returns the untrimmed name, so leading/trailing whitespace will still be rendered. Consider computing const trimmed = name.trim() and using trimmed || "Unknown" so the displayed value is actually normalized.
| const displayName = name?.trim() ? name : "Unknown"; | |
| const trimmedName = name?.trim(); | |
| const displayName = trimmedName || "Unknown"; |
| const imageUri = | ||
| weapon?.imageUrl?.trim() ?? | ||
| ( | ||
| weapon as (weaponType & { weapon?: { imageUrl?: string } }) | undefined | ||
| )?.weapon?.imageUrl?.trim(); |
There was a problem hiding this comment.
The imageUri extraction relies on a fairly unsafe type cast to a shape with a nested weapon.imageUrl. This undermines type-safety and makes it easy for future refactors to silently break image rendering. Prefer normalizing the assigned-weapon payload in the service (or broadening the prop/type definition to a proper union) so this component can read imageUrl without casting.
| name={ | ||
| weapon.weaponType ?? | ||
| (weapon as AssignedWeapon & { | ||
| weapon?: { weaponType?: string }; | ||
| }).weapon?.weaponType ?? | ||
| "Unknown" | ||
| } |
There was a problem hiding this comment.
The name prop is being derived via a type cast to reach weapon.weaponType, which indicates the runtime shape of getWeaponByOfficer() isn't accurately represented by AssignedWeapon. Instead of casting at the call site, consider updating the AssignedWeapon type (e.g., include an optional nested weapon object) or normalizing the API response in weaponService so consumers can access weaponType safely.
| onPress={() => | ||
| alert("Please contact your administrator to reset your password.") | ||
| } |
There was a problem hiding this comment.
This uses the global alert() function. Elsewhere in the app (e.g., Duty/Chat/Settings screens) user messaging is done via Alert.alert(...) from react-native, which is more consistent and allows specifying a title/buttons. Consider switching to Alert.alert("Forgot Password", "Please contact your administrator to reset your password.").
No description provided.