mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-02-18 09:52:37 +01:00
Fix wired furni selection
This commit is contained in:
parent
7c68755014
commit
b084ba6210
@ -1,11 +1,21 @@
|
|||||||
import { FC } from 'react';
|
import { FC, useEffect } from 'react';
|
||||||
import { LocalizeText } from '../../../api';
|
import { LocalizeText } from '../../../api';
|
||||||
import { Column, Text } from '../../../common';
|
import { Column, Text } from '../../../common';
|
||||||
import { useWired } from '../../../hooks';
|
import { useWired } from '../../../hooks';
|
||||||
|
|
||||||
export const WiredFurniSelectorView: FC<{}> = props =>
|
export const WiredFurniSelectorView: FC<{}> = props =>
|
||||||
{
|
{
|
||||||
const { trigger = null, furniIds = [] } = useWired();
|
const { trigger = null, furniIds = [], setAllowsFurni = null } = useWired();
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
setAllowsFurni(true);
|
||||||
|
|
||||||
|
return () =>
|
||||||
|
{
|
||||||
|
setAllowsFurni(false);
|
||||||
|
}
|
||||||
|
}, [ setAllowsFurni ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column gap={ 1 }>
|
<Column gap={ 1 }>
|
||||||
|
@ -12,6 +12,7 @@ const useWiredState = () =>
|
|||||||
const [ stringParam, setStringParam ] = useState<string>('');
|
const [ stringParam, setStringParam ] = useState<string>('');
|
||||||
const [ furniIds, setFurniIds ] = useState<number[]>([]);
|
const [ furniIds, setFurniIds ] = useState<number[]>([]);
|
||||||
const [ actionDelay, setActionDelay ] = useState<number>(0);
|
const [ actionDelay, setActionDelay ] = useState<number>(0);
|
||||||
|
const [ allowsFurni, setAllowsFurni ] = useState(false);
|
||||||
const { showConfirm = null } = useNotification();
|
const { showConfirm = null } = useNotification();
|
||||||
|
|
||||||
const saveWired = () =>
|
const saveWired = () =>
|
||||||
@ -51,7 +52,7 @@ const useWiredState = () =>
|
|||||||
|
|
||||||
const selectObjectForWired = (objectId: number, category: number) =>
|
const selectObjectForWired = (objectId: number, category: number) =>
|
||||||
{
|
{
|
||||||
if(!trigger) return;
|
if(!trigger || !allowsFurni) return;
|
||||||
|
|
||||||
if(objectId <= 0) return;
|
if(objectId <= 0) return;
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ const useWiredState = () =>
|
|||||||
}
|
}
|
||||||
}, [ trigger ]);
|
}, [ trigger ]);
|
||||||
|
|
||||||
return { trigger, setTrigger, intParams, setIntParams, stringParam, setStringParam, furniIds, setFurniIds, actionDelay, setActionDelay, saveWired, selectObjectForWired };
|
return { trigger, setTrigger, intParams, setIntParams, stringParam, setStringParam, furniIds, setFurniIds, actionDelay, setActionDelay, setAllowsFurni, saveWired, selectObjectForWired };
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useWired = () => useBetween(useWiredState);
|
export const useWired = () => useBetween(useWiredState);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user