починил ввод для поиска пациентов и линз в модальном окне по выдаче линзы
This commit is contained in:
parent
bd1ba09b08
commit
c320437b00
@ -19,6 +19,11 @@ export const lensesApi = createApi({
|
|||||||
providesTags: ['Lens'],
|
providesTags: ['Lens'],
|
||||||
refetchOnMountOrArgChange: 5
|
refetchOnMountOrArgChange: 5
|
||||||
}),
|
}),
|
||||||
|
getNotIssuedLenses: builder.query({
|
||||||
|
query: () => '/lenses/not_issued/',
|
||||||
|
providesTags: ['Lens'],
|
||||||
|
refetchOnMountOrArgChange: 5
|
||||||
|
}),
|
||||||
addLens: builder.mutation({
|
addLens: builder.mutation({
|
||||||
query: (lens) => ({
|
query: (lens) => ({
|
||||||
url: '/lenses/',
|
url: '/lenses/',
|
||||||
@ -47,6 +52,7 @@ export const lensesApi = createApi({
|
|||||||
|
|
||||||
export const {
|
export const {
|
||||||
useGetLensesQuery,
|
useGetLensesQuery,
|
||||||
|
useGetNotIssuedLensesQuery,
|
||||||
useAddLensMutation,
|
useAddLensMutation,
|
||||||
useUpdateLensMutation,
|
useUpdateLensMutation,
|
||||||
useDeleteLensMutation,
|
useDeleteLensMutation,
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import {
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import useLensIssueFormModal from "./useLensIssueFormModal.js";
|
import useLensIssueFormModal from "./useLensIssueFormModal.js";
|
||||||
import useLensIssueFormModalUI from "./useLensIssueFormModalUI.js";
|
import useLensIssueFormModalUI from "./useLensIssueFormModalUI.js";
|
||||||
|
import {useMemo} from "react";
|
||||||
|
|
||||||
const LensIssueFormModal = ({visible, onCancel, onSubmit}) => {
|
const LensIssueFormModal = ({visible, onCancel, onSubmit}) => {
|
||||||
const lensIssueFormModalData = useLensIssueFormModal();
|
const lensIssueFormModalData = useLensIssueFormModal();
|
||||||
@ -37,7 +38,7 @@ const LensIssueFormModal = ({visible, onCancel, onSubmit}) => {
|
|||||||
</div>,
|
</div>,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const SelectPatientStep = () => {
|
const SelectPatientStep = useMemo(() => {
|
||||||
return lensIssueFormModalUI.selectedPatient ? (
|
return lensIssueFormModalUI.selectedPatient ? (
|
||||||
<div style={lensIssueFormModalUI.blockStepStyle}>
|
<div style={lensIssueFormModalUI.blockStepStyle}>
|
||||||
<Typography.Text strong>
|
<Typography.Text strong>
|
||||||
@ -73,9 +74,9 @@ const LensIssueFormModal = ({visible, onCancel, onSubmit}) => {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
}, [lensIssueFormModalUI, patientsItems]);
|
||||||
|
|
||||||
const SelectLensStep = () => {
|
const SelectLensStep = useMemo(() => {
|
||||||
return lensIssueFormModalUI.selectedLens ? (
|
return lensIssueFormModalUI.selectedLens ? (
|
||||||
<div style={lensIssueFormModalUI.blockStepStyle}>
|
<div style={lensIssueFormModalUI.blockStepStyle}>
|
||||||
<Typography.Text strong>
|
<Typography.Text strong>
|
||||||
@ -97,7 +98,9 @@ const LensIssueFormModal = ({visible, onCancel, onSubmit}) => {
|
|||||||
>
|
>
|
||||||
Выбрать другую линзу
|
Выбрать другую линзу
|
||||||
</Button>
|
</Button>
|
||||||
</div>) : (<>
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<Input
|
<Input
|
||||||
placeholder="Поиск линз"
|
placeholder="Поиск линз"
|
||||||
value={lensIssueFormModalUI.searchLensString}
|
value={lensIssueFormModalUI.searchLensString}
|
||||||
@ -113,7 +116,7 @@ const LensIssueFormModal = ({visible, onCancel, onSubmit}) => {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
}, [lensIssueFormModalUI.blockStepStyle, lensIssueFormModalUI.chooseContainerStyle, lensIssueFormModalUI.handleSetSearchLensString, lensIssueFormModalUI.resetLens, lensIssueFormModalUI.searchInputStyle, lensIssueFormModalUI.searchLensString, lensIssueFormModalUI.selectedLens, lensesItems]);
|
||||||
|
|
||||||
const ConfirmStep = () => {
|
const ConfirmStep = () => {
|
||||||
return (
|
return (
|
||||||
@ -135,8 +138,8 @@ const LensIssueFormModal = ({visible, onCancel, onSubmit}) => {
|
|||||||
<DatePicker
|
<DatePicker
|
||||||
placeholder={"Дата выдачи"}
|
placeholder={"Дата выдачи"}
|
||||||
value={lensIssueFormModalUI.issueDate}
|
value={lensIssueFormModalUI.issueDate}
|
||||||
onChange={(date) => lensIssueFormModalUI.setIssueDate(date)}
|
onChange={lensIssueFormModalUI.handleSetIssueDate}
|
||||||
format="DD.MM.YYYY"
|
format={"DD.MM.YYYY"}
|
||||||
style={lensIssueFormModalUI.datePickerStyle}
|
style={lensIssueFormModalUI.datePickerStyle}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
@ -175,9 +178,9 @@ const LensIssueFormModal = ({visible, onCancel, onSubmit}) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const steps = [{
|
const steps = [{
|
||||||
title: 'Выбор пациента', content: <SelectPatientStep/>,
|
title: 'Выбор пациента', content: SelectPatientStep,
|
||||||
}, {
|
}, {
|
||||||
title: 'Выбор линзы', content: <SelectLensStep/>,
|
title: 'Выбор линзы', content: SelectLensStep,
|
||||||
}, {
|
}, {
|
||||||
title: 'Подтверждение', content: <ConfirmStep/>,
|
title: 'Подтверждение', content: <ConfirmStep/>,
|
||||||
}];
|
}];
|
||||||
@ -203,7 +206,7 @@ const LensIssueFormModal = ({visible, onCancel, onSubmit}) => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
{lensIssueFormModalUI.screenXS && (
|
{!lensIssueFormModalUI.screenXS && (
|
||||||
<Steps
|
<Steps
|
||||||
current={lensIssueFormModalUI.currentStep}
|
current={lensIssueFormModalUI.currentStep}
|
||||||
items={steps}
|
items={steps}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import {useGetPatientsQuery} from "../../../../../Api/patientsApi.js";
|
import {useGetPatientsQuery} from "../../../../../Api/patientsApi.js";
|
||||||
import {useGetLensesQuery} from "../../../../../Api/lensesApi.js";
|
import {useGetNotIssuedLensesQuery} from "../../../../../Api/lensesApi.js";
|
||||||
|
|
||||||
|
|
||||||
const useLensIssueFormModal = () => {
|
const useLensIssueFormModal = () => {
|
||||||
const {data: patients = [], isLoading: isLoadingPatients, isError: isErrorPatients} = useGetPatientsQuery(undefined);
|
const {data: patients = [], isLoading: isLoadingPatients, isError: isErrorPatients} = useGetPatientsQuery(undefined);
|
||||||
const {data: lenses = [], isLoading: isLoadingLenses, isError: isErrorLenses} = useGetLensesQuery(undefined);
|
const {data: lenses = [], isLoading: isLoadingLenses, isError: isErrorLenses} = useGetNotIssuedLensesQuery(undefined);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
patients,
|
patients,
|
||||||
|
|||||||
@ -47,7 +47,7 @@ const useLensIssueFormModalUI = (visible, onCancel, onSubmit, patients, lenses)
|
|||||||
const resetLens = () => setSelectedLens(null);
|
const resetLens = () => setSelectedLens(null);
|
||||||
|
|
||||||
const screenXS = useMemo(() => screens.xs, [screens]);
|
const screenXS = useMemo(() => screens.xs, [screens]);
|
||||||
const direction = useMemo(() => screenXS ? "horizontal" : "vertical", [screenXS]);
|
const direction = useMemo(() => !screenXS ? "horizontal" : "vertical", [screenXS]);
|
||||||
const modalWidth = useMemo(() => screenXS ? 700 : "90%", [screenXS]);
|
const modalWidth = useMemo(() => screenXS ? 700 : "90%", [screenXS]);
|
||||||
|
|
||||||
const nextButtonText = useMemo(() => {
|
const nextButtonText = useMemo(() => {
|
||||||
@ -60,6 +60,7 @@ const useLensIssueFormModalUI = (visible, onCancel, onSubmit, patients, lenses)
|
|||||||
|
|
||||||
const handleSetSearchPatientString = (e) => setSearchPatientString(e.target.value);
|
const handleSetSearchPatientString = (e) => setSearchPatientString(e.target.value);
|
||||||
const handleSetSearchLensString = (e) => setSearchLensString(e.target.value);
|
const handleSetSearchLensString = (e) => setSearchLensString(e.target.value);
|
||||||
|
const handleSetIssueDate = (date) => setIssueDate(date);
|
||||||
|
|
||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
try {
|
try {
|
||||||
@ -154,17 +155,13 @@ const useLensIssueFormModalUI = (visible, onCancel, onSubmit, patients, lenses)
|
|||||||
filteredPatients,
|
filteredPatients,
|
||||||
filteredLenses,
|
filteredLenses,
|
||||||
searchPatientString,
|
searchPatientString,
|
||||||
setSearchPatientString,
|
|
||||||
searchLensString,
|
searchLensString,
|
||||||
setSearchLensString,
|
|
||||||
issueDate,
|
issueDate,
|
||||||
setIssueDate,
|
|
||||||
selectedPatient,
|
selectedPatient,
|
||||||
setSelectedPatient,
|
setSelectedPatient,
|
||||||
selectedLens,
|
selectedLens,
|
||||||
setSelectedLens,
|
setSelectedLens,
|
||||||
currentStep,
|
currentStep,
|
||||||
setCurrentStep,
|
|
||||||
disableBackButton,
|
disableBackButton,
|
||||||
disableNextButton,
|
disableNextButton,
|
||||||
nextButtonText,
|
nextButtonText,
|
||||||
@ -191,6 +188,7 @@ const useLensIssueFormModalUI = (visible, onCancel, onSubmit, patients, lenses)
|
|||||||
getDateString,
|
getDateString,
|
||||||
handleSetSearchPatientString,
|
handleSetSearchPatientString,
|
||||||
handleSetSearchLensString,
|
handleSetSearchLensString,
|
||||||
|
handleSetIssueDate,
|
||||||
getSelectedPatientBirthdayString,
|
getSelectedPatientBirthdayString,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user