import React, { useEffect, useState } from 'react' import { FormCheck, FormGroup } from 'react-bootstrap' import { setMediaType } from '@/app/actions' import { useAppDispatch, useAppSelector } from '@/app/hooks' import { MEDIA_TYPES } from '@/constants' import { checkFormValue, isFormDisabled } from '@/utils' import { TooltipFormLabel } from './TooltipFormLabel' type FormRadioProps = { label: string mediaType: string disabled: boolean onChange: (event: React.ChangeEvent) => void } const FormRadio: React.FC = (props) => { const { label, disabled, onChange, mediaType } = props return ( ) } export const MediaTypeForm: React.FC = () => { // NOTE(yuito): window.CropTarget の有無のみで radio の表示/非表示を切り替えると // サーバサイドとクライアントサイドのレンダリング結果の不一致で warning が発生するため // mount してから表示するハックを入れる const [mountClient, setMountClient] = useState(false) const enabledMediacaptureRegion = typeof window !== 'undefined' && window.CropTarget !== undefined const connectionStatus = useAppSelector((state) => state.soraContents.connectionStatus) const mediaType = useAppSelector((state) => state.mediaType) const disabled = isFormDisabled(connectionStatus) const dispatch = useAppDispatch() const onChange = (event: React.ChangeEvent): void => { if (checkFormValue(event.target.value, MEDIA_TYPES)) { dispatch(setMediaType(event.target.value)) } } useEffect(() => { setMountClient(true) }, []) return ( mediaType: {mountClient && ( )} ) }