refactor: Удалил строку поиска пациентов из MailingPage
This commit is contained in:
parent
90f3ab8ab1
commit
9b58e09f37
@ -14,14 +14,12 @@ const MailingPage = () => {
|
|||||||
selectedPatientIds,
|
selectedPatientIds,
|
||||||
subject,
|
subject,
|
||||||
body,
|
body,
|
||||||
searchQuery,
|
|
||||||
containerStyle,
|
containerStyle,
|
||||||
cardStyle,
|
cardStyle,
|
||||||
buttonStyle,
|
buttonStyle,
|
||||||
handleSelectPatients,
|
handleSelectPatients,
|
||||||
handleSubjectChange,
|
handleSubjectChange,
|
||||||
handleBodyChange,
|
handleBodyChange,
|
||||||
handleSearchChange,
|
|
||||||
handleSendEmail,
|
handleSendEmail,
|
||||||
isMobile,
|
isMobile,
|
||||||
} = useMailingPage();
|
} = useMailingPage();
|
||||||
@ -64,14 +62,6 @@ const MailingPage = () => {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Card style={cardStyle} title="Выбор пациентов">
|
<Card style={cardStyle} title="Выбор пациентов">
|
||||||
<Input
|
|
||||||
placeholder="Поиск по имени или email"
|
|
||||||
prefix={<SearchOutlined />}
|
|
||||||
value={searchQuery}
|
|
||||||
onChange={handleSearchChange}
|
|
||||||
style={{ marginBottom: 16, width: isMobile ? "100%" : 300 }}
|
|
||||||
allowClear
|
|
||||||
/>
|
|
||||||
<Table
|
<Table
|
||||||
rowSelection={{
|
rowSelection={{
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useState, useMemo } from "react";
|
import {useState} from "react";
|
||||||
import {notification} from "antd";
|
import {notification} from "antd";
|
||||||
import {Grid} from "antd";
|
import {Grid} from "antd";
|
||||||
import {useGetPatientsWithEmailQuery} from "../../../Api/patientsApi.js";
|
import {useGetPatientsWithEmailQuery} from "../../../Api/patientsApi.js";
|
||||||
@ -19,22 +19,11 @@ const useMailingPage = () => {
|
|||||||
const [selectedPatientIds, setSelectedPatientIds] = useState([]);
|
const [selectedPatientIds, setSelectedPatientIds] = useState([]);
|
||||||
const [subject, setSubject] = useState("");
|
const [subject, setSubject] = useState("");
|
||||||
const [body, setBody] = useState("");
|
const [body, setBody] = useState("");
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
|
||||||
|
|
||||||
const containerStyle = {padding: screens.xs ? 16 : 24};
|
const containerStyle = {padding: screens.xs ? 16 : 24};
|
||||||
const cardStyle = {marginBottom: 24};
|
const cardStyle = {marginBottom: 24};
|
||||||
const buttonStyle = {width: screens.xs ? "100%" : "auto", marginTop: 16};
|
const buttonStyle = {width: screens.xs ? "100%" : "auto", marginTop: 16};
|
||||||
|
|
||||||
const filteredPatients = useMemo(() => {
|
|
||||||
if (!searchQuery) return patientsWithEmail;
|
|
||||||
const lowerQuery = searchQuery.toLowerCase();
|
|
||||||
return patientsWithEmail.filter(
|
|
||||||
(patient) =>
|
|
||||||
`${patient.last_name} ${patient.first_name}`.toLowerCase().includes(lowerQuery) ||
|
|
||||||
patient.email.toLowerCase().includes(lowerQuery)
|
|
||||||
);
|
|
||||||
}, [patientsWithEmail, searchQuery]);
|
|
||||||
|
|
||||||
const handleSelectPatients = (selectedRowKeys) => {
|
const handleSelectPatients = (selectedRowKeys) => {
|
||||||
setSelectedPatientIds(selectedRowKeys);
|
setSelectedPatientIds(selectedRowKeys);
|
||||||
};
|
};
|
||||||
@ -47,10 +36,6 @@ const useMailingPage = () => {
|
|||||||
setBody(e.target.value);
|
setBody(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSearchChange = (e) => {
|
|
||||||
setSearchQuery(e.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const generateMailtoLink = () => {
|
const generateMailtoLink = () => {
|
||||||
if (!selectedPatientIds.length) {
|
if (!selectedPatientIds.length) {
|
||||||
notification.error({
|
notification.error({
|
||||||
@ -76,7 +61,7 @@ const useMailingPage = () => {
|
|||||||
|
|
||||||
const encodedSubject = encodeURIComponent(subject);
|
const encodedSubject = encodeURIComponent(subject);
|
||||||
const encodedBody = encodeURIComponent(body);
|
const encodedBody = encodeURIComponent(body);
|
||||||
return `mailto:?bcc=${selectedEmails}&subject=${encodedSubject}&body=${encodedBody}`;
|
return `mailto:?cc=${selectedEmails}&subject=${encodedSubject}&body=${encodedBody}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSendEmail = () => {
|
const handleSendEmail = () => {
|
||||||
@ -87,20 +72,18 @@ const useMailingPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
patientsWithEmail: filteredPatients,
|
patientsWithEmail,
|
||||||
isLoading: isLoadingPatients,
|
isLoading: isLoadingPatients,
|
||||||
isError: isErrorPatients,
|
isError: isErrorPatients,
|
||||||
selectedPatientIds,
|
selectedPatientIds,
|
||||||
subject,
|
subject,
|
||||||
body,
|
body,
|
||||||
searchQuery,
|
|
||||||
containerStyle,
|
containerStyle,
|
||||||
cardStyle,
|
cardStyle,
|
||||||
buttonStyle,
|
buttonStyle,
|
||||||
handleSelectPatients,
|
handleSelectPatients,
|
||||||
handleSubjectChange,
|
handleSubjectChange,
|
||||||
handleBodyChange,
|
handleBodyChange,
|
||||||
handleSearchChange,
|
|
||||||
handleSendEmail,
|
handleSendEmail,
|
||||||
isMobile: screens.xs,
|
isMobile: screens.xs,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user