fix: Embed theme not working using Embed API (#10163)

## What does this PR do?

Fixes #10187
See [Tests Done](https://www.loom.com/share/f03e0191b60143d8b45a505042dbfa11)

## Type of change
  - [x] Bug fix (non-breaking change which fixes an issue)

## How should this be tested?
- [x] Configure embed to use `dark` theme and verify that dark theme is shown on event booking page(when user has light theme set). This is failing in main
- Additional Tests for embed to avoid any new regression
	- [x] - Configure "auto" theme using embed API and see it reacts to system theme
	- [x] - Don't configure any theme and see that "light" theme is shown even when we switch system theme(Because User has configured light theme in App)
-  Tests outside embed to avoid any new regression
	- [x] - See that light theme is shown even after switching system theme
	- [x] - Now, switch the user theme to dark and see that it reflects the change. 

## Mandatory Tasks

 [x] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
This commit is contained in:
Hariom Balhara authored and GitHub committed 2023-07-17 18:02:42 -07:00
1 parent 2db4998eaa
commit 6dfc19247e
13 files changed
+173 -82

No files matched your search

+1
View File
@@ -40,6 +40,7 @@ export default function Type({ slug, user, booking, away, isBrandingHidden, resc
);
}
Type.isBookingPage = true;
Type.PageWrapper = PageWrapper;
async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {
+1 -1
View File
@@ -278,7 +278,7 @@ export default function Success(props: SuccessProps) {
// This is a weird case where the same route can be opened in booking flow as a success page or as a booking detail page from the app
// As Booking Page it has to support configured theme, but as booking detail page it should not do any change. Let Shell.tsx handle it.
useTheme(isSuccessBookingPage ? props.profile.theme : undefined);
useTheme(isSuccessBookingPage ? props.profile.theme : "system");
useBrandColors({
brandColor: props.profile.brandColor,
darkBrandColor: props.profile.darkBrandColor,
+1
View File
@@ -39,6 +39,7 @@ export default function Type({ slug, user, booking, away, isBrandingHidden, isTe
}
Type.PageWrapper = PageWrapper;
Type.isBookingPage = true;
async function getUserPageProps(context: GetServerSidePropsContext) {
const { link, slug } = paramsSchema.parse(context.params);
@@ -60,3 +60,4 @@ export default function Page(props: Props) {
}
Page.PageWrapper = PageWrapper;
Page.isBookingPage = true;
@@ -37,4 +37,5 @@ export default function Page(props: Props) {
return <UserPage {...(props as UserPageProps)} />;
}
Page.isBookingPage = true;
Page.PageWrapper = PageWrapper;
+1
View File
@@ -42,6 +42,7 @@ export default function Type({ slug, user, booking, away, isBrandingHidden, org
}
Type.PageWrapper = PageWrapper;
Type.isBookingPage = true;
const paramsSchema = z.object({
type: z.string().transform((s) => slugify(s)),