g1t/apps/web/app/routes/settings/emails.tsx

40 lines1,674 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas1import type { Route } from "./+types/emails";
2import { page } from "../../lib/meta";
3import { assertSameOrigin, requireUser } from "../../lib/session.server";
4import { EmailsSection } from "../../components/emails-section";
5import { EMAIL_INTENTS, emailAction, loadEmails } from "../../lib/emails.server";
6import { githubSignIn } from "../../lib/github.server";
7
8export function meta(args: Route.MetaArgs) {
9 return page(args, { title: "Emails · Settings · g1t" });
10}
11
12export async function loader({ request, context }: Route.LoaderArgs) {
13 const user = requireUser(context, request);
14 const [emails, github] = await Promise.all([loadEmails(user), githubSignIn.account(user).catch(() => null)]);
15 // Whether a sensitive change can be confirmed with a password.
16 return { emails: emails.emails, hasPassword: github?.hasPassword ?? true };
17}
18
19export async function action({ request, context }: Route.ActionArgs) {
20 assertSameOrigin(request);
21 const user = requireUser(context, request);
22 const form = await request.formData();
23 // Sensitive changes may first ask for the password (lib/emails.server.ts).
24 if ((EMAIL_INTENTS as readonly string[]).includes(String(form.get("intent")))) {
Merge branch 'worktree-agent-a985c01f43538af01'25 // Which form posted, so its answer shows beside it.
26 return { emailAction: await emailAction(user, form, request), emailIntent: String(form.get("intent")) };
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas27 }
28 return null;
29}
30
31export default function EmailSettings({ loaderData, actionData }: Route.ComponentProps) {
32 return (
33 <EmailsSection
34 data={loaderData.emails}
35 actionData={actionData?.emailAction}
Merge branch 'worktree-agent-a985c01f43538af01'36 intent={actionData?.emailIntent}
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas37 hasPassword={loaderData.hasPassword}
38 />
39 );
40}

This file's history is long; its oldest lines are credited to the oldest commit read.