diff --git a/src/views/wired/views/triggers/avatar-enter-room/WiredTriggerAvatarEnterRoomView.tsx b/src/views/wired/views/triggers/avatar-enter-room/WiredTriggerAvatarEnterRoomView.tsx index 45a6fbea..90c7e030 100644 --- a/src/views/wired/views/triggers/avatar-enter-room/WiredTriggerAvatarEnterRoomView.tsx +++ b/src/views/wired/views/triggers/avatar-enter-room/WiredTriggerAvatarEnterRoomView.tsx @@ -1,10 +1,44 @@ -import { FC } from 'react'; +import { FC, useCallback, useEffect, useState } from 'react'; +import { LocalizeText } from '../../../../../utils/LocalizeText'; +import { useWiredContext } from '../../../context/WiredContext'; import { WiredFurniType } from '../../../WiredView.types'; import { WiredTriggerBaseView } from '../base/WiredTriggerBaseView'; export const WiredTriggerAvatarEnterRoomView: FC<{}> = props => { + const [ username, setUsername ] = useState(''); + const [ avatarMode, setAvatarMode ] = useState(0); + const { trigger = null, setStringParam = null } = useWiredContext(); + + useEffect(() => + { + setUsername(trigger.stringData); + setAvatarMode(trigger.stringData ? 1 : 0) + }, [ trigger ]); + + const save = useCallback(() => + { + if(avatarMode === 1) + setStringParam(username); + else + setStringParam(''); + }, [ username, avatarMode, setStringParam ]); + return ( - + +
+ setAvatarMode(0)} /> + +
+
+ setAvatarMode(1)} /> + +
+ { avatarMode === 1 && setUsername(event.target.value) } /> } +
); }