import { useMemo } from 'react'; import { Card, Empty, Input, Select, Skeleton, Typography } from 'antd'; import { Controller, useFormContext } from 'react-hook-form'; import { ControlledFormItem, useLineActionStore, useRouterStore } from '@l-clutch/core'; import { FormValues } from '.'; import { useSelectAction } from './useSelectAction'; export const ActionEditor = () => { const { getPath } = useRouterStore(); const id = getPath(1); const { control, watch } = useFormContext(); const selectedIndex = useSelectAction((select) => select.index); const areas = watch(`areas`); const selectedAction = areas?.[selectedIndex ?? -1]?.action; const types = useLineActionStore((state) => state.types); const LineActionField = useMemo(() => { if (!selectedAction || !selectedAction.type) return () => null; return types[selectedAction.type]?.Field; }, [selectedAction?.type, types]); return ( <> アクション設定 {selectedIndex !== undefined ? ( areas?.map((_area, index) => { if (index !== selectedIndex) return null; return ( ( <> formState.isLoading ? : } /> formState.isLoading ? ( ) : ( ) } /> field.onChange({ ...field.value, ...action })} errors={fieldState.error} richMenuId={id} /> )} /> ); }) ) : ( )} ); };