Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAH-3760 | Fix. warning popup shouldn't be displayed after successful save #334

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import Notification from "../Notifications/Notifications.jsx";

const AddAppointment = props => {

const {appConfig, intl, appointmentParams, currentProvider, urlParams } = props;
const {appConfig, intl, appointmentParams, currentProvider, urlParams, setIsAppointmentModalOpen } = props;
const {setViewDate} = React.useContext(AppContext);
const errorTranslations = getErrorTranslations(intl);

Expand Down Expand Up @@ -345,6 +345,7 @@ const AddAppointment = props => {
const date = startDate ? moment(startDate) : moment();
setViewDate(date.startOf('day').toDate())
setShowSuccessPopup(true);
setIsAppointmentModalOpen(false);
reInitialiseComponent();
};

Expand Down Expand Up @@ -874,7 +875,8 @@ AddAppointment.propTypes = {
appConfig: PropTypes.object,
appointmentParams: PropTypes.object,
currentProvider: PropTypes.object,
urlParams: PropTypes.object
urlParams: PropTypes.object,
setIsAppointmentModalOpen: PropTypes.func
};

export const isVirtual = (appt) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ describe('Add appointment with appointment request enabled', () => {
it('should update the appointment status and provider responses if the AppointmentRequest is Enabled', async () => {
const {container, queryAllByText, getByText, getByTestId, queryByText} = renderWithReactIntl(
<AppContext.Provider value={{setViewDate: jest.fn()}}>
<AddAppointment appConfig={config} appointmentParams={appointmentTime} currentProvider={currentProvider}/>
<AddAppointment appConfig={config} appointmentParams={appointmentTime} currentProvider={currentProvider} setIsAppointmentModalOpen={jest.fn()}/>
</AppContext.Provider>

);
Expand All @@ -649,7 +649,7 @@ describe('Add appointment with appointment request enabled', () => {
it('should update the appointment status as Scheduled when current provider is part of appointment', async () => {
const {container, getByTestId, getByText, queryByText} = renderWithReactIntl(
<AppContext.Provider value={{setViewDate: jest.fn()}}>
<AddAppointment appConfig={config} appointmentParams={appointmentTime} currentProvider={currentProvider}/>
<AddAppointment appConfig={config} appointmentParams={appointmentTime} currentProvider={currentProvider} setIsAppointmentModalOpen={jest.fn()}/>
</AppContext.Provider>

);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import Notification from "../Notifications/Notifications.jsx";

const EditAppointment = props => {

const {appConfig, appointmentUuid, isRecurring, intl, currentProvider} = props;
const {appConfig, appointmentUuid, isRecurring, intl, currentProvider, setIsAppointmentModalOpen } = props;

const {setViewDate} = React.useContext(AppContext);

Expand Down Expand Up @@ -320,6 +320,7 @@ const EditAppointment = props => {
const date = startDate ? moment(startDate) : moment();
setViewDate(date.startOf('day').toDate())
setShowUpdateSuccessPopup(true);
setIsAppointmentModalOpen(false);
};

const isRescheduled = function (appointmentTimeBeforeEdit) {
Expand Down Expand Up @@ -811,7 +812,8 @@ EditAppointment.propTypes = {
appConfig: PropTypes.object,
appointmentUuid: PropTypes.string.isRequired,
isRecurring: PropTypes.string.isRequired,
currentProvider: PropTypes.object
currentProvider: PropTypes.object,
setIsAppointmentModalOpen: PropTypes.func
};

export default injectIntl(EditAppointment);
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ describe('Edit appointment with appointment request enabled', () => {
const {container, getByText, queryByText, getByTestId} = renderWithReactIntl(
<AppContext.Provider value={{setViewDate: jest.fn()}}>
renderWithReactIntl(<EditAppointment appConfig={config} appointmentUuid={'123tr5-7ae5-4708-9fcc-8c98daba0ca9'}
isRecurring="false" currentProvider={currentProvider} />);
isRecurring="false" currentProvider={currentProvider} setIsAppointmentModalOpen={jest.fn()}/>);
</AppContext.Provider>

);
Expand Down Expand Up @@ -571,7 +571,7 @@ describe('Edit appointment with appointment request enabled', () => {
const {container, getByText, queryByText, getByTestId} = renderWithReactIntl(
<AppContext.Provider value={{setViewDate: jest.fn()}}>
renderWithReactIntl(<EditAppointment appConfig={config} appointmentUuid={'123tr5-7ae5-4708-9fcc-8c98daba0ca9'}
isRecurring="false" currentProvider={currentProvider} />);
isRecurring="false" currentProvider={currentProvider} setIsAppointmentModalOpen={jest.fn()} />);
</AppContext.Provider>

);
Expand Down Expand Up @@ -604,7 +604,7 @@ describe('Edit appointment with appointment request enabled', () => {
const {container, getByText, queryByText, getByTestId} = renderWithReactIntl(
<AppContext.Provider value={{setViewDate: jest.fn()}}>
renderWithReactIntl(<EditAppointment appConfig={config} appointmentUuid={'123tr5-7y65-4708-9fcc-8c98daba0ca9'}
isRecurring="false" currentProvider={currentProvider} />);
isRecurring="false" currentProvider={currentProvider} setIsAppointmentModalOpen={jest.fn()} />);
</AppContext.Provider>

);
Expand Down Expand Up @@ -644,7 +644,7 @@ describe('Edit appointment with appointment request enabled', () => {
<AppContext.Provider value={{setViewDate: jest.fn()}}>
renderWithReactIntl(<EditAppointment appConfig={config}
appointmentUuid={'45hj76-7y65-4708-9fcc-8c98daba0ca9'}
isRecurring="false" currentProvider={currentProvider} currentProvider={currentProvider}/>);
isRecurring="false" currentProvider={currentProvider} currentProvider={currentProvider} setIsAppointmentModalOpen={jest.fn()} />);
</AppContext.Provider>
);
getByTextInDom = getByText;
Expand Down
16 changes: 12 additions & 4 deletions ui/react-components/containers/AppointmentContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,34 @@ class AppointmentContainer extends Component {
locale: getLocale() === 'pt_BR' ? 'pt-BR': getLocale(),
messages: translations[props.locale],
appConfig: null,
isAppointmentModalOpen: true
};

this.setIsAppointmentModalOpen = this.setIsAppointmentModalOpen.bind(this);

(async () => {
this.setState({messages: await getMessages(getLocale())});
this.setState({appConfig: await getAppConfig()});
})();
moment.locale(getLocale() === 'pt_BR' ? 'pt-BR': getLocale());
}

setIsAppointmentModalOpen(isOpen) {
this.setState({ isAppointmentModalOpen: isOpen });
};

render() {
const { locale, messages, appConfig } = this.state;
const { locale, messages, appConfig, isAppointmentModalOpen } = this.state;
const {appointmentUuid,isRecurring, setViewDate, onBack, appointmentParams, currentProvider, urlParams, editConflict, resetEditConflict} = this.props;
return (
<AppContext.Provider value={{onBack: onBack, setViewDate: setViewDate}}>
<IntlProvider defaultLocale='en' locale={locale} messages={messages}>
<div>
{appointmentUuid
? <EditAppointment appConfig={appConfig} appointmentUuid={appointmentUuid} isRecurring={isRecurring} currentProvider={currentProvider}/>
: <AddAppointment appConfig={appConfig} appointmentParams={appointmentParams} currentProvider={currentProvider} urlParams={urlParams}/>
? <EditAppointment appConfig={appConfig} appointmentUuid={appointmentUuid} isRecurring={isRecurring} currentProvider={currentProvider} setIsAppointmentModalOpen={this.setIsAppointmentModalOpen}/>
: <AddAppointment appConfig={appConfig} appointmentParams={appointmentParams} currentProvider={currentProvider} urlParams={urlParams} setIsAppointmentModalOpen={this.setIsAppointmentModalOpen}/>
}
{ editConflict && <CancelConfirmationWrapper show={editConflict} appointmentUuid={appointmentUuid} onBack={onBack} resetEditConflict={resetEditConflict}/>}
{ isAppointmentModalOpen && editConflict && <CancelConfirmationWrapper show={editConflict} appointmentUuid={appointmentUuid} onBack={onBack} resetEditConflict={resetEditConflict}/>}
</div>
</IntlProvider>
</AppContext.Provider>);
Expand Down
Loading