Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-transifex
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher authored Feb 22, 2024
2 parents f3c2847 + 4d8ab44 commit 60322fc
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
DatePicker,
Form,
InlineLoading,
Layer,
MultiSelect,
NumberInput,
Select,
Expand All @@ -24,7 +23,14 @@ import {
import { Controller, useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
import { useLocations, useSession, showSnackbar, useLayoutType, useConfig } from '@openmrs/esm-framework';
import {
useLocations,
useSession,
showSnackbar,
useLayoutType,
useConfig,
ResponsiveWrapper,
} from '@openmrs/esm-framework';
import { convertTime12to24 } from '@openmrs/esm-patient-common-lib';
import {
saveAppointment,
Expand Down Expand Up @@ -302,7 +308,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
<section className={styles.formGroup}>
<span className={styles.heading}>{t('location', 'Location')}</span>
<div>
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Controller
name="location"
control={control}
Expand Down Expand Up @@ -330,7 +336,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
</section>
<section className={styles.formGroup}>
<span className={styles.heading}>{t('service', 'Service')}</span>
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Controller
name="selectedService"
control={control}
Expand Down Expand Up @@ -364,7 +370,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({

<section className={styles.formGroup}>
<span className={styles.heading}>{t('appointmentType_title', 'Appointment Type')}</span>
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Controller
name="appointmentType"
control={control}
Expand Down Expand Up @@ -417,12 +423,12 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
toggled={isAllDayAppointment}
/>
)}
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Controller
name="appointmentDateTime"
control={control}
render={({ field: { onChange, value, ref } }) => (
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<DatePicker
datePickerType="range"
dateFormat={datePickerFormat}
Expand Down Expand Up @@ -459,7 +465,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
<TimeAndDuration isTablet={isTablet} control={control} services={services} watch={watch} t={t} />
)}

<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Controller
name="recurringPatternPeriod"
control={control}
Expand All @@ -482,7 +488,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
/>
</ResponsiveWrapper>

<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Controller
name="recurringPatternType"
control={control}
Expand Down Expand Up @@ -543,7 +549,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
toggled={isAllDayAppointment}
/>
)}
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Controller
name="appointmentDateTime"
control={control}
Expand Down Expand Up @@ -575,7 +581,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({

{getValues('selectedService') && (
<section className={styles.formGroup}>
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Workload
selectedService={watch('selectedService')}
appointmentDate={watch('appointmentDateTime').startDate}
Expand All @@ -587,7 +593,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
{context !== 'creating' ? (
<section className={styles.formGroup}>
<span className={styles.heading}>{t('appointmentStatus', 'Appointment Status')}</span>
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Controller
name="appointmentStatus"
control={control}
Expand Down Expand Up @@ -621,7 +627,7 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
name="appointmentNote"
control={control}
render={({ field: { onChange, onBlur, value, ref } }) => (
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<TextArea
id="appointmentNote"
value={value}
Expand All @@ -648,16 +654,12 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
);
};

function ResponsiveWrapper({ children, isTablet }) {
return isTablet ? <Layer>{children}</Layer> : <div>{children}</div>;
}

function TimeAndDuration({ isTablet, t, watch, control, services }) {
const defaultDuration = services?.find((service) => service.name === watch('selectedService'))?.durationMins || null;

return (
<React.Fragment>
<ResponsiveWrapper isTablet={isTablet}>
<>
<ResponsiveWrapper>
<Controller
name="startTime"
control={control}
Expand Down Expand Up @@ -687,7 +689,7 @@ function TimeAndDuration({ isTablet, t, watch, control, services }) {
)}
/>
</ResponsiveWrapper>
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Controller
name="duration"
control={control}
Expand All @@ -709,7 +711,7 @@ function TimeAndDuration({ isTablet, t, watch, control, services }) {
)}
/>
</ResponsiveWrapper>
</React.Fragment>
</>
);
}

Expand Down
8 changes: 7 additions & 1 deletion packages/esm-appointments-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@
},
{
"name": "appointments-form-workspace",
"component": "appointmentsFormWorkspace"
"component": "appointmentsFormWorkspace",
"meta": {
"title": {
"key": "createNewAppointment",
"default": "Create new appointment"
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export function CodedPersonAttributeField({
const { data: conceptAnswers, isLoading: isLoadingConceptAnswers } = useConceptAnswers(
customConceptAnswers.length ? '' : answerConceptSetUuid,
);

const { t } = useTranslation();
const fieldName = `attributes.${personAttributeType.uuid}`;
const [error, setError] = useState(false);

useEffect(() => {
if (!answerConceptSetUuid) {
if (!answerConceptSetUuid && !customConceptAnswers.length) {
reportError(
t(
'codedPersonAttributeNoAnswerSet',
Expand All @@ -41,10 +42,10 @@ export function CodedPersonAttributeField({
);
setError(true);
}
}, [answerConceptSetUuid]);
}, [answerConceptSetUuid, customConceptAnswers]);

useEffect(() => {
if (!isLoadingConceptAnswers) {
if (!isLoadingConceptAnswers && !customConceptAnswers.length) {
if (!conceptAnswers) {
reportError(
t(
Expand All @@ -69,7 +70,7 @@ export function CodedPersonAttributeField({
setError(true);
}
}
}, [isLoadingConceptAnswers, conceptAnswers]);
}, [isLoadingConceptAnswers, conceptAnswers, customConceptAnswers]);

const answers = useMemo(() => {
if (customConceptAnswers.length) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useEffect, useState } from 'react';
import classNames from 'classnames';
import { InlineNotification, Layer, Select, SelectItem, RadioButtonGroup, RadioButton, TextInput } from '@carbon/react';
import { InlineNotification, Select, SelectItem, RadioButtonGroup, RadioButton, TextInput } from '@carbon/react';
import { useQueueLocations } from '../hooks/useQueueLocations';
import { usePriority, useStatus } from '../../active-visits/active-visits-table.resource';
import styles from './visit-form-queue-fields.scss';
import { type ConfigObject, useConfig, useLayoutType } from '@openmrs/esm-framework';
import { type ConfigObject, useConfig, useLayoutType, ResponsiveWrapper } from '@openmrs/esm-framework';
import { useTranslation } from 'react-i18next';
import { useQueues } from '../../helpers/useQueues';

Expand Down Expand Up @@ -47,7 +47,7 @@ const StartVisitQueueFields: React.FC = () => {
<div>
<section className={styles.section}>
<div className={styles.sectionTitle}>{t('queueLocation', 'Queue location')}</div>
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<Select
labelText={t('selectQueueLocation', 'Select a queue location')}
id="queueLocation"
Expand Down Expand Up @@ -154,8 +154,4 @@ const StartVisitQueueFields: React.FC = () => {
);
};

function ResponsiveWrapper({ children, isTablet }) {
return isTablet ? <Layer>{children}</Layer> : <div>{children}</div>;
}

export default StartVisitQueueFields;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DatePickerInput,
Form,
InlineNotification,
Layer,
Row,
Select,
SelectItem,
Expand All @@ -34,6 +33,7 @@ import {
toDateObjectStrict,
showSnackbar,
useConfig,
ResponsiveWrapper,
type ConfigObject,
} from '@openmrs/esm-framework';
import BaseVisitType from './base-visit-type.component';
Expand Down Expand Up @@ -229,7 +229,7 @@ const StartVisitForm: React.FC<VisitFormProps> = ({ patientUuid, toggleSearchTyp
style={{ width: '100%' }}
/>
</DatePicker>
<ResponsiveWrapper isTablet={isTablet}>
<ResponsiveWrapper>
<TimePicker
id="visitStartTime"
labelText={t('time', 'Time')}
Expand Down Expand Up @@ -357,8 +357,4 @@ const StartVisitForm: React.FC<VisitFormProps> = ({ patientUuid, toggleSearchTyp
);
};

function ResponsiveWrapper({ children, isTablet }) {
return isTablet ? <Layer>{children}</Layer> : <div>{children}</div>;
}

export default StartVisitForm;
Loading

0 comments on commit 60322fc

Please sign in to comment.