|
@@ -1,6 +1,7 @@
|
|
|
import React from 'react';
|
|
|
import { Row, Col, Select, Segmented } from 'antd';
|
|
|
-import { useSelector } from 'react-redux';
|
|
|
+import { useSelector, useDispatch } from 'react-redux';
|
|
|
+import { setCurrentPatientType } from '@/states/patientTypeSlice';
|
|
|
import { RootState } from '@/states/store';
|
|
|
import { PatientType } from '@/API/patientType';
|
|
|
import { BodyPart } from '@/API/bodyPart';
|
|
@@ -21,12 +22,17 @@ const RegisterAvailableFilterBar: React.FC<Props> = ({
|
|
|
setSelected,
|
|
|
bodyPart,
|
|
|
setBodyPart,
|
|
|
- patientType,
|
|
|
setPatientType,
|
|
|
enabled,
|
|
|
setEnabled,
|
|
|
}) => {
|
|
|
- const bodyParts = useSelector((state: RootState) => state.bodyPart.items); // [{ label, value }]
|
|
|
+ const dispatch = useDispatch();
|
|
|
+ const bodyParts: BodyPart[] = useSelector(
|
|
|
+ (state: RootState) => state.bodyPart.byPatientType
|
|
|
+ ); // [{ label, value }]
|
|
|
+ const currentPatientType = useSelector(
|
|
|
+ (state: RootState) => state.patientType.current
|
|
|
+ );
|
|
|
const patientTypes = useSelector(
|
|
|
(state: RootState) => state.patientType.items
|
|
|
); // [{ label, value }]
|
|
@@ -61,6 +67,7 @@ const RegisterAvailableFilterBar: React.FC<Props> = ({
|
|
|
}))}
|
|
|
value={bodyPart}
|
|
|
onChange={setBodyPart}
|
|
|
+ disabled={!currentPatientType}
|
|
|
/>
|
|
|
</Col>
|
|
|
<Col xs={24} sm={12} md={6} lg={6} xl={6}>
|
|
@@ -72,8 +79,14 @@ const RegisterAvailableFilterBar: React.FC<Props> = ({
|
|
|
label: item.patient_type_name,
|
|
|
value: item.patient_type_id,
|
|
|
}))}
|
|
|
- value={patientType}
|
|
|
- onChange={setPatientType}
|
|
|
+ value={currentPatientType?.patient_type_id}
|
|
|
+ onChange={(val) => {
|
|
|
+ setPatientType(val);
|
|
|
+ const selectedPatientType = patientTypes.find(
|
|
|
+ (item) => item.patient_type_id === val
|
|
|
+ );
|
|
|
+ dispatch(setCurrentPatientType(selectedPatientType || null));
|
|
|
+ }}
|
|
|
/>
|
|
|
</Col>
|
|
|
<Col xs={24} sm={12} md={6} lg={6} xl={4}>
|