Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const PowerFormView: FC<PowerFormViewProps> = ({
/>

{/* 申請する場合のフォーム */}
{showForm && (
<div style={{ display: showForm ? 'block' : 'none' }}>
<form onSubmit={handleSubmit(onSubmit)}>
<div className="flex w-full flex-col gap-10">
{fields.map((field, index) => (
Expand Down Expand Up @@ -74,7 +74,7 @@ export const PowerFormView: FC<PowerFormViewProps> = ({
</div>
</div>
</form>
)}
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { useGetPowerOrders, useMutatePowerOrders } from '@/api/powerApi';
import {
ORDER_TYPES,
Expand Down Expand Up @@ -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;

// 状態更新のヘルパー関数
Expand Down