From a76b20c1683182bd254095b736fe6b3a1f9489d6 Mon Sep 17 00:00:00 2001 From: riririn180904 <25.r.sugawara.nutfes@gmail.com> Date: Mon, 15 Dec 2025 10:20:16 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=E3=83=95=E3=82=A9=E3=83=BC=E3=83=A0?= =?UTF-8?q?=E5=88=9D=E6=9C=9F=E5=80=A4=E3=81=AE=E7=94=9F=E6=88=90=E3=82=92?= =?UTF-8?q?useMemo=E3=81=AB=E5=88=87=E3=82=8A=E5=87=BA=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Applications/Power/hooks/usePowerApplication.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/user/src/components/Applications/Power/hooks/usePowerApplication.ts b/user/src/components/Applications/Power/hooks/usePowerApplication.ts index c7ba8ac5e..0536f80b9 100644 --- a/user/src/components/Applications/Power/hooks/usePowerApplication.ts +++ b/user/src/components/Applications/Power/hooks/usePowerApplication.ts @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { useGetPowerOrders, useMutatePowerOrders } from '@/api/powerApi'; import { ORDER_TYPES, @@ -58,7 +58,14 @@ export const usePowerApplication = (groupId: number) => { const { submitPowerOrders, deletePowerOrder } = useMutatePowerOrders(); // フォーム管理 - const powerForm = usePowerForm(hasExisting ? { devices } : undefined); + const initialDefaultValues = useMemo(() => { + if (!hasExisting) return undefined; + + return { + devices: devices.map((d) => ({ ...d })), + }; + }, [hasExisting, devices]); + const powerForm = usePowerForm(initialDefaultValues); const { formMethods } = powerForm; // 状態更新のヘルパー関数 From c0ffe1f97a0fa66dbe72847498d6770f938a30de Mon Sep 17 00:00:00 2001 From: riririn180904 <25.r.sugawara.nutfes@gmail.com> Date: Mon, 15 Dec 2025 10:12:04 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[fix]=E3=83=95=E3=82=A9=E3=83=BC=E3=83=A0?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=82=92=E6=9D=A1=E4=BB=B6=E6=8F=8F=E7=94=BB?= =?UTF-8?q?=E3=81=8B=E3=82=89=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Applications/Power/components/PowerFormView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user/src/components/Applications/Power/components/PowerFormView.tsx b/user/src/components/Applications/Power/components/PowerFormView.tsx index ee60f2098..644b6033d 100644 --- a/user/src/components/Applications/Power/components/PowerFormView.tsx +++ b/user/src/components/Applications/Power/components/PowerFormView.tsx @@ -31,7 +31,7 @@ export const PowerFormView: FC = ({ /> {/* 申請する場合のフォーム */} - {showForm && ( +
{fields.map((field, index) => ( @@ -74,7 +74,7 @@ export const PowerFormView: FC = ({
- )} + ); };