diff --git a/src/Components/Utils/Notificaciones/Notificaciones.tsx b/src/Components/Utils/Notificaciones/Notificaciones.tsx index 25e12bf..c2bbaad 100644 --- a/src/Components/Utils/Notificaciones/Notificaciones.tsx +++ b/src/Components/Utils/Notificaciones/Notificaciones.tsx @@ -19,6 +19,7 @@ import NotificacionesDS from '../../../Services/Utils/Notificaciones/Notificacio import { AiFillCaretLeft, AiFillCaretRight, + AiOutlineFileSearch, AiOutlineProfile, AiOutlineTeam, AiOutlineUsergroupAdd @@ -28,11 +29,17 @@ import { HiCurrencyDollar } from 'react-icons/hi' import DTONotificacionesContactoGrupo from '../../../DTO/Utils/Notificaciones/DTONotificacionesContactoGrupo' import { number } from 'yup/lib/locale' import INotificacionesConceptos from '../../../Interfaces/Utils/INotificacionesConceptos' +import INotificacionesLog from '../../../Interfaces/Utils/INotificacionesLog' export interface INotificacionesProps {} export function Notificaciones(props: INotificacionesProps) { + const [UserId, setUserId] = useState(() => { + const stickyValue = window.localStorage.getItem('UserId') + return stickyValue !== null ? JSON.parse(stickyValue) : 0 + }) const [selectedRows, setSelectedRows] = React.useState([]) + const [Log, setLog] = useState([]) const [Grupos, setGrupos] = useState([]) const [Contactos, setContactos] = useState([]) const [CatConceptos, setCatConceptos] = useState( @@ -43,7 +50,6 @@ export function Notificaciones(props: INotificacionesProps) { >([]) const [Filtro, setFiltro] = useState('') const [FiltroEnGrupo, setFiltroEnGrupo] = useState('') - const [Mensaje, setMensaje] = useState('') const [Grupo, setGrupo] = useState('') const [IdGrupo, setIdGrupo] = useState(0) const [Concepto, setConcepto] = useState('') @@ -58,6 +64,7 @@ export function Notificaciones(props: INotificacionesProps) { const [ShowModal, setShowModal] = useState(false) const [ShowModalG, setShowModalG] = useState(false) const [ShowModalC, setShowModalC] = useState(false) + const [ShowModalLog, setShowModalLog] = useState(false) const [SelectedConcepto, setSelectedConcepto] = useState(true) const [header, setHeader] = useState('') const [show, setShowMsg] = useState(false) @@ -127,6 +134,39 @@ export function Notificaciones(props: INotificacionesProps) { } ] + const colLog = [ + { + name: 'id', + width: '60px', + cell: (row: INotificacionesLog) =>
{row.id}
, + sortable: true + }, + { + name: 'Envia', + width: '130px', + cell: (row: INotificacionesLog) =>
{row.envia}
, + sortable: true + }, + { + name: 'Concepto', + width: '300px', + cell: (row: INotificacionesLog) =>
{row.concepto}
, + sortable: true + }, + { + name: 'Enviado a...', + width: '600px', + cell: (row: INotificacionesLog) =>
{row.contactos}
, + sortable: true + }, + { + name: 'Fecha / hora', + width: '200px', + cell: (row: INotificacionesLog) =>
{row.fhCreacion}
, + sortable: true + } + ] + const saveContact = () => { if (!Nombre) { setHeader('Error') @@ -269,6 +309,21 @@ export function Notificaciones(props: INotificacionesProps) { loadAllConcepts() }, []) + useEffect(() => { + if (ShowModalLog) { + NotificacionesDS.Log$Get() + .then((response) => { + setLog(response.data) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }) + } + }, [ShowModalLog]) + useEffect(() => { if (ShowModal) { if (selectedRows.length > 0) { @@ -334,19 +389,19 @@ export function Notificaciones(props: INotificacionesProps) { } const sendWhattsapp = () => { - if (IdConcepto===0) { - setHeader('Error') - setMsg('Para enviar un concepto primero debe guardarlo en el catalogo') - setShowMsg(true) - return + if (IdConcepto === 0) { + setHeader('Error') + setMsg('Para enviar un concepto primero debe guardarlo en el catalogo') + setShowMsg(true) + return } - if (IdGrupo===0) { + if (IdGrupo === 0) { setHeader('Error') setMsg('Para enviar un mensaje primero debe seleccionar el grupo') setShowMsg(true) return - } - NotificacionesDS.SendWhattsapp(IdConcepto, Mensaje, IdGrupo) + } + NotificacionesDS.SendWhattsapp(UserId, Concepto, IdGrupo) .then((response) => { setHeader('Informativo') setMsg(`El mensaje se ha enviado satisfactoriamente`) @@ -370,7 +425,19 @@ export function Notificaciones(props: INotificacionesProps) {
- Notificaciones + + Notificaciones{' '} + { + setShowModalLog(!ShowModalLog) + }} + > + + + + + Mensaje @@ -388,15 +455,6 @@ export function Notificaciones(props: INotificacionesProps) { - {/* { - setMensaje(e.target.value) - }} - /> */} + + { + setShowModalLog(false) + }} + size={'sm'} + dialogClassName={'modal-90w'} + closeButton + > + +
+ + + + + +
+
+
(`/Notificaciones/SendWhattsapp?IdConcepto=${IdConcepto}&Concepto=${Concepto}&Grupo=${Grupo}`); + SendWhattsapp(IdUsuario: number, Concepto: string, IdGrupo: number) { + return http.get(`/Notificaciones/SendWhattsapp?IdUsuario=${IdUsuario}&Concepto=${Concepto}&IdGrupo=${IdGrupo}`); + } + Log$Get() { + return http.get(`/Notificaciones/Log/Get`); } ContactosAppend(data: INotificacionesContactos) { return http.post(`/Notificaciones/Contacto/Append`, data);