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

Refactor/restructure email templates #687

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7d5377b
feat: completed welcome template
kinxlo Jul 24, 2024
a12a81a
feat: modified welcome template
kinxlo Jul 24, 2024
f904978
feat: modified welcome template
kinxlo Jul 24, 2024
2a2d03c
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 24, 2024
b76d3ae
feat: completed subscription template
kinxlo Jul 25, 2024
1b013d4
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 25, 2024
508bd88
feat: completed forgot password template
kinxlo Jul 25, 2024
950df81
feat: completed forgot password template
kinxlo Jul 25, 2024
8ef748d
feat: completed email verification template
kinxlo Jul 25, 2024
b6aaa39
feat: completed email confirmation template
kinxlo Jul 25, 2024
4992ac9
fix: fixed new features layout template
kinxlo Jul 25, 2024
3c94f46
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 25, 2024
e139a56
fix: fixed all layout template
kinxlo Jul 25, 2024
517a1eb
feat: completed activate your account template
kinxlo Jul 25, 2024
90f3ae5
feat: completed activate activation successful template
kinxlo Jul 25, 2024
6f297ac
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 25, 2024
b53e4d5
feat: completed activation link expired template
kinxlo Jul 25, 2024
61709b9
feat: completed activation due to inactivity template
kinxlo Jul 25, 2024
ff71cd9
feat: completed activation deactivation successful template
kinxlo Jul 25, 2024
856927f
feat: completed newsletter template
kinxlo Jul 25, 2024
573288d
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 25, 2024
02deb71
feat: completed newsletter template
kinxlo Jul 25, 2024
b9a8e6b
feat: completed Subscription cancellation template
kinxlo Jul 25, 2024
5fc0058
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 25, 2024
a3583a9
feat: completed Subscription cancellation template
kinxlo Jul 26, 2024
30bec1a
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 26, 2024
9b79bb6
feat: completed Subscription renewal template
kinxlo Jul 26, 2024
d65e5dc
feat: completed Subscription renewal failed template
kinxlo Jul 26, 2024
3f3cf17
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 26, 2024
3ec80ef
fix: resolved template viewer scroll issues
kinxlo Jul 26, 2024
30a8323
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 26, 2024
720ff82
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 26, 2024
046645c
Merge branch 'clean' of https://github.com/hngprojects/hng_boilerplat…
kinxlo Jul 26, 2024
220af5f
fix: resolved template viewer scroll issues
kinxlo Jul 26, 2024
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
@@ -1,8 +1,12 @@
const PreviewCard = () => {
// @kinxlo IS CURRENTLY WORKING ON THIS FIX 👍.
return (
<div className="h-full min-h-[700px] w-full max-w-[447px] rounded-[19px] border-[1px] border-border bg-background p-5 transition-all duration-300">
<div className="h-full w-full rounded-[7px] border-[1px] border-border bg-white p-4">
<div className="h-full w-full rounded-[7px] border-[1px] border-border"></div>
<div className="h-full w-full rounded-[7px] border-[1px] border-border">
hi guys, @Guy in A Chair is currently working on this component
responsivess 👍
</div>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const GenerateField = () => {
isButtonVisible={true}
buttonContent="Generate"
onButtonClick={() =>
router.push(
"/dashboard/admin/email/generate-with-html/preview-template",
)
router.push("/admin/email/generate-with-html/preview-template")
}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import React, { useEffect, useRef, useState } from "react";
import { usePathname } from "next/navigation";
import React, { ReactNode, useEffect, useRef, useState } from "react";

interface PreviewComponentProperties {
template?: string;
template?: string | ReactNode;
mode?: "preview" | "edit";
onEdit?: (content: string) => void;
}

const TemplateViewer: React.FC<PreviewComponentProperties> = ({
template = "",
template,
mode = "preview",
onEdit,
}) => {
const [content, setContent] = useState<string>(template);
const [content, setContent] = useState<string>(template as string);
const contentReference = useRef<HTMLTextAreaElement>(null);
const pathname = usePathname();

useEffect(() => {
setContent(template);
if (typeof template === "string") {
setContent(template);
}
}, [template]);

useEffect(() => {
Expand All @@ -28,8 +32,10 @@ const TemplateViewer: React.FC<PreviewComponentProperties> = ({
event: React.ChangeEvent<HTMLTextAreaElement>,
) => {
const newContent = event.target.value;
setContent(newContent);
onEdit?.(newContent);
if (newContent !== content) {
setContent(newContent);
onEdit?.(newContent);
}
};

return (
Expand All @@ -41,7 +47,7 @@ const TemplateViewer: React.FC<PreviewComponentProperties> = ({
data-testid="scroll-container"
className="relative overflow-y-auto rounded-lg lg:max-h-[719px]"
>
<div className="flex w-[98%] items-center justify-center overflow-auto rounded-lg border border-[#CBD5E1] bg-white p-[1rem] lg:p-[3rem]">
<div className="flex w-[98%] items-center justify-center overflow-auto rounded-lg border border-[#CBD5E1] bg-white p-[1rem]">
{mode === "edit" ? (
<textarea
style={{ scrollbarWidth: "none" }}
Expand All @@ -53,10 +59,16 @@ const TemplateViewer: React.FC<PreviewComponentProperties> = ({
/>
) : (
<div
data-testid="template-content"
dangerouslySetInnerHTML={{ __html: content }}
className="h-full w-fit"
/>
className={
pathname?.includes("preview-template") ? `my-[48px]` : undefined
}
>
<div
data-testid="template-content"
dangerouslySetInnerHTML={{ __html: content }}
className="h-full w-fit"
/>
</div>
)}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
"use client";

import { useState } from "react";
import { renderToString } from "react-dom/server";

import { Button } from "~/components/common/common-button";
import AccountActivationSuccessful from "~/email/templates/account-activation-successful/image";
import PageHeader from "../../../_components/page-header";
import { templateOne } from "./template-example";
import TemplateViewer from "./TemplateViewer";

const HtmlTemplateViewer = () => {
const [template, setTemplate] = useState<string>(templateOne);
// Define the props for the component
const previewProperties = {
title: "Your Account is Now Active!",
username: "John Doe",
image: "https://imgur.com/3Yymb22.png",
link: "/",
description:
"Congratulations! Your account with Boilerplate is now active and ready to use.",
descriptionOne:
"We're thrilled to have you as part of our community and look forward to helping you make the most out of your experience with us.",
descriptionTwo:
"You can now log in and start exploring all the features and benefits we have to offer. ",
};

// Convert the React component to a string with the props
// eslint-disable-next-line testing-library/render-result-naming-convention
const welcomeEmailString = renderToString(
<AccountActivationSuccessful {...previewProperties} />,
);

const [template, setTemplate] = useState<string>(welcomeEmailString);
const [mode, setMode] = useState<"preview" | "edit">("preview");

const toggleMode = () => {
Expand Down
Loading