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

Disable dark mode on the success page only for the organizer #3001

Merged
merged 19 commits into from Jun 8, 2022

Conversation

CarinaWolli
Copy link
Member

@CarinaWolli CarinaWolli commented Jun 7, 2022

What does this PR do?

Right now, dark mode is disabled on the success page for all logged-in users. This PR disables it only when a user is redirected to the success page after clicking on a booking to see the booking details.

Environment: Staging(main branch) / Production

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

  • Switch to dark mode
  • Book a meeting --> success page should be in dark mode now
  • Click on a booking to see booking details --> success page should be in light mode

Checklist

  • I haven't added tests that prove my fix is effective or that my feature works

@CarinaWolli CarinaWolli added 🐛 bug Something isn't working ♻️ autoupdate tells kodiak to keep this branch up-to-date labels Jun 7, 2022
@CarinaWolli CarinaWolli requested a review from PeerRich June 7, 2022 13:09
@vercel
Copy link

vercel bot commented Jun 7, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
cal ✅ Ready (Inspect) Visit Preview Jun 8, 2022 at 1:57PM (UTC)
3 Ignored Deployments
Name Status Preview Updated
docs ⬜️ Ignored (Inspect) Jun 8, 2022 at 1:57PM (UTC)
swagger ⬜️ Ignored (Inspect) Jun 8, 2022 at 1:57PM (UTC)
ui ⬜️ Ignored (Inspect) Jun 8, 2022 at 1:57PM (UTC)

@CarinaWolli CarinaWolli marked this pull request as draft June 7, 2022 13:12
@CarinaWolli CarinaWolli removed the request for review from PeerRich June 7, 2022 13:12
@@ -23,6 +24,7 @@ type BookingPage = inferQueryOutput<"viewer.bookings">;
export default function Bookings() {
const router = useRouter();
const status = router.query?.status as BookingListingStatus;
const { isReady, Theme } = useTheme("light");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed as otherwise, we have an issue with dark mode when we click on 'back to bookings' after booking an event

@@ -257,7 +257,7 @@ export default function Success(props: SuccessProps) {
return t("emailed_you_and_attendees" + titleSuffix);
}
const userIsOwner = !!(session?.user?.id && eventType.users.find((user) => (user.id = session.user.id)));
const { isReady, Theme } = useTheme(userIsOwner ? "light" : props.profile.theme);
const { isReady, Theme } = useTheme(listingStatus ? "light" : props.profile.theme);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disable dark mode when we click on a booking to see the booking details

Copy link
Contributor

@alannnc alannnc Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the original purpose of listingStatus? Probably we can use a new parameter that can tell us that we navigated from a booking list click and change the theme from there. Otherwise someone unintentionally can remove or change the behaviour of our listingStatus parameter and mess up our theme too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alannnc listingStatus is used for recurring events, to know if we should show all dates (when coming from the "upcoming" section) or only the specific date of the booking (when coming from "recurring"). I introduced a new parameter isSucessBookingPage that defines if user is redirected to the page after successfully booking an event (https://github.com/calcom/cal.com/pull/3001/files#r891948713)

Comment on lines 65 to 67
isReady && (
<Shell heading={t("bookings")} subtitle={t("bookings_description")} customLoader={<SkeletonLoader />}>
<Theme />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we handle this in the Shell itself? 🤔

Copy link
Contributor

@alannnc alannnc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks and works fine, just a comment about using a specific parameter to trigger light/dark theme.

@@ -166,6 +166,7 @@ const BookingPage = ({
location,
eventName: profile.eventName || "",
bookingId: id,
isSuccessBookingPage: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new parameter that defines if user is redirected to that page after successfully booking an event

Copy link
Contributor

@emrysal emrysal Jun 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what situations does this variable turn false?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emrysal always true when it comes from the booking page, but we also redirect to /success from bookingListItem to see the booking details. So it is here to check if we we redirected from the booking page or come from a bookingListItem

@@ -622,10 +622,15 @@ function RecurringBookings({
}: RecurringBookingsProps) {
const [moreEventsVisible, setMoreEventsVisible] = useState(false);
const { t } = useLocale();
return !isReschedule && recurringBookings && listingStatus === "upcoming" ? (

const recurringBookingsSorted = recurringBookings
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dates for recurring events currently aren't sorted

@CarinaWolli CarinaWolli merged commit abe5d53 into main Jun 8, 2022
@CarinaWolli CarinaWolli deleted the fix/dark-mode-success-page branch June 8, 2022 14:02
ee07b570 pushed a commit to ee07b570/cal.com that referenced this pull request Jun 14, 2022
…3001)

* disable darkmode only for organizer

* disable dark mode when user comes from user dashboard

* move Theme to shell

* fix build errors

* sort dates for recurring bookings

* new parameter if user comes from booking an event

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
@zomars zomars mentioned this pull request Jun 15, 2022
@PeerRich PeerRich added the core area: core, team members only label Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♻️ autoupdate tells kodiak to keep this branch up-to-date 🐛 bug Something isn't working core area: core, team members only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants