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

No provider slots error #33789

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 @@ -97,6 +97,8 @@
routeToNextReferralPage(history, currentPage, currentReferral.UUID);
};

const noSlotsAvailable = !provider.slots.length;

return (
<>
<div>
Expand Down Expand Up @@ -165,51 +167,70 @@
{provider.driveTime} ({provider.driveDistance})
</p>
<h2>Choose a date and time</h2>
<p>
Select an available date and time from the calendar below. Appointment
times are displayed in{' '}
{`${getTimezoneDescByFacilityId(
currentReferral.ReferringFacilityInfo.FacilityCode,
)}`}
.
</p>
{!noSlotsAvailable && (
<p>
Select an available date and time from the calendar below.
Appointment times are displayed in{' '}
{`${getTimezoneDescByFacilityId(
currentReferral.ReferringFacilityInfo.FacilityCode,
)}`}
.
</p>
)}
</div>
<div data-testid="cal-widget">
<CalendarWidget
maxSelections={1}
availableSlots={provider.slots}
value={[selectedDate]}
id="dateTime"
timezone={facilityTimeZone}
additionalOptions={{
required: true,
}}
// disabled={loadingSlots}
disabledMessage={
<va-loading-indicator
data-testid="loadingIndicator"
set-focus
message="Finding appointment availability..."
{noSlotsAvailable && (
<va-alert
status="warning"
data-testid="no-slots-alert"
class="vads-u-margin-top--3"
>
<h2 slot="headline">
We’re sorry. We couldn’t find any open time slots.
</h2>
<p>Please call this provider to schedule an appointment</p>
<va-telephone contact={provider.orgPhone} />
</va-alert>
)}
{!noSlotsAvailable && (
<>
<div data-testid="cal-widget">
<CalendarWidget
maxSelections={1}
availableSlots={provider.slots}
value={[selectedDate]}
id="dateTime"
timezone={facilityTimeZone}
additionalOptions={{
required: true,
}}
// disabled={loadingSlots}
disabledMessage={
<va-loading-indicator

Check warning on line 208 in src/applications/vaos/referral-appointments/components/DateAndTimeContent.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/referral-appointments/components/DateAndTimeContent.jsx:208:17:Missing parentheses around multilines JSX
data-testid="loadingIndicator"
set-focus
message="Finding appointment availability..."
/>
}
onChange={onChange}
onNextMonth={null}
onPreviousMonth={null}
minDate={format(new Date(), 'yyyy-MM-dd')}
maxDate={format(latestAvailableSlot, 'yyyy-MM-dd')}
required
requiredMessage={error}
startMonth={format(new Date(), 'yyyy-MM')}
showValidation={error.length > 0}
showWeekends
overrideMaxDays
/>
}
onChange={onChange}
onNextMonth={null}
onPreviousMonth={null}
minDate={format(new Date(), 'yyyy-MM-dd')}
maxDate={format(latestAvailableSlot, 'yyyy-MM-dd')}
required
requiredMessage={error}
startMonth={format(new Date(), 'yyyy-MM')}
showValidation={error.length > 0}
showWeekends
overrideMaxDays
/>
</div>
<FormButtons
onBack={() => onBack()}
onSubmit={() => onSubmit()}
loadingText="Page change in progress"
/>
</div>
<FormButtons
onBack={() => onBack()}
onSubmit={() => onSubmit()}
loadingText="Page change in progress"
/>
</>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,17 @@ describe('VAOS Component: DateAndTimeContent', () => {
// Routes to next page if selection exists
expect(screen.history.push.called).to.be.true;
});
it('should show error if no slots available', async () => {
const screen = renderWithStoreAndRouter(
<DateAndTimeContent
currentReferral={referral}
provider={createProviderDetails(0)}
appointmentsByMonth={appointmentsByMonth}
/>,
{
initialState,
},
);
expect(screen.getByTestId('no-slots-alert')).to.exist;
});
});
17 changes: 17 additions & 0 deletions src/applications/vaos/referral-appointments/utils/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ const dateFns = require('date-fns');
const dateFnsTz = require('date-fns-tz');

const providers = {
'0': {
providerName: 'Dr. Perpetually Unavailable',
typeOfCare: 'Physical Therapy',
orgName: 'Ethereal Adjunct of Deferred Care',
orgAddress: {
street1: '421 Promethean Circuit',
street2: 'Suite 300',
street3: '',
city: 'Portland',
state: 'Oregon',
zip: '97214',
},
orgPhone: '555-687-6736',
driveTime: '1 hour drive',
driveDistance: '100 miles',
location: 'Hypothetical Adjunct Node, Sublime Care Complex',
},
'111': {
providerName: 'Dr. Bones',
typeOfCare: 'Physical Therapy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ const createReferrals = (numberOfReferrals = 3, baseDate) => {
const baseDateObject = new Date(year, month - 1, day);
const referrals = [];
const baseUUID = 'add2f0f4-a1ea-4dea-a504-a54ab57c68';
const providerIds = ['111', '222'];
const isOdd = number => {
return number % 2;
};
const providerIds = ['111', '222', '0'];

for (let i = 0; i < numberOfReferrals; i++) {
const startDate = addDays(baseDateObject, i);
Expand All @@ -79,7 +76,7 @@ const createReferrals = (numberOfReferrals = 3, baseDate) => {
createReferral(
referralDate,
`${baseUUID}${i.toString().padStart(2, '0')}`,
isOdd(i) ? providerIds[0] : providerIds[1],
providerIds[i % providerIds.length],
),
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/applications/vaos/services/mocks/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* istanbul ignore file */
/* eslint-disable camelcase */
const delay = require('mocker-api/lib/delay');
const moment = require('moment');

Check warning on line 4 in src/applications/vaos/services/mocks/index.js

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/services/mocks/index.js:4:16:Use date-fns or Native Date methods instead of moment.js
// var
const confirmedVA = require('./var/confirmed_va.json');
const confirmedCC = require('./var/confirmed_cc.json');
Expand Down Expand Up @@ -352,10 +352,10 @@
Array.isArray(requestedPeriods) &&
requestedPeriods.length > 0
) {
date = moment(requestedPeriods[0].start);

Check warning on line 355 in src/applications/vaos/services/mocks/index.js

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/services/mocks/index.js:355:22:Consider using Native new Date().
}
} else if (status === 'booked') {
date = moment(appointment.attributes.start);

Check warning on line 358 in src/applications/vaos/services/mocks/index.js

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/services/mocks/index.js:358:20:Consider using Native new Date().
}

if (
Expand Down Expand Up @@ -415,10 +415,10 @@
req,
res,
) => {
const start = moment(req.query.start);

Check warning on line 418 in src/applications/vaos/services/mocks/index.js

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/services/mocks/index.js:418:19:Consider using Native new Date().
const end = moment(req.query.end);

Check warning on line 419 in src/applications/vaos/services/mocks/index.js

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/services/mocks/index.js:419:17:Consider using Native new Date().
const slots = appointmentSlotsV2.data.filter(slot => {
const slotStartDate = moment(slot.attributes.start);

Check warning on line 421 in src/applications/vaos/services/mocks/index.js

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/services/mocks/index.js:421:29:Consider using Native new Date().
return slotStartDate.isBetween(start, end, '[]');
});
return res.json({
Expand Down Expand Up @@ -675,6 +675,12 @@
if (req.params.providerId === '3') {
return res.status(500).json({ error: true });
}
// Provider 0 has no available slots
if (req.params.providerId === '0') {
return res.json({
data: providerUtils.createProviderDetails(0, req.params.providerId),
});
}
return res.json({
data: providerUtils.createProviderDetails(5, req.params.providerId),
});
Expand Down
Loading