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