|
|
|
@ -1,7 +1,7 @@
@@ -1,7 +1,7 @@
|
|
|
|
|
import React, { FC } from "react"; |
|
|
|
|
import React, { FC, useEffect } from "react"; |
|
|
|
|
import Modal from "../../components/Modal"; |
|
|
|
|
import { Controller } from "react-hook-form"; |
|
|
|
|
import { InputCheckbox, InputField, TextField } from "@/shared"; |
|
|
|
|
import { InputField, TextField } from "@/shared"; |
|
|
|
|
import { useSendNotifications } from "./hooks/use-send-notifications.hook"; |
|
|
|
|
import "./style.scss"; |
|
|
|
|
import { useFetchChatUsers } from "@/containers/User/hooks"; |
|
|
|
@ -10,9 +10,6 @@ import {
@@ -10,9 +10,6 @@ import {
|
|
|
|
|
UsersSelectList, |
|
|
|
|
} from "@/containers/User/components"; |
|
|
|
|
import { ButtonToolbar, Button } from "reactstrap"; |
|
|
|
|
import { Checkbox } from "@material-ui/core"; |
|
|
|
|
import { divide } from "lodash"; |
|
|
|
|
import { CheckField } from "@/components/Fields"; |
|
|
|
|
import { FormCheckbox } from "@/components/Forms/FormCheckbox"; |
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
@ -38,6 +35,21 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
@@ -38,6 +35,21 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
|
|
|
|
|
loadParams, |
|
|
|
|
} = useFetchChatUsers(); |
|
|
|
|
|
|
|
|
|
const isSelectedAll = Boolean(selectedUsers?.length === items?.length); |
|
|
|
|
|
|
|
|
|
const toggleSelectAll = () => { |
|
|
|
|
if (isSelectedAll) selectUsers([]); |
|
|
|
|
else selectUsers(items); |
|
|
|
|
}; |
|
|
|
|
const reset = () => { |
|
|
|
|
setSearchVal(""); |
|
|
|
|
form.reset({ title: "", haveToSendEmail: false, content: "", users: [] }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (!isOpen) reset(); |
|
|
|
|
}, [isOpen]); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Modal show={isOpen} toggle={() => onClose()} title="Нове сповіщення"> |
|
|
|
|
<div className="form send-notifi-form"> |
|
|
|
@ -76,10 +88,10 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
@@ -76,10 +88,10 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
|
|
|
|
|
items={items} |
|
|
|
|
searchStr={searchString} |
|
|
|
|
onChangeContact={setSearchVal} |
|
|
|
|
selectAll={() => selectUsers(items)} |
|
|
|
|
selectAll={toggleSelectAll} |
|
|
|
|
allBtnLabel={isSelectedAll ? "Очистити" : "Додати всіх"} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<Controller |
|
|
|
|
name="users" |
|
|
|
|
control={form.control} |
|
|
|
@ -105,7 +117,6 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
@@ -105,7 +117,6 @@ export const SendNotificationsWidget: FC<Props> = ({ isOpen, onClose }) => {
|
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
<ButtonToolbar className="form__add-chat"> |
|
|
|
|
<Button |
|
|
|
|
style={{ width: "220px", height: "46px" }} |
|
|
|
|