refactor: more use cases with useToggle

This commit is contained in:
Mahyar Khanbolooki
2025-08-10 18:29:48 +03:30
parent 389ac492c2
commit 7fca4375fc
45 changed files with 155 additions and 133 deletions
+3 -3
View File
@@ -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>
: