Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -1,9 +1,5 @@
|
||||
import Logo from "~/components/brand/Logo";
|
||||
import ErrorModal, { RefErrorModal } from "~/components/ui/modals/ErrorModal";
|
||||
import UserValidationUtils from "~/utils/app/UserValidationUtils";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, Form, useActionData, useLoaderData } from "react-router";
|
||||
import { useActionData, useLoaderData } from "react-router";
|
||||
import { ActionFunction, LoaderFunctionArgs, MetaFunction } from "react-router";
|
||||
import { withMetrics } from "~/lib/metrics/ssr";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
@@ -11,21 +7,20 @@ import { getUser, getUserByEmail, register } from "~/utils/db/users.db.server";
|
||||
import { queueTransactionalEmail } from "~/modules/emails/services/TransactionalEmailQueue.server";
|
||||
import { createTenantUser, getTenant } from "~/utils/db/tenants.db.server";
|
||||
import { createUserSession, getUserInfo, setLoggedUser } from "~/utils/session.server";
|
||||
import type { Tenant, User } from "@toolctrl/db/prisma-browser";
|
||||
import type { Tenant, User } from "@hivegrid/db/prisma-browser";
|
||||
import { getAllRoles } from "~/utils/db/permissions/roles.db.server";
|
||||
import { TenantUserType } from "~/application/enums/tenants/TenantUserType";
|
||||
import { getAbsoluteUrl } from "~/utils/url.server";
|
||||
import EventsService from "~/modules/events/services/.server/EventsService";
|
||||
import { MemberInvitationAcceptedDto } from "~/modules/events/dtos/MemberInvitationAcceptedDto";
|
||||
import SuccessBanner from "~/components/ui/banners/SuccessBanner";
|
||||
import { Button } from "~/components/ui/button";
|
||||
import SetPasswordScreen from "~/modules/users/components/SetPasswordScreen";
|
||||
import EmailTemplates from "~/modules/emails/utils/EmailTemplates";
|
||||
import { getMailTranslator } from "~/locale/mail-translator.server";
|
||||
import { getAppConfiguration } from "~/utils/db/appConfiguration.db.server";
|
||||
import { appPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { loadRequiredWebConfig } from "@toolctrl/config";
|
||||
import { loadRequiredWebConfig } from "@hivegrid/config";
|
||||
import { absoluteAppRootPath } from "~/utils/app/CrossHostUrls";
|
||||
import { acceptWorkspaceInvite, getWorkspaceInviteByToken, WorkspaceInviteDto, WorkspaceInviteError } from "@toolctrl/db/workspace-invites.server";
|
||||
import { acceptWorkspaceInvite, getWorkspaceInviteByToken, WorkspaceInviteDto, WorkspaceInviteError } from "@hivegrid/db/workspace-invites.server";
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
@@ -231,143 +226,7 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => [{ title: data?.t
|
||||
export default function InvitationRoute() {
|
||||
const data = useLoaderData<LoaderData>();
|
||||
const actionData = useActionData<ActionData>();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const errorModal = useRef<RefErrorModal>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (actionData?.error) {
|
||||
errorModal.current?.show(actionData.error);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [actionData]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<div className="flex min-h-screen flex-col items-center justify-center px-4 py-12 sm:px-6 lg:px-8">
|
||||
<div className="sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<Logo className="mx-auto h-12 w-auto" />
|
||||
</div>
|
||||
{(() => {
|
||||
if (!data.invitation?.pending || actionData?.invitationAccepted) {
|
||||
return (
|
||||
<div className="mt-3 w-full space-y-5">
|
||||
<div className="flex flex-col items-center">
|
||||
<h1 className="text-left text-xl font-extrabold">{t("auth:invitation.accepted.title")}</h1>
|
||||
<div className="mx-auto mt-4 w-full max-w-sm space-y-5">
|
||||
<div className="w-full">
|
||||
<SuccessBanner title={t("shared.success")} text={t("auth:invitation.accepted.description")} />
|
||||
</div>
|
||||
<div className="flex w-full justify-end">
|
||||
<Button asChild variant="outline">
|
||||
<Link to={data.appRootPath}>{t("account.shared.signIn")}</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else if (!data.invitation) {
|
||||
return <div className="text-center text-red-500">{t("shared.invalidInvitation")}</div>;
|
||||
} else {
|
||||
return (
|
||||
<div>
|
||||
<h2 className="text-foreground mt-6 text-center text-lg font-extrabold dark:text-slate-200">
|
||||
{t("shared.hi")} {data.invitation.firstName ? data.invitation.firstName : data.invitation.email}, {t("account.invitation.youWereInvited")}{" "}
|
||||
{data.invitation.tenant.name}
|
||||
</h2>
|
||||
<p className="max-w text-muted-foreground mt-2 text-center text-sm leading-5">
|
||||
{t("account.register.alreadyRegistered")}{" "}
|
||||
<span className="text-primary font-medium hover:underline">
|
||||
<Link to="/login">{t("account.register.clickHereToLogin")}</Link>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<div className="px-4 py-8 sm:rounded-sm sm:px-10">
|
||||
<Form method="post" className="sm:w-96">
|
||||
<div>
|
||||
<label htmlFor="email" className="block text-sm leading-5 font-medium">
|
||||
{t("account.shared.email")}
|
||||
</label>
|
||||
<div className="mt-1 rounded-sm shadow-2xs">
|
||||
<input
|
||||
disabled={true}
|
||||
type="email"
|
||||
id="email"
|
||||
name="email"
|
||||
defaultValue={data.invitation.email}
|
||||
required
|
||||
className="focus:border-theme-500 focus:ring-ring border-border text-foreground bg-secondary/90 relative block w-full appearance-none rounded-md border px-3 py-2 placeholder-gray-500 focus:z-10 focus:outline-hidden sm:text-sm dark:border-gray-700 dark:bg-slate-800 dark:text-slate-200"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{!data.existingUser && (
|
||||
<>
|
||||
<div className="mt-6">
|
||||
<label htmlFor="password" className="block text-sm leading-5 font-medium">
|
||||
{t("account.shared.password")}
|
||||
</label>
|
||||
<div className="mt-1 rounded-sm shadow-2xs">
|
||||
<input
|
||||
type="password"
|
||||
id="password"
|
||||
name="password"
|
||||
required
|
||||
className="focus:border-theme-500 focus:ring-ring border-border text-foreground relative block w-full appearance-none rounded-md border px-3 py-2 placeholder-gray-500 focus:z-10 focus:outline-hidden sm:text-sm dark:border-gray-700 dark:bg-gray-900 dark:text-slate-200"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<label htmlFor="password-confirm" className="block text-sm leading-5 font-medium">
|
||||
{t("account.register.confirmPassword")}
|
||||
</label>
|
||||
<div className="mt-1 rounded-sm shadow-2xs">
|
||||
<input
|
||||
type="password"
|
||||
id="password-confirm"
|
||||
name="password-confirm"
|
||||
required
|
||||
className="focus:border-theme-500 focus:ring-ring border-border text-foreground relative block w-full appearance-none rounded-md border px-3 py-2 placeholder-gray-500 focus:z-10 focus:outline-hidden sm:text-sm dark:border-gray-700 dark:bg-gray-900 dark:text-slate-200"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="mt-6 space-y-2">
|
||||
<span className="block w-full rounded-sm shadow-2xs">
|
||||
<button
|
||||
type="submit"
|
||||
name="intent"
|
||||
value="set-password"
|
||||
className="bg-primary text-primary-foreground hover:bg-primary/90 inline-flex h-10 w-full items-center justify-center rounded-md px-4 text-sm font-medium"
|
||||
>
|
||||
{t("account.invitation.button")}
|
||||
</button>
|
||||
</span>
|
||||
{!data.existingUser && (
|
||||
<button
|
||||
type="submit"
|
||||
name="intent"
|
||||
value="magic-link"
|
||||
className="text-foreground/80 hover:text-foreground w-full text-center text-sm font-medium underline-offset-4 hover:underline"
|
||||
>
|
||||
{t("auth:invitation.skipPasswordUseMagicLink")}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
</div>
|
||||
<ErrorModal ref={errorModal} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
// WF-P2 / S01 — Davids "Neues Passwort setzen". Loader/Action unverändert (intent=set-password /
|
||||
// intent=magic-link), nur die UI re-skinned auf Davids Auth-Optik.
|
||||
return <SetPasswordScreen data={data} actionData={actionData} />;
|
||||
}
|
||||
Reference in new issue
Block a user