Skip to content

Commit 9092333

Browse files
committed
Handle missing user name in TicketNotesItem to prevent rendering errors
- Use optional chaining for `note.user?.name` in Avatar and text - Default alt text to empty string if user name is missing - Show "---" if user name is not available in secondary text - Prevents runtime errors when `note.user` is undefined - Improves UI robustness for incomplete note data - Changes only affect `frontend/src/components/TicketNotesItem/index.js`
1 parent 41718e8 commit 9092333

File tree

1 file changed

+2
-2
lines changed
  • frontend/src/components/TicketNotesItem

1 file changed

+2
-2
lines changed

frontend/src/components/TicketNotesItem/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function TicketNotesItem (props) {
2727
return (
2828
<ListItem alignItems="flex-start">
2929
<ListItemAvatar>
30-
<Avatar alt={note.user.name} src="/static/images/avatar/1.jpg" />
30+
<Avatar alt={note.user?.name || ""} src="/static/images/avatar/1.jpg" />
3131
</ListItemAvatar>
3232
<ListItemText
3333
primary={
@@ -44,7 +44,7 @@ export default function TicketNotesItem (props) {
4444
}
4545
secondary={
4646
<>
47-
{note.user.name}, {moment(note.createdAt).format('DD/MM/YY HH:mm')}
47+
{note.user?.name || "---"}, {moment(note.createdAt).format('DD/MM/YY HH:mm')}
4848
</>
4949
}
5050
/>

0 commit comments

Comments
 (0)