Show invited people the Rule, let them copy its cards for their community, and replace an expired invitation link.
This commit is contained in:
1 parent
727a92a9ac
commit
3c984e00c5
37 files changed
+1962
-19
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
import { getSessionUser } from "../../../../lib/server/session";
|
||||
import { getAcceptedStakeholderInviteView } from "../../../../lib/server/publishedRules";
|
||||
import { inviteRuleCountsSpoken } from "../../../../lib/create/ruleInviteCardMeta";
|
||||
import {
|
||||
INVITE_COPY_VALUE,
|
||||
invitedRulePath,
|
||||
} from "../../../../lib/create/invitePaths";
|
||||
import { InvitedRuleView } from "../_components/InvitedRuleView";
|
||||
|
||||
type PageProps = {
|
||||
params: Promise<{ ruleId: string }>;
|
||||
searchParams: Promise<{ copy?: string }>;
|
||||
};
|
||||
|
||||
export default async function InviteRulePage({
|
||||
params,
|
||||
searchParams,
|
||||
}: PageProps) {
|
||||
const { ruleId } = await params;
|
||||
const query = await searchParams;
|
||||
const copy = query.copy === INVITE_COPY_VALUE;
|
||||
const user = await getSessionUser();
|
||||
if (!user) {
|
||||
const next = invitedRulePath(ruleId, { copy });
|
||||
redirect(`/login?next=${encodeURIComponent(next)}`);
|
||||
}
|
||||
|
||||
const view = await getAcceptedStakeholderInviteView({
|
||||
userId: user.id,
|
||||
ruleId,
|
||||
});
|
||||
if (!view) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<InvitedRuleView
|
||||
ruleId={view.ruleId}
|
||||
title={view.title}
|
||||
summary={view.summary}
|
||||
document={view.document}
|
||||
updatedAt={view.updatedAt}
|
||||
inviterEmail={view.inviterEmail}
|
||||
viewerEmail={user.email}
|
||||
countsSpoken={inviteRuleCountsSpoken(view.document)}
|
||||
openCopyDialog={copy}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user