|
|
|
@ -25,6 +25,8 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
@@ -25,6 +25,8 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
|
|
|
|
|
unselectUser, |
|
|
|
|
selectUsers, |
|
|
|
|
submit, |
|
|
|
|
allSelected, |
|
|
|
|
setAllSelected, |
|
|
|
|
} = useSendNotifications(onClose); |
|
|
|
|
|
|
|
|
|
const { |
|
|
|
@ -35,14 +37,16 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
@@ -35,14 +37,16 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
|
|
|
|
|
loadParams, |
|
|
|
|
} = useFetchChatUsers(); |
|
|
|
|
|
|
|
|
|
const isSelectedAll = Boolean(selectedUsers?.length === items?.length); |
|
|
|
|
|
|
|
|
|
const toggleSelectAll = () => { |
|
|
|
|
if (isSelectedAll) selectUsers([]); |
|
|
|
|
else selectUsers(items); |
|
|
|
|
if (allSelected) { |
|
|
|
|
selectUsers([]); |
|
|
|
|
setAllSelected(false); |
|
|
|
|
} else setAllSelected(true); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const reset = () => { |
|
|
|
|
setSearchVal(""); |
|
|
|
|
setAllSelected(false); |
|
|
|
|
form.reset({ title: "", haveToSendEmail: false, content: "", users: [] }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -50,6 +54,14 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
@@ -50,6 +54,14 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
|
|
|
|
|
if (!isOpen) reset(); |
|
|
|
|
}, [isOpen]); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (allSelected) selectUsers(items); |
|
|
|
|
}, [allSelected, items]); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (selectedUsers.length === loadParams?.count) setAllSelected(true); |
|
|
|
|
}, [loadParams?.count, selectedUsers]); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Modal show={isOpen} toggle={() => onClose()} title="Нове сповіщення"> |
|
|
|
|
<div className="form send-notifi-form"> |
|
|
|
@ -89,7 +101,7 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
@@ -89,7 +101,7 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
|
|
|
|
|
searchStr={searchString} |
|
|
|
|
onChangeContact={setSearchVal} |
|
|
|
|
selectAll={toggleSelectAll} |
|
|
|
|
allBtnLabel={isSelectedAll ? "Очистити" : "Додати всіх"} |
|
|
|
|
allBtnLabel={allSelected ? "Очистити" : "Додати всіх"} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<Controller |
|
|
|
|