77 lines
3.0 KiB
TypeScript
77 lines
3.0 KiB
TypeScript
import { LoaderFunctionArgs, MetaFunction } from "react-router";
|
|
import { Outlet, useParams } from "react-router";
|
|
import { useTranslation } from "react-i18next";
|
|
import ServerError from "~/components/ui/errors/ServerError";
|
|
import IncreaseIcon from "~/components/ui/icons/crm/IncreaseIcon";
|
|
import IncreaseIconFilled from "~/components/ui/icons/crm/IncreaseIconFilled";
|
|
import MegaphoneIcon from "~/components/ui/icons/emails/MegaphoneIcon";
|
|
import MegaphoneIconFilled from "~/components/ui/icons/emails/MegaphoneIconFilled";
|
|
import SentIcon from "~/components/ui/icons/emails/SentIcon";
|
|
import SentIconFilled from "~/components/ui/icons/emails/SentIconFilled";
|
|
import ActivityHistoryIcon from "~/components/ui/icons/entities/ActivityHistoryIcon";
|
|
import ActivityHistoryIconFilled from "~/components/ui/icons/entities/ActivityHistoryIconFilled";
|
|
import SidebarIconsLayout from "~/components/ui/layouts/SidebarIconsLayout";
|
|
import { getTranslations } from "~/locale/i18next.server";
|
|
import CrmService from "~/modules/crm/services/CrmService";
|
|
import UrlUtils from "~/utils/app/UrlUtils";
|
|
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
|
|
|
type LoaderData = {
|
|
title: string;
|
|
};
|
|
|
|
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
|
const { t } = await getTranslations(request);
|
|
const data: LoaderData = {
|
|
title: `${t("emailMarketing:title")} | ${process.env.APP_NAME}`,
|
|
};
|
|
const tenantId = await getTenantIdOrNull({ request, params });
|
|
await CrmService.validate(tenantId);
|
|
return data;
|
|
};
|
|
|
|
export const meta: MetaFunction<typeof loader> = ({ data }) => [{ title: data?.title }];
|
|
|
|
export default () => {
|
|
const { t } = useTranslation();
|
|
const params = useParams();
|
|
return (
|
|
<SidebarIconsLayout
|
|
label={{ align: "right" }}
|
|
items={[
|
|
{
|
|
name: t("shared.overview"),
|
|
href: UrlUtils.getModulePath(params, "email-marketing"),
|
|
exact: true,
|
|
icon: <IncreaseIcon className="h-5 w-5" />,
|
|
iconSelected: <IncreaseIconFilled className="h-5 w-5" />,
|
|
},
|
|
{
|
|
name: t("emailMarketing:campaigns"),
|
|
href: UrlUtils.getModulePath(params, "email-marketing/campaigns"),
|
|
icon: <MegaphoneIcon className="h-5 w-5" />,
|
|
iconSelected: <MegaphoneIconFilled className="h-5 w-5" />,
|
|
},
|
|
{
|
|
name: t("emailMarketing:activity"),
|
|
href: UrlUtils.getModulePath(params, "email-marketing/activity"),
|
|
icon: <ActivityHistoryIcon className="h-5 w-5" />,
|
|
iconSelected: <ActivityHistoryIconFilled className="h-5 w-5" />,
|
|
},
|
|
{
|
|
name: t("emailMarketing:senders.plural"),
|
|
href: UrlUtils.getModulePath(params, "email-marketing/senders"),
|
|
icon: <SentIcon className="h-5 w-5" />,
|
|
iconSelected: <SentIconFilled className="h-5 w-5" />,
|
|
},
|
|
]}
|
|
>
|
|
<Outlet />
|
|
</SidebarIconsLayout>
|
|
);
|
|
};
|
|
|
|
export function ErrorBoundary() {
|
|
return <ServerError />;
|
|
}
|