refactor: more use cases with useToggle
This commit is contained in:
@@ -35,7 +35,7 @@ function ChatIndex({ }: Props) {
|
||||
const [search, setSearch] = useState('');
|
||||
const [selectedChats, setSelectedChats] = useState<Array<string>>([]);
|
||||
const router = useRouter();
|
||||
const { active: deleteModal, onToggle: onToggleDeleteModal } = useToggle();
|
||||
const { state: deleteModal, toggle: toggleDeleteModal } = useToggle();
|
||||
|
||||
const [chatsList, setChatList] = useState<Array<ChatEntryModel>>([
|
||||
{
|
||||
@@ -106,7 +106,7 @@ function ChatIndex({ }: Props) {
|
||||
if (deleteModal) {
|
||||
setSelectedChats([]);
|
||||
}
|
||||
onToggleDeleteModal()
|
||||
toggleDeleteModal()
|
||||
};
|
||||
|
||||
const deleteSelectedChats = () => {
|
||||
@@ -153,7 +153,7 @@ function ChatIndex({ }: Props) {
|
||||
<SearchBox placeholder={t('InputSearch.Placeholder')} value={search} onChange={(e) => setSearch(e.target.value)} />
|
||||
|
||||
{selectedChats.length > 0 ?
|
||||
<span onClick={onToggleDeleteModal} className='bg-container p-2 rounded-xl active:bg-gray-50'>
|
||||
<span onClick={toggleDeleteModal} className='bg-container p-2 rounded-xl active:bg-gray-50'>
|
||||
<Trash size={24} className='stroke-primary' />
|
||||
</span>
|
||||
:
|
||||
|
||||
Reference in New Issue
Block a user