Skip to content

Enhance weapon display logic and improve styling in components - #49

Merged
iSiRaH merged 3 commits into
devfrom
isira
Mar 22, 2026
Merged

iSiRaH merged 3 commits into
devfrom
isira

Conversation

@iSiRaH

@iSiRaH iSiRaH commented Mar 22, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings March 22, 2026 15:36
@iSiRaH
iSiRaH merged commit 6ab3c74 into dev Mar 22, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 WeaponCard to 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";

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
const displayName = name?.trim() ? name : "Unknown";
const trimmedName = name?.trim();
const displayName = trimmedName || "Unknown";

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +31
const imageUri =
weapon?.imageUrl?.trim() ??
(
weapon as (weaponType & { weapon?: { imageUrl?: string } }) | undefined
)?.weapon?.imageUrl?.trim();

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread app/(screens)/Weapon.tsx
Comment on lines +183 to +189
name={
weapon.weaponType ??
(weapon as AssignedWeapon & {
weapon?: { weaponType?: string };
}).weapon?.weaponType ??
"Unknown"
}

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread app/login.tsx
Comment on lines +245 to +247
onPress={() =>
alert("Please contact your administrator to reset your password.")
}

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

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

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.").

Copilot uses AI. Check for mistakes.
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.

2 participants