Compare commits
No commits in common. '520dd137d8cd611e4fb930df64992534f727d9f8' and 'cf174db0147a240566a84f51182f155b654a6042' have entirely different histories.
520dd137d8
...
cf174db014
@ -0,0 +1,12 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
export const submitContactFormAction = (formData: FormData) => {
|
||||||
|
console.log(JSON.stringify(formData, null, 2));
|
||||||
|
console.log(formData.get("message"));
|
||||||
|
console.log(formData.get("subject"));
|
||||||
|
console.log(formData.get("date"));
|
||||||
|
console.log(formData.get("time"));
|
||||||
|
console.log(formData.get("name"));
|
||||||
|
console.log(formData.get("email"));
|
||||||
|
console.log(formData.get("phone"));
|
||||||
|
};
|
@ -1,53 +0,0 @@
|
|||||||
"use server";
|
|
||||||
|
|
||||||
import { getI18n } from "@/i18n/server";
|
|
||||||
import { getPayload } from "@/utils/payload";
|
|
||||||
import { getSettings } from "@/api";
|
|
||||||
import { renderContactConfirmationEmail } from "@/emails/contact-confirmation";
|
|
||||||
import { renderContactEmail } from "@/emails/contact";
|
|
||||||
|
|
||||||
export const submitContactFormAction = async (formData: FormData) => {
|
|
||||||
const payload = await getPayload();
|
|
||||||
const { adminLanguage, contactEmailsTo } = await getSettings();
|
|
||||||
const t = await getI18n();
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
await renderContactEmail(
|
|
||||||
{
|
|
||||||
name: formData.get("name"),
|
|
||||||
email: formData.get("email"),
|
|
||||||
subject: formData.get("subject"),
|
|
||||||
message: formData.get("message"),
|
|
||||||
locale: adminLanguage,
|
|
||||||
},
|
|
||||||
{ plainText: true },
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
await payload.sendEmail({
|
|
||||||
to: contactEmailsTo,
|
|
||||||
subject: t("email.contactSubject", { name: formData.get("name") }),
|
|
||||||
email: await renderContactEmail(
|
|
||||||
{
|
|
||||||
name: formData.get("name"),
|
|
||||||
email: formData.get("email"),
|
|
||||||
subject: formData.get("subject"),
|
|
||||||
message: formData.get("message"),
|
|
||||||
locale: adminLanguage,
|
|
||||||
},
|
|
||||||
{ plainText: true },
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
await payload.sendEmail({
|
|
||||||
to: formData.get("email"),
|
|
||||||
subject: `Bestätigung Ihrer Kontaktanfrage ${formData.get("name")}`,
|
|
||||||
email: await renderContactConfirmationEmail({
|
|
||||||
name: formData.get("name"),
|
|
||||||
email: formData.get("email"),
|
|
||||||
subject: formData.get("subject"),
|
|
||||||
message: formData.get("message"),
|
|
||||||
locale: adminLanguage,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
};
|
|
@ -0,0 +1,12 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
export const submitReservationFormAction = (formData: FormData) => {
|
||||||
|
console.log(JSON.stringify(formData, null, 2));
|
||||||
|
console.log(formData.get("message"));
|
||||||
|
console.log(formData.get("subject"));
|
||||||
|
console.log(formData.get("date"));
|
||||||
|
console.log(formData.get("time"));
|
||||||
|
console.log(formData.get("name"));
|
||||||
|
console.log(formData.get("email"));
|
||||||
|
console.log(formData.get("phone"));
|
||||||
|
};
|
@ -1,22 +0,0 @@
|
|||||||
"use server";
|
|
||||||
|
|
||||||
import { getPayload } from "@/utils/payload";
|
|
||||||
|
|
||||||
export const submitReservationFormAction = async (formData: FormData) => {
|
|
||||||
const payload = await getPayload();
|
|
||||||
await payload.sendEmail({
|
|
||||||
to: "moravrav@gmail.com",
|
|
||||||
subject: `Reservation von ${formData.get("name")}`,
|
|
||||||
text: `Sie haben eine Reservation von ${formData.get("name")} erhalten:
|
|
||||||
|
|
||||||
Datum / Uhrzeit: ${formData.get("date")} / ${formData.get("date")}
|
|
||||||
Gäste: ${formData.get("guests")}
|
|
||||||
|
|
||||||
Nachricht: ${formData.get("message")}
|
|
||||||
|
|
||||||
Kontaktdaten:
|
|
||||||
- E-Mail: ${formData.get("email")}
|
|
||||||
- Telefonnummer: ${formData.get("phone")}
|
|
||||||
`,
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,7 +0,0 @@
|
|||||||
import type { Options } from "node_modules/payload/dist/globals/operations/local/findOne";
|
|
||||||
import { getPayload } from "@/utils/payload";
|
|
||||||
|
|
||||||
export const getSettings = async (opts: Omit<Options<"settings">, "slug"> = {}) => {
|
|
||||||
const payload = await getPayload();
|
|
||||||
return await payload.findGlobal({ slug: "settings", ...opts });
|
|
||||||
};
|
|
@ -1,60 +0,0 @@
|
|||||||
import { Font, Head, Html, Preview, Tailwind, Text } from "@react-email/components";
|
|
||||||
import { I18nProviderClient, useI18n } from "@/i18n/client";
|
|
||||||
import { Options, render } from "@react-email/render";
|
|
||||||
|
|
||||||
import { defaultLocale } from "@/i18n/settings";
|
|
||||||
|
|
||||||
type ContactConfirmationEmailContentProps = {
|
|
||||||
name: string;
|
|
||||||
email: string;
|
|
||||||
subject: string;
|
|
||||||
message: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
function ContactConfirmationEmailContent(_props: ContactConfirmationEmailContentProps) {
|
|
||||||
const t = useI18n();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Html>
|
|
||||||
<Head>
|
|
||||||
<title>{t("email.contactConfirmationSubject")}</title>
|
|
||||||
<Font
|
|
||||||
fontFamily="Roboto"
|
|
||||||
fallbackFontFamily="Verdana"
|
|
||||||
webFont={{
|
|
||||||
url: "https://fonts.googleapis.com/css2?family=Moderustic:wght@300..800&display=swap",
|
|
||||||
format: "woff2",
|
|
||||||
}}
|
|
||||||
fontWeight={400}
|
|
||||||
fontStyle="normal"
|
|
||||||
/>
|
|
||||||
</Head>
|
|
||||||
<Preview>{t("email.contactConfirmationSubject")}</Preview>
|
|
||||||
<Tailwind>
|
|
||||||
<Text>{t("email.contactConfirmationText")}</Text>
|
|
||||||
</Tailwind>
|
|
||||||
</Html>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
type ContactConfirmationEmailProps = {
|
|
||||||
locale: string;
|
|
||||||
} & ContactConfirmationEmailContentProps;
|
|
||||||
|
|
||||||
export default function ContactConfirmationEmail({
|
|
||||||
locale = defaultLocale,
|
|
||||||
...props
|
|
||||||
}: ContactConfirmationEmailProps) {
|
|
||||||
return (
|
|
||||||
<I18nProviderClient locale={locale}>
|
|
||||||
<ContactConfirmationEmailContent {...props} />
|
|
||||||
</I18nProviderClient>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function renderContactConfirmationEmail(
|
|
||||||
props: ContactConfirmationEmailProps,
|
|
||||||
opts?: Options,
|
|
||||||
) {
|
|
||||||
return await render(<ContactConfirmationEmail {...props} />, opts);
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
import {
|
|
||||||
Column,
|
|
||||||
Font,
|
|
||||||
Head,
|
|
||||||
Html,
|
|
||||||
Preview,
|
|
||||||
Row,
|
|
||||||
Section,
|
|
||||||
Tailwind,
|
|
||||||
Text,
|
|
||||||
} from "@react-email/components";
|
|
||||||
import { I18nProviderClient, useI18n } from "@/i18n/client";
|
|
||||||
import { Options, render } from "@react-email/render";
|
|
||||||
|
|
||||||
import { defaultLocale } from "@/i18n/settings";
|
|
||||||
|
|
||||||
type ContactEmailContentProps = { name: string; email: string; subject: string; message: string };
|
|
||||||
|
|
||||||
function ContactEmailContent({
|
|
||||||
name = "[[Name]]",
|
|
||||||
subject = "[[Subject]]",
|
|
||||||
email = "[[Email]]",
|
|
||||||
message = "[[Message]]",
|
|
||||||
}: ContactEmailContentProps) {
|
|
||||||
const t = useI18n();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Html>
|
|
||||||
<Head>
|
|
||||||
<title>{t("email.contactSubject", { name })}</title>
|
|
||||||
<Font
|
|
||||||
fontFamily="Roboto"
|
|
||||||
fallbackFontFamily="Verdana"
|
|
||||||
webFont={{
|
|
||||||
url: "https://fonts.googleapis.com/css2?family=Moderustic:wght@300..800&display=swap",
|
|
||||||
format: "woff2",
|
|
||||||
}}
|
|
||||||
fontWeight={400}
|
|
||||||
fontStyle="normal"
|
|
||||||
/>
|
|
||||||
</Head>
|
|
||||||
<Preview>{t("email.contactSubject", { name })}</Preview>
|
|
||||||
<Tailwind>
|
|
||||||
<Text>{t("email.contactTitle", { name })}</Text>
|
|
||||||
<Text>{subject}</Text>
|
|
||||||
<Section>
|
|
||||||
<Row>
|
|
||||||
<Column>{t("contact.name")}</Column>
|
|
||||||
<Column>{name}</Column>
|
|
||||||
</Row>
|
|
||||||
<Row>
|
|
||||||
<Column>{t("general.email")}</Column>
|
|
||||||
<Column>{email}</Column>
|
|
||||||
</Row>
|
|
||||||
</Section>
|
|
||||||
<Text>{t("contact.message")}</Text>
|
|
||||||
<Text>{message}</Text>
|
|
||||||
</Tailwind>
|
|
||||||
</Html>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
type ContactEmailProps = { locale: string } & ContactEmailContentProps;
|
|
||||||
|
|
||||||
export default function ContactEmail({ locale = defaultLocale, ...props }: ContactEmailProps) {
|
|
||||||
return (
|
|
||||||
<I18nProviderClient locale={locale}>
|
|
||||||
<ContactEmailContent {...props} />
|
|
||||||
</I18nProviderClient>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function renderContactEmail(props: ContactEmailProps, opts?: Options) {
|
|
||||||
return await render(<ContactEmail {...props} />, opts);
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
import { defaultLocale, locales } from "@/i18n/settings";
|
|
||||||
|
|
||||||
import type { GlobalConfig } from "payload";
|
|
||||||
|
|
||||||
export const Settings: GlobalConfig = {
|
|
||||||
slug: "settings",
|
|
||||||
access: {},
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
name: "adminLanguage",
|
|
||||||
type: "select",
|
|
||||||
options: locales.map((l) => ({
|
|
||||||
value: l.code,
|
|
||||||
label: l.label[l.code] ?? l.label[defaultLocale],
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "contactEmailsTo",
|
|
||||||
type: "email",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
@ -1,7 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { createI18nClient } from "next-international/client";
|
import { createI18nClient } from "next-international/client";
|
||||||
import { importedLocales } from "./settings";
|
|
||||||
|
|
||||||
export const { useI18n, useScopedI18n, I18nProviderClient, useChangeLocale, useCurrentLocale } =
|
export const { useI18n, useScopedI18n, I18nProviderClient, useChangeLocale, useCurrentLocale } =
|
||||||
createI18nClient(importedLocales);
|
createI18nClient({
|
||||||
|
de: () => import("./de"),
|
||||||
|
en: () => import("./en"),
|
||||||
|
});
|
||||||
|
@ -1 +0,0 @@
|
|||||||
export default {} as const;
|
|
@ -1 +0,0 @@
|
|||||||
export default {} as const;
|
|
@ -1,5 +1,6 @@
|
|||||||
import { createI18nServer } from "next-international/server";
|
import { createI18nServer } from "next-international/server";
|
||||||
import { importedLocales } from "./settings";
|
|
||||||
|
|
||||||
export const { getI18n, getScopedI18n, getStaticParams, getCurrentLocale } =
|
export const { getI18n, getScopedI18n, getStaticParams } = createI18nServer({
|
||||||
createI18nServer(importedLocales);
|
de: () => import("./de"),
|
||||||
|
en: () => import("./en"),
|
||||||
|
});
|
||||||
|
@ -1,49 +1,4 @@
|
|||||||
export const locales = [
|
export const defaultLocale = "de" as const;
|
||||||
{
|
export const locales = [defaultLocale, "en"] as const;
|
||||||
label: {
|
|
||||||
de: "Deutsch",
|
|
||||||
en: "German",
|
|
||||||
fr: "Allemand",
|
|
||||||
it: "Tedesco",
|
|
||||||
},
|
|
||||||
code: "de",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: {
|
|
||||||
fr: "Français",
|
|
||||||
en: "French",
|
|
||||||
de: "Französisch",
|
|
||||||
it: "Francese",
|
|
||||||
},
|
|
||||||
code: "fr",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: {
|
|
||||||
it: "Italiano",
|
|
||||||
de: "Italienisch",
|
|
||||||
en: "Italian",
|
|
||||||
fr: "Italien",
|
|
||||||
},
|
|
||||||
code: "it",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: {
|
|
||||||
de: "Englisch",
|
|
||||||
en: "English",
|
|
||||||
it: "Inglese",
|
|
||||||
fr: "Anglais",
|
|
||||||
},
|
|
||||||
code: "en",
|
|
||||||
},
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export type Locale = (typeof locales)[number]["code"];
|
export type Locale = (typeof locales)[number];
|
||||||
|
|
||||||
export const defaultLocale: Locale = "de";
|
|
||||||
|
|
||||||
export const importedLocales = {
|
|
||||||
de: () => import("./de"),
|
|
||||||
en: () => import("./en"),
|
|
||||||
it: () => import("./it"),
|
|
||||||
fr: () => import("./fr"),
|
|
||||||
} as const;
|
|
||||||
|
Loading…
Reference in New Issue