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

お問い合わせ一覧・個別ページを作成 #7387

Merged
merged 15 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions app/controllers/admin/inquiries_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class Admin::InquiriesController < AdminController
def index
@inquiries = Inquiry.order(created_at: :desc)
Copy link
Member

Choose a reason for hiding this comment

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

orderをちゃんとしていしていて、created_atにしてるのがよいとおもいます~!

end

def show
@inquiry = Inquiry.find(params[:id])
end
end
7 changes: 7 additions & 0 deletions app/decorators/inquiry_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module InquiryDecorator
def sender_name_and_email
Copy link
Member

Choose a reason for hiding this comment

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

👍

"#{name} 様 (#{email})"
end
end
4 changes: 4 additions & 0 deletions app/views/admin/_admin_page_tabs.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
= link_to 'お試し延長',
admin_campaigns_path,
class: "page-tabs__item-link #{current_link(/^admin-campaigns/)}"
li.page-tabs__item
= link_to 'お問い合わせ',
admin_inquiries_path,
class: "page-tabs__item-link #{current_link(/^admin-inquiries/)}"
18 changes: 18 additions & 0 deletions app/views/admin/inquiries/_inquiries_item.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.card-list-item
.card-list-item__inner
.card-list-item__rows
.card-list-item__row
.card-list-item-title
h2.card-list-item-title__title
= link_to admin_inquiry_path(inquiry), class: 'card-list-item-title__link a-text-link' do
= inquiry.sender_name_and_email
.card-list-item__row
.card-list-item-meta
.card-list-item-meta__items
.card-list-item-meta__item
.a-meta
span.a-meta__label 受信日
span.a-meta__value = l inquiry.created_at
.card-list-item__row
.a-meta
p = inquiry.body.truncate(100)
20 changes: 20 additions & 0 deletions app/views/admin/inquiries/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- title '管理ページ'

header.page-header
.container
.page-header__inner
h1.page-header__title = title

= render 'admin/admin_page_tabs'

header.page-main-header
.container
.page-main-header__inner
h1.page-main-header__title お問い合わせ一覧
hr.a-border
.page-body
.page-body__inner
.container.is-md
.card-list.a-card
.card-list__items
= render partial: 'inquiries_item', collection: @inquiries, as: :inquiry
33 changes: 33 additions & 0 deletions app/views/admin/inquiries/show.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
- title 'お問い合わせ'

header.page-header
.container
.page-header__inner
h1.page-header__title お問い合わせ
.page-header-actions
ul.page-header-actions__items
li.page-header-actions__item
= link_to admin_inquiries_path, class: 'a-button is-md is-secondary is-block is-back' do
| お問い合わせ一覧へ
hr.a-border
.page-body
.container.is-md
.page-content
header.page-content-header
.page-content-header__end
.page-content-header__row
h1.page-content-header__title
= @inquiry.sender_name_and_email
.page-content-header__row
.page-content-header-metas
.page-content-header-metas__start
.page-content-header-metas__meta
.a-meta
span.a-meta__label 受信日
span.a-meta__value = l @inquiry.created_at
.page-content__body
.a-card
.card-body
.card__description
.a-long-text.is-md
= auto_link(simple_format(@inquiry.body), html: { target: '_blank' })
1 change: 1 addition & 0 deletions config/routes/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
resource :password, only: %i(edit update), controller: "users/password"
end
resources :campaigns, only: %i(new create index edit update)
resources :inquiries, only: %i(index show)
end
end
11 changes: 11 additions & 0 deletions db/fixtures/inquiries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
inquiry1:
name: 'inquiry1'
email: '[email protected]'
created_at: '2017-01-01 00:00:00'
body: 'お問い合わせのテスト1です。'

inquiry2:
name: 'inquiry2'
email: '[email protected]'
created_at: '2017-01-01 00:00:00'
body: 'お問い合わせのテスト2です。'
1 change: 1 addition & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
surveys
survey_question_listings
buzzes
inquiries
]

ActiveRecord::FixtureSet.create_fixtures 'db/fixtures', tables
Expand Down
14 changes: 14 additions & 0 deletions test/decorators/inquiry_decorator_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

require 'test_helper'
require 'active_decorator_test_case'

class InquiryDecoratorTest < ActiveDecoratorTestCase
setup do
@inquiry = decorate(inquiries(:inquiry1))
Copy link
Member

Choose a reason for hiding this comment

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

👍

end

test '#sender_name_and_email' do
assert_equal 'inquiry1 様 ([email protected])', @inquiry.sender_name_and_email
end
end
11 changes: 11 additions & 0 deletions test/fixtures/inquiries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
inquiry1:
name: 'inquiry1'
email: '[email protected]'
created_at: '2017-01-01 00:00:00'
body: 'お問い合わせのテスト1です。'

inquiry2:
name: 'inquiry2'
email: '[email protected]'
created_at: '2017-01-01 00:00:00'
body: 'お問い合わせのテスト2です。'
3 changes: 2 additions & 1 deletion test/system/admin/home_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ class Admin::HomeTest < ApplicationSystemTestCase
visit_with_auth '/admin', 'komagata'
assert_equal '管理ページ | FBC', title

assert_selector 'a.page-tabs__item-link', count: 4
assert_selector 'a.page-tabs__item-link', count: 5
assert_selector '.page-tabs__item-link', text: '管理ページ'
assert_selector '.page-tabs__item-link', text: 'ユーザー'
assert_selector '.page-tabs__item-link', text: '企業'
assert_selector '.page-tabs__item-link', text: 'お試し延長'
assert_selector '.page-tabs__item-link', text: 'お問い合わせ'
assert_no_selector '.page-tabs__item-link', text: 'プラクティス'
assert_no_selector '.page-tabs__item-link', text: 'カテゴリー'
assert_no_selector '.page-tabs__item-link', text: 'コース'
Expand Down
21 changes: 21 additions & 0 deletions test/system/admin/inquiries_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'application_system_test_case'

class Admin::InquiriesTest < ApplicationSystemTestCase
test 'show listing inquiries' do
visit_with_auth '/admin/inquiries', 'komagata'
assert_equal '管理ページ | FBC', title
assert_selector 'h1.page-main-header__title', text: 'お問い合わせ一覧'
assert_text inquiries(:inquiry1).name
assert_text inquiries(:inquiry2).name
end

test 'show inquiry details' do
visit_with_auth "/admin/inquiries/#{inquiries(:inquiry1).id}", 'komagata'
assert_text inquiries(:inquiry1).name
assert_text inquiries(:inquiry1).email
assert_text I18n.l inquiries(:inquiry1).created_at.to_date
assert_text inquiries(:inquiry1).body
end
end