mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-19 05:46:27 +01:00
Fix TriggerAvatarEnterRoom
This commit is contained in:
parent
dc559cf0b4
commit
537987b85e
@ -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 { WiredFurniType } from '../../../WiredView.types';
|
||||||
import { WiredTriggerBaseView } from '../base/WiredTriggerBaseView';
|
import { WiredTriggerBaseView } from '../base/WiredTriggerBaseView';
|
||||||
|
|
||||||
export const WiredTriggerAvatarEnterRoomView: FC<{}> = props =>
|
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 (
|
return (
|
||||||
<WiredTriggerBaseView requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ null }></WiredTriggerBaseView>
|
<WiredTriggerBaseView requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
|
||||||
|
<div className="form-check">
|
||||||
|
<input className="form-check-input" type="radio" name="avatarMode" id="avatarMode0" checked={ avatarMode === 0 } onChange={() => setAvatarMode(0)} />
|
||||||
|
<label className="form-check-label" htmlFor="avatarMode0">
|
||||||
|
{ LocalizeText('wiredfurni.params.anyavatar') }
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div className="form-check">
|
||||||
|
<input className="form-check-input" type="radio" name="avatarMode" id="avatarMode1" checked={ avatarMode === 1 } onChange={() => setAvatarMode(1)} />
|
||||||
|
<label className="form-check-label" htmlFor="avatarMode1">
|
||||||
|
{ LocalizeText('wiredfurni.params.certainavatar') }
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{ avatarMode === 1 && <input type="text" className="form-control form-control-sm" value={ username } onChange={ event => setUsername(event.target.value) } /> }
|
||||||
|
</WiredTriggerBaseView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user