Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+25
-21
@@ -6,8 +6,8 @@
|
||||
* before inserting so the row is always renderable by the trigger
|
||||
* handler.
|
||||
*/
|
||||
import { Form, Link, redirect, useActionData, type ActionFunctionArgs, type LoaderFunctionArgs } from "react-router";
|
||||
import { t as i18nT } from "i18next";
|
||||
import { Form, Link, redirect, useActionData, useLoaderData, type ActionFunctionArgs, type LoaderFunctionArgs } from "react-router";
|
||||
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { db } from "~/utils/db.server";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
@@ -15,23 +15,24 @@ import { getTranslations } from "~/locale/i18next.server";
|
||||
|
||||
type ActionResponse = { ok: true } | { ok: false; error: string };
|
||||
|
||||
const DEFAULT_STEPS = JSON.stringify(
|
||||
[
|
||||
{
|
||||
stepIndex: 0,
|
||||
delayHours: 0,
|
||||
template: "welcome",
|
||||
subject: i18nT("admin.emailSequences.defaults.welcomeSubject"),
|
||||
variables: { productName: "HiveGrid" },
|
||||
},
|
||||
],
|
||||
null,
|
||||
2
|
||||
);
|
||||
|
||||
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
await verifyUserHasPermission(request, "admin.marketing.leads.view");
|
||||
return Response.json({});
|
||||
const { t } = await getTranslations(request);
|
||||
const productName = process.env.APP_NAME ?? "HiveGrid";
|
||||
const defaultSteps = JSON.stringify(
|
||||
[
|
||||
{
|
||||
stepIndex: 0,
|
||||
delayHours: 0,
|
||||
template: "welcome",
|
||||
subject: t("admin.emailSequences.defaults.welcomeSubject", { productName }),
|
||||
variables: { productName },
|
||||
},
|
||||
],
|
||||
null,
|
||||
2
|
||||
);
|
||||
return Response.json({ defaultSteps });
|
||||
};
|
||||
|
||||
export const action = async ({ request }: ActionFunctionArgs) => {
|
||||
@@ -54,10 +55,10 @@ export const action = async ({ request }: ActionFunctionArgs) => {
|
||||
const { parseSequenceSteps } = await import("@hivegrid/email-sequences");
|
||||
try {
|
||||
parseSequenceSteps(stepsJson);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return Response.json({
|
||||
ok: false,
|
||||
error: error instanceof Error ? error.message : t("admin.emailSequences.errors.stepsJsonValidationFailed"),
|
||||
error: t("admin.emailSequences.errors.stepsJsonValidationFailed"),
|
||||
} satisfies ActionResponse);
|
||||
}
|
||||
let conditionsJson: unknown = null;
|
||||
@@ -78,10 +79,13 @@ export const action = async ({ request }: ActionFunctionArgs) => {
|
||||
isEnabled: false,
|
||||
},
|
||||
});
|
||||
return redirect(`${adminPath("email-sequences", { mode: "host-aware" })}/${created.id}`);
|
||||
return redirect(
|
||||
`${adminPath("email-sequences", { mode: "host-aware" })}/${created.id}?toast=${encodeURIComponent("admin.emailSequences.toast.created")}`
|
||||
);
|
||||
};
|
||||
|
||||
export default function EmailSequenceNew() {
|
||||
const { defaultSteps } = useLoaderData<typeof loader>();
|
||||
const action = useActionData<ActionResponse>();
|
||||
return (
|
||||
<div className="mx-auto mb-12 max-w-5xl space-y-5 px-4 py-4 sm:px-6 lg:px-8">
|
||||
@@ -126,7 +130,7 @@ export default function EmailSequenceNew() {
|
||||
<textarea
|
||||
id="stepsJson"
|
||||
name="stepsJson"
|
||||
defaultValue={DEFAULT_STEPS}
|
||||
defaultValue={defaultSteps}
|
||||
rows={14}
|
||||
spellCheck={false}
|
||||
className="border-border w-full rounded-md border px-3 py-1.5 font-mono text-xs"
|
||||
|
||||
Reference in new issue
Block a user