Skip to content

Commit

Permalink
/reportsでユーザーロール情報が取得できるように変更
Browse files Browse the repository at this point in the history
  • Loading branch information
hirano-vm4 committed Apr 24, 2024
1 parent fae64eb commit 0c657ed
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/javascript/components/CommentUserIcon.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'

export default function CommentUserIcon({ comment, report }) {
const roleClass = `is-${report.user.primary_role}`
export default function CommentUserIcon({ comment }) {
const roleClass = `is-${comment.primary_role}`
return (
<a
className="card-list-item__user-icons-icon"
Expand Down
6 changes: 1 addition & 5 deletions app/javascript/components/ListComment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ export default function ListComment({ report }) {
<div className="card-list-item__user-icons">
{report.comments.map((comment) => {
return (
<CommentUserIcon
comment={comment}
key={comment.user_id}
report={report}
/>
<CommentUserIcon comment={comment} key={comment.user_id} />
)
})}
</div>
Expand Down
13 changes: 7 additions & 6 deletions app/views/api/comments/_user_icons.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
json.hasAnyComments comments.present?
if comments.present?
json.numberOfComments comments.size
json.lastCommentDatetime comments.last.updated_at.to_datetime
json.lastCommentDate l comments.last.updated_at, format: :date_and_time
json.hasAnyComments report.comments.present?
if report.comments.present?
json.numberOfComments report.comments.size
json.lastCommentDatetime report.comments.last.updated_at.to_datetime
json.lastCommentDate l report.comments.last.updated_at, format: :date_and_time
json.comments do
json.array! comments.commented_users do |user|
json.array! report.commented_users.uniq do |user|
json.user_icon user.avatar_url
json.user_id user.id
json.primary_role user.primary_role
end
end
end
2 changes: 1 addition & 1 deletion app/views/api/reports/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
json.reports @reports do |report|
json.partial! "api/reports/report", report: report
json.partial! "api/reports/checks", checks: report.checks
json.partial! "api/comments/user_icons", comments: report.comments
json.partial! "api/comments/user_icons", report: report
json.user do
json.partial! "api/users/user", user: report.user
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/reports/sad_streak/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
json.reports @reports do |report|
json.partial! "api/reports/report", report: report
json.partial! "api/reports/checks", checks: report.checks
json.partial! "api/comments/user_icons", comments: report.comments
json.partial! "api/comments/user_icons", report: report
json.user do
json.partial! "api/users/user", user: report.user
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/reports/unchecked/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
json.reports @reports do |report|
json.partial! "api/reports/report", report: report
json.partial! "api/comments/user_icons", comments: report.comments
json.partial! "api/comments/user_icons", report: report
json.user do
json.partial! "api/users/user", user: report.user
end
Expand Down

0 comments on commit 0c657ed

Please sign in to comment.