Skip to content
Open
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
7 changes: 6 additions & 1 deletion app/admin/components/admin-page-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ export function AdminPageHeader({
title,
description,
variant = "page",
actions,
footer,
}: {
title: string;
description?: string;
variant?: "page" | "workspace";
actions?: ReactNode;
footer?: ReactNode;
}) {
const classes = adminPageHeaderClasses(variant);
Expand All @@ -29,7 +31,10 @@ export function AdminPageHeader({
</p>
) : null}
</div>
<AdminHeaderActions />
<div className="flex shrink-0 flex-wrap items-center justify-end gap-2">
{actions}
<AdminHeaderActions />
</div>
</div>
{footer}
</header>
Expand Down
8 changes: 6 additions & 2 deletions app/admin/components/admin-page-shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ export function AdminPageShell({
width = "wide",
}: {
children: ReactNode;
width?: "wide" | "narrow";
width?: "wide" | "narrow" | "full";
}) {
return (
<main className="min-h-screen bg-background px-4 py-5 text-foreground md:px-6">
<div
className={cn(
"mx-auto flex flex-col gap-5",
width === "narrow" ? "max-w-3xl" : "max-w-7xl",
width === "narrow"
? "max-w-3xl"
: width === "full"
? "max-w-none"
: "max-w-7xl",
)}
>
{children}
Expand Down
42 changes: 42 additions & 0 deletions app/admin/email-campaigns/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"use server";

import { revalidatePath } from "next/cache";
import {
createMasterTemplate,
deleteMasterTemplate,
saveActiveTheme,
updateMasterTemplate,
} from "@/lib/email/templates/master-service";
import {
emailTemplateUpsertSchema,
emailThemeTokensSchema,
type EmailTemplateUpsertInput,
type EmailThemeTokens,
} from "@/lib/email/types";

const emailCampaignsPath = "/admin/email-campaigns";

export async function saveEmailTemplateAction(input: {
templateId?: string;
template: EmailTemplateUpsertInput;
}) {
const payload = emailTemplateUpsertSchema.parse(input.template);
const template = input.templateId
? await updateMasterTemplate(input.templateId, payload)
: await createMasterTemplate(payload);

revalidatePath(emailCampaignsPath);
return template;
}

export async function deleteEmailTemplateAction(templateId: string) {
await deleteMasterTemplate(templateId);
revalidatePath(emailCampaignsPath);
return { success: true };
}

export async function saveEmailThemeAction(input: EmailThemeTokens) {
const theme = await saveActiveTheme(emailThemeTokensSchema.parse(input));
revalidatePath(emailCampaignsPath);
return theme;
}
Loading
Loading