From acb19dc40e3fe0956d5fe9dbb338e5cc4edffe7b Mon Sep 17 00:00:00 2001 From: ryufuta Date: Thu, 27 Nov 2025 17:54:45 +0900 Subject: [PATCH 01/13] =?UTF-8?q?=E9=96=A2=E6=95=B0=E3=81=AE=E8=A8=98?= =?UTF-8?q?=E6=B3=95=E3=82=92=E3=82=A2=E3=83=AD=E3=83=BC=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E5=BC=8F=E3=81=AB=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/action_completed_button.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index f57e72bf2d1..f4e3faf1d85 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -1,13 +1,13 @@ import CSRF from 'csrf' import { toast } from './vanillaToast' -document.addEventListener('DOMContentLoaded', function () { +document.addEventListener('DOMContentLoaded', () => { const button = document.querySelector('.check-button') if (!button) { return } const commentableId = button.dataset.commentableId - button.addEventListener('click', function () { + button.addEventListener('click', () => { const isInitialActionCompleted = button.classList.contains('is-muted-borderd') const isActionCompleted = !isInitialActionCompleted From 5238b34a24d1fb5d16b2772e699ed113b9a8679c Mon Sep 17 00:00:00 2001 From: ryufuta Date: Thu, 27 Nov 2025 19:34:17 +0900 Subject: [PATCH 02/13] =?UTF-8?q?`then`=E3=82=92`async/await`=E3=81=AB?= =?UTF-8?q?=E7=BD=AE=E6=8F=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/action_completed_button.js | 40 +++++++++++------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index f4e3faf1d85..2b849517a77 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -7,28 +7,24 @@ document.addEventListener('DOMContentLoaded', () => { return } const commentableId = button.dataset.commentableId - button.addEventListener('click', () => { + button.addEventListener('click', async () => { const isInitialActionCompleted = button.classList.contains('is-muted-borderd') const isActionCompleted = !isInitialActionCompleted - fetch(`/api/talks/${commentableId}`, { - method: 'PATCH', - headers: { - 'Content-Type': 'application/json; charset=utf-8', - 'X-Requested-With': 'XMLHttpRequest', - 'X-CSRF-Token': CSRF.getToken() - }, - body: JSON.stringify({ - talk: { action_completed: isActionCompleted } + try { + const response = await fetch(`/api/talks/${commentableId}`, { + method: 'PATCH', + headers: { + 'Content-Type': 'application/json; charset=utf-8', + 'X-Requested-With': 'XMLHttpRequest', + 'X-CSRF-Token': CSRF.getToken() + }, + body: JSON.stringify({ + talk: { action_completed: isActionCompleted } + }) }) - }) - .then((response) => { - if (!response.ok) { - throw new Error('Network response was not ok') - } - }) - .then(() => { + if (response.ok) { const newButtonText = isActionCompleted ? '対応済です' : '対応済にする' const iconClass = isActionCompleted ? 'fa-check' : 'fa-redo' const newMessage = isActionCompleted @@ -49,9 +45,11 @@ document.addEventListener('DOMContentLoaded', () => { ? '対応済みにしました' : '未対応にしました' toast(tostMessage, 'success') - }) - .catch((error) => { - console.warn(error) - }) + } else { + throw new Error('Network response was not ok') + } + } catch (error) { + console.warn(error) + } }) }) From 62cda935a5a42fc300d2c50a821899fb94171a8e Mon Sep 17 00:00:00 2001 From: ryufuta Date: Thu, 27 Nov 2025 19:56:16 +0900 Subject: [PATCH 03/13] =?UTF-8?q?`fetch`=E3=82=92`rails/request.js`?= =?UTF-8?q?=E3=81=AB=E7=BD=AE=E6=8F=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/action_completed_button.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index 2b849517a77..f5f0ac9c87d 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -1,4 +1,4 @@ -import CSRF from 'csrf' +import { patch } from '@rails/request.js' import { toast } from './vanillaToast' document.addEventListener('DOMContentLoaded', () => { @@ -13,13 +13,7 @@ document.addEventListener('DOMContentLoaded', () => { const isActionCompleted = !isInitialActionCompleted try { - const response = await fetch(`/api/talks/${commentableId}`, { - method: 'PATCH', - headers: { - 'Content-Type': 'application/json; charset=utf-8', - 'X-Requested-With': 'XMLHttpRequest', - 'X-CSRF-Token': CSRF.getToken() - }, + const response = await patch(`/api/talks/${commentableId}`, { body: JSON.stringify({ talk: { action_completed: isActionCompleted } }) From 8dda9f7b1fa12f636246d5de7bff245f5bae08f8 Mon Sep 17 00:00:00 2001 From: ryufuta Date: Fri, 28 Nov 2025 17:01:04 +0900 Subject: [PATCH 04/13] =?UTF-8?q?=E7=9B=B8=E8=AB=87=E9=83=A8=E5=B1=8B?= =?UTF-8?q?=E3=81=AE=E5=AF=BE=E5=BF=9C=E6=B8=88=E3=83=95=E3=83=A9=E3=82=B0?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E6=99=82=E3=81=AB=E6=98=8E=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E3=81=AB=E3=83=AC=E3=82=B9=E3=83=9D=E3=83=B3=E3=82=B9=E3=82=92?= =?UTF-8?q?=E8=BF=94=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/talks_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/talks_controller.rb b/app/controllers/api/talks_controller.rb index a57968bb9e4..8ac4cf327e9 100644 --- a/app/controllers/api/talks_controller.rb +++ b/app/controllers/api/talks_controller.rb @@ -7,7 +7,8 @@ def index; end def update talk = Talk.find(params[:id]) - talk.update(talk_params) + talk.update!(talk_params) + head :no_content end private From 14acb5af8b30736875cafe47fa095add5bde36f9 Mon Sep 17 00:00:00 2001 From: ryufuta Date: Fri, 28 Nov 2025 17:20:24 +0900 Subject: [PATCH 05/13] =?UTF-8?q?=E7=9B=B8=E8=AB=87=E9=83=A8=E5=B1=8B?= =?UTF-8?q?=E3=81=AE=E5=AF=BE=E5=BF=9C=E6=B8=88=E3=83=95=E3=83=A9=E3=82=B0?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E5=A4=B1=E6=95=97=E6=99=82=E3=81=AB=E3=82=88?= =?UTF-8?q?=E3=82=8A=E9=81=A9=E5=88=87=E3=81=AA=E6=83=85=E5=A0=B1=E3=82=92?= =?UTF-8?q?=E6=AE=8B=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CodeRabbitの指摘を受けて修正:https://github.com/fjordllc/bootcamp/pull/9331#discussion_r2579979304 --- app/javascript/action_completed_button.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index f5f0ac9c87d..7ce2fde2614 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -40,7 +40,12 @@ document.addEventListener('DOMContentLoaded', () => { : '未対応にしました' toast(tostMessage, 'success') } else { - throw new Error('Network response was not ok') + toast('更新に失敗しました', 'error') + const errorText = await response.text + console.warn('update action_completed failed', { + status: response.statusCode, + body: errorText + }) } } catch (error) { console.warn(error) From 26d5ec3a83f88899fa9aeab07fdd2a156183c1be Mon Sep 17 00:00:00 2001 From: ryufuta Date: Fri, 28 Nov 2025 17:27:12 +0900 Subject: [PATCH 06/13] =?UTF-8?q?=E5=86=97=E9=95=B7=E3=81=AA=E8=AA=AC?= =?UTF-8?q?=E6=98=8E=E5=A4=89=E6=95=B0=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit typoもあった --- app/javascript/action_completed_button.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index 7ce2fde2614..f8f906ef02b 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -35,10 +35,10 @@ document.addEventListener('DOMContentLoaded', () => { description.innerHTML = newMessage } - const tostMessage = isActionCompleted - ? '対応済みにしました' - : '未対応にしました' - toast(tostMessage, 'success') + toast( + isActionCompleted ? '対応済みにしました' : '未対応にしました', + 'success' + ) } else { toast('更新に失敗しました', 'error') const errorText = await response.text From 5097185f9e1a9f933747bcf94ffd17f0fd57cb6a Mon Sep 17 00:00:00 2001 From: ryufuta Date: Fri, 28 Nov 2025 22:30:14 +0900 Subject: [PATCH 07/13] =?UTF-8?q?=E4=BA=8C=E9=87=8D=E3=82=AF=E3=83=AA?= =?UTF-8?q?=E3=83=83=E3=82=AF=E9=98=B2=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/action_completed_button.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index f8f906ef02b..c887b861161 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -6,8 +6,14 @@ document.addEventListener('DOMContentLoaded', () => { if (!button) { return } + + let isLoading = false const commentableId = button.dataset.commentableId button.addEventListener('click', async () => { + if (isLoading) return + + isLoading = true + button.disabled = true const isInitialActionCompleted = button.classList.contains('is-muted-borderd') const isActionCompleted = !isInitialActionCompleted @@ -50,5 +56,8 @@ document.addEventListener('DOMContentLoaded', () => { } catch (error) { console.warn(error) } + + isLoading = false + button.disabled = false }) }) From 4b84b1d8d2f360e41d8a0808dd31674d211aa8f6 Mon Sep 17 00:00:00 2001 From: ryufuta Date: Sun, 30 Nov 2025 18:56:07 +0900 Subject: [PATCH 08/13] =?UTF-8?q?ActionCompletedButtonComponent=E3=81=AE?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92private=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `app/components/action_completed_button_component.html.slim`からはprivateでも参照可能 --- app/components/action_completed_button_component.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/components/action_completed_button_component.rb b/app/components/action_completed_button_component.rb index 45a4c9420f3..d5ad0dfe909 100644 --- a/app/components/action_completed_button_component.rb +++ b/app/components/action_completed_button_component.rb @@ -1,10 +1,12 @@ # frozen_string_literal: true class ActionCompletedButtonComponent < ViewComponent::Base - attr_reader :is_action_completed, :commentable_id - def initialize(is_initial_action_completed:, commentable_id:) @is_action_completed = is_initial_action_completed @commentable_id = commentable_id end + + private + + attr_reader :is_action_completed, :commentable_id end From cfea4fa8e56b485d9535a86d98561ff53a51f9b3 Mon Sep 17 00:00:00 2001 From: ryufuta Date: Sun, 30 Nov 2025 21:11:53 +0900 Subject: [PATCH 09/13] =?UTF-8?q?ActionCompletedButtonComponent=E3=82=92?= =?UTF-8?q?=E5=86=8D=E5=88=A9=E7=94=A8=E5=8F=AF=E8=83=BD=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/action_completed_button_component.html.slim | 6 ++++-- app/components/action_completed_button_component.rb | 7 ++++--- app/javascript/action_completed_button.js | 7 ++++--- app/views/talks/show.html.slim | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/components/action_completed_button_component.html.slim b/app/components/action_completed_button_component.html.slim index fd26c79822c..723786ba563 100644 --- a/app/components/action_completed_button_component.html.slim +++ b/app/components/action_completed_button_component.html.slim @@ -4,7 +4,8 @@ .action-completed .action-completed__action button.a-button.is-sm.is-block.check-button.is-muted-borderd( - data-commentable-id='#{commentable_id}' + data-update-path='#{update_path}' + data-model-name='#{model_name}' ) i.fas.fa-check | 対応済です @@ -18,7 +19,8 @@ .action-complete .action-completed__action button.a-button.is-sm.is-block.check-button.is-warning( - data-commentable-id='#{commentable_id}' + data-update-path='#{update_path}' + data-model-name='#{model_name}' ) i.fas.fa-redo | 対応済にする diff --git a/app/components/action_completed_button_component.rb b/app/components/action_completed_button_component.rb index d5ad0dfe909..7cbec9ff876 100644 --- a/app/components/action_completed_button_component.rb +++ b/app/components/action_completed_button_component.rb @@ -1,12 +1,13 @@ # frozen_string_literal: true class ActionCompletedButtonComponent < ViewComponent::Base - def initialize(is_initial_action_completed:, commentable_id:) + def initialize(is_initial_action_completed:, update_path:, model_name:) @is_action_completed = is_initial_action_completed - @commentable_id = commentable_id + @update_path = update_path + @model_name = model_name end private - attr_reader :is_action_completed, :commentable_id + attr_reader :is_action_completed, :update_path, :model_name end diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index c887b861161..d7b27d2841b 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -8,7 +8,8 @@ document.addEventListener('DOMContentLoaded', () => { } let isLoading = false - const commentableId = button.dataset.commentableId + const updatePath = button.dataset.updatePath + const modelName = button.dataset.modelName button.addEventListener('click', async () => { if (isLoading) return @@ -19,9 +20,9 @@ document.addEventListener('DOMContentLoaded', () => { const isActionCompleted = !isInitialActionCompleted try { - const response = await patch(`/api/talks/${commentableId}`, { + const response = await patch(updatePath, { body: JSON.stringify({ - talk: { action_completed: isActionCompleted } + [modelName]: { action_completed: isActionCompleted } }) }) if (response.ok) { diff --git a/app/views/talks/show.html.slim b/app/views/talks/show.html.slim index 92a4deeeee6..7ff23af6923 100644 --- a/app/views/talks/show.html.slim +++ b/app/views/talks/show.html.slim @@ -62,7 +62,7 @@ = member.login_name = render 'comments/comments', commentable: @talk, commentable_type: 'Talk' - if current_user.admin? - = render(ActionCompletedButtonComponent.new(is_initial_action_completed: @talk.action_completed, commentable_id: @talk.id)) + = render(ActionCompletedButtonComponent.new(is_initial_action_completed: @talk.action_completed, update_path: api_talk_path(@talk), model_name: 'talk')) - if current_user.admin? .col-xl-5.col-xs-12 From 1186164eac07239e9070c220334dd3c88a90e343 Mon Sep 17 00:00:00 2001 From: ryufuta Date: Tue, 2 Dec 2025 12:41:27 +0900 Subject: [PATCH 10/13] =?UTF-8?q?ActionCompletedButtonComponent=E3=81=AE?= =?UTF-8?q?=E5=8D=98=E4=BD=93=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action_completed_button_component_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/components/action_completed_button_component_test.rb diff --git a/test/components/action_completed_button_component_test.rb b/test/components/action_completed_button_component_test.rb new file mode 100644 index 00000000000..3acc00dcd4b --- /dev/null +++ b/test/components/action_completed_button_component_test.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'test_helper' + +class ActionCompletedButtonComponentTest < ViewComponent::TestCase + test 'action is completed' do + # update_pathとmodel_nameは使用されないため値は任意 + render_inline(ActionCompletedButtonComponent.new(is_initial_action_completed: true, update_path: '/api/talks/1', model_name: 'talk')) + + assert_text '対応済です' + end + + test 'action is not completed' do + render_inline(ActionCompletedButtonComponent.new(is_initial_action_completed: false, update_path: '/api/talks/1', model_name: 'talk')) + + assert_text '対応済にする' + end +end From 51c92691c2a074dbbd15e043378f091ffb84a0ef Mon Sep 17 00:00:00 2001 From: ryufuta Date: Fri, 26 Dec 2025 17:52:22 +0900 Subject: [PATCH 11/13] =?UTF-8?q?=E6=97=A9=E6=9C=9F=E3=83=AA=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E3=83=B3=E3=81=AE=E6=9B=B8=E5=BC=8F=E3=82=92=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E5=86=85=E3=81=A7=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/action_completed_button.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index d7b27d2841b..f1dcda12d2a 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -3,9 +3,7 @@ import { toast } from './vanillaToast' document.addEventListener('DOMContentLoaded', () => { const button = document.querySelector('.check-button') - if (!button) { - return - } + if (!button) return let isLoading = false const updatePath = button.dataset.updatePath From 26a8edc74513395ca755674c742ad3a248b89143 Mon Sep 17 00:00:00 2001 From: ryufuta Date: Tue, 17 Feb 2026 21:34:36 +0900 Subject: [PATCH 12/13] =?UTF-8?q?=E4=BA=8C=E9=87=8D=E3=82=AF=E3=83=AA?= =?UTF-8?q?=E3=83=83=E3=82=AF=E9=98=B2=E6=AD=A2=E3=81=AE=E4=B8=8D=E8=A6=81?= =?UTF-8?q?=E3=81=AA=E5=87=A6=E7=90=86=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/fjordllc/bootcamp/pull/9331#discussion_r2807499452 の指摘への対応 --- app/javascript/action_completed_button.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index f1dcda12d2a..40cc2581da1 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -5,13 +5,9 @@ document.addEventListener('DOMContentLoaded', () => { const button = document.querySelector('.check-button') if (!button) return - let isLoading = false const updatePath = button.dataset.updatePath const modelName = button.dataset.modelName button.addEventListener('click', async () => { - if (isLoading) return - - isLoading = true button.disabled = true const isInitialActionCompleted = button.classList.contains('is-muted-borderd') @@ -56,7 +52,6 @@ document.addEventListener('DOMContentLoaded', () => { console.warn(error) } - isLoading = false button.disabled = false }) }) From 7f39c06bb62ec41f212d724bff0e9f600529833e Mon Sep 17 00:00:00 2001 From: ryufuta Date: Wed, 18 Feb 2026 11:21:19 +0900 Subject: [PATCH 13/13] =?UTF-8?q?=E5=8F=AF=E8=AA=AD=E6=80=A7=E5=90=91?= =?UTF-8?q?=E4=B8=8A=E3=81=AE=E3=81=9F=E3=82=81isActionCompleted=E3=81=AB?= =?UTF-8?q?=E3=82=88=E3=82=8B=E6=9D=A1=E4=BB=B6=E5=88=86=E5=B2=90=E3=82=92?= =?UTF-8?q?1=E7=AE=87=E6=89=80=E3=81=AB=E3=81=BE=E3=81=A8=E3=82=81?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/fjordllc/bootcamp/pull/9331#discussion_r2807535127 の指摘への対応 --- app/javascript/action_completed_button.js | 26 +++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/app/javascript/action_completed_button.js b/app/javascript/action_completed_button.js index 40cc2581da1..eff49e66b3e 100644 --- a/app/javascript/action_completed_button.js +++ b/app/javascript/action_completed_button.js @@ -20,11 +20,22 @@ document.addEventListener('DOMContentLoaded', () => { }) }) if (response.ok) { - const newButtonText = isActionCompleted ? '対応済です' : '対応済にする' - const iconClass = isActionCompleted ? 'fa-check' : 'fa-redo' - const newMessage = isActionCompleted - ? 'お疲れ様でした!相談者から次のアクションがあった際は、自動で未対応のステータスに変更されます。再度このボタンをクリックすると、未対応にステータスに戻ります。' - : '返信が完了し次は相談者からのアクションの待ちの状態になったとき、もしくは、相談者とのやりとりが一通り完了した際は、このボタンをクリックして対応済のステータスに変更してください。' + const forCompleted = { + newButtonText: '対応済です', + iconClass: 'fa-check', + newMessage: + 'お疲れ様でした!相談者から次のアクションがあった際は、自動で未対応のステータスに変更されます。再度このボタンをクリックすると、未対応にステータスに戻ります。', + toastMessage: '対応済みにしました' + } + const forNotCompleted = { + newButtonText: '対応済にする', + iconClass: 'fa-redo', + newMessage: + '返信が完了し次は相談者からのアクションの待ちの状態になったとき、もしくは、相談者とのやりとりが一通り完了した際は、このボタンをクリックして対応済のステータスに変更してください。', + toastMessage: '未対応にしました' + } + const { newButtonText, iconClass, newMessage, toastMessage } = + isActionCompleted ? forCompleted : forNotCompleted button.innerHTML = ` ${newButtonText}` button.classList.toggle('is-warning', !isActionCompleted) button.classList.toggle('is-muted-borderd', isActionCompleted) @@ -36,10 +47,7 @@ document.addEventListener('DOMContentLoaded', () => { description.innerHTML = newMessage } - toast( - isActionCompleted ? '対応済みにしました' : '未対応にしました', - 'success' - ) + toast(toastMessage, 'success') } else { toast('更新に失敗しました', 'error') const errorText = await response.text