Skip to content

Commit

Permalink
Merge pull request #6207 from DilshanSenarath/template-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
pavinduLakshan authored May 8, 2024
2 parents 6af2f17 + 7ee6659 commit d38499f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-peas-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/features": patch
---

Fix the email template preview issues
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import React, {
useState
} from "react";
import { useSelector } from "react-redux";
import useGetBrandingPreference from "../../admin.branding.v1/api/use-get-branding-preference";
import { BrandingPreferencesConstants } from "../../admin.branding.v1/constants";
import useBrandingPreference from "../../admin.branding.v1/hooks/use-branding-preference";
import { BrandingPreferenceThemeInterface } from "../../admin.branding.v1/models";
import { BrandingPreferenceUtils } from "../../admin.branding.v1/utils";
import { AppState, store } from "../../admin.core.v1";
import { AppState } from "../../admin.core.v1";
import { EmailTemplate } from "../models";
import { EmailCustomizationUtils } from "../utils";

Expand All @@ -59,22 +58,17 @@ export const EmailTemplatePreview: FunctionComponent<EmailTemplatePreviewInterfa
["data-componentid"]: testId
} = props;

const { customText } = useBrandingPreference();
const { preference: brandingPreference, customText } = useBrandingPreference();

const [ , setIsIframeReady ] = useState(false);
const [
predefinedThemes,
setPredefinedThemes
] = useState<BrandingPreferenceThemeInterface>(BrandingPreferencesConstants.DEFAULT_PREFERENCE.theme);

const organizationName: string = store.getState().auth.tenantDomain;
const organizationName: string = useSelector((state: AppState) => state?.organization?.organization?.name);
const theme: string = useSelector((state: AppState) => state.config.ui.theme?.name);

const {
data: brandingPreference,
isLoading: isBrandingPreferenceLoading
} = useGetBrandingPreference(organizationName);

const emailTemplateBody: string = useMemo(() => {
if (emailTemplate?.body) {
return EmailCustomizationUtils.getTemplateBody(
Expand All @@ -91,7 +85,6 @@ export const EmailTemplatePreview: FunctionComponent<EmailTemplatePreviewInterfa
emailTemplate?.body,
organizationName,
brandingPreference?.preference,
isBrandingPreferenceLoading,
predefinedThemes
]);

Expand Down

0 comments on commit d38499f

Please sign in to comment.