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

fix: use session status for initial appointment check #985

Merged
merged 4 commits into from
Jan 10, 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
6 changes: 5 additions & 1 deletion cypress/e2e/registration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe('registration', () => {
// `Uncaught ReferenceError: setVisitorCookieTimeout is not defined`
// and causes Cypress to fail the test.
// As this is outside of our control, we ignore this specific error for now.
// Update (2024-01-10): The page is now re-redirected to 'https://www.u25-deutschland.de/helpmail/'
cy.on('uncaught:exception', (error) => {
if (
error.message.includes(
Expand All @@ -92,7 +93,10 @@ describe('registration', () => {
});
cy.visit('/u25/registration');
cy.wait('@consultingTypeServiceBySlugFull');
cy.url().should('be.equal', 'https://www.u25.de/helpmail/');
cy.url().should(
'be.equal',
'https://www.u25-deutschland.de/helpmail/'
);
});

it('should have all generic registration page elements', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/fixtures/service.consultingtypes.u25.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"registrationDropdown": "Beratung für suizidgefährdete junge Menschen [U25]"
},
"urls": {
"requiredAidMissingRedirectUrl": "https://www.u25.de/helpmail/"
"requiredAidMissingRedirectUrl": "https://www.u25-deutschland.de/helpmail/"
},
"registration": {
"minPostcodeSize": 5,
Expand Down
6 changes: 4 additions & 2 deletions src/containers/bookings/components/Booking/booking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import { useContext, useEffect, useState } from 'react';
import {
ListItemInterface,
STATUS_EMPTY,
UserDataContext,
UserDataInterface
} from '../../../../globalState';
Expand Down Expand Up @@ -45,6 +46,8 @@ export const Booking = () => {
});
}, [userData]);

if (!session) return null;

return (
<React.Fragment>
{appointmentLink && settings.calcomUrl && (
Expand All @@ -58,8 +61,7 @@ export const Booking = () => {
'metadata[user]': userData.userId,
'metadata[isInitialAppointment]':
!session.consultant ||
new Date(session.latestMessage).getTime() <
new Date(session.session.createDate).getTime(),
session.session.status === STATUS_EMPTY,
'metadata[sessionId]': session.session.id,
'metadata[rcToken]': getValueFromCookie('rc_token'),
'metadata[rcUserId]': getValueFromCookie('rc_uid'),
Expand Down
Loading