From 296c4aac224d45360b44554a99c9b377c8235a4f Mon Sep 17 00:00:00 2001 From: tomolld Date: Sun, 18 Aug 2024 12:16:54 +0900 Subject: [PATCH 1/2] =?UTF-8?q?geminikey=E3=81=AE=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/app/routes/$userName+/edit/route.tsx | 81 ++++++++++++------- .../$userName+/page+/$slug+/edit/_edit.tsx | 1 + web/app/routes/translator/route.tsx | 29 +++++-- 3 files changed, 76 insertions(+), 35 deletions(-) diff --git a/web/app/routes/$userName+/edit/route.tsx b/web/app/routes/$userName+/edit/route.tsx index 852e6518..ff7bd2d9 100644 --- a/web/app/routes/$userName+/edit/route.tsx +++ b/web/app/routes/$userName+/edit/route.tsx @@ -6,17 +6,20 @@ import { } from "@conform-to/react"; import { getZodConstraint, parseWithZod } from "@conform-to/zod"; import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node"; -import { redirect } from "@remix-run/node"; import { Form } from "@remix-run/react"; +import { Link } from "@remix-run/react"; +import { useNavigation } from "@remix-run/react"; +import { ArrowLeft } from "lucide-react"; +import { useState } from "react"; import { typedjson, useTypedLoaderData } from "remix-typedjson"; import { z } from "zod"; import { Button } from "~/components/ui/button"; import { Input } from "~/components/ui/input"; import { Label } from "~/components/ui/label"; +import { GeminiApiKeyDialog } from "~/routes/resources+/gemini-api-key-dialog"; import { authenticator, sanitizeUser } from "~/utils/auth.server"; import { commitSession, getSession } from "~/utils/session.server"; import { updateUser } from "./functions/mutations.server"; - const schema = z.object({ displayName: z .string() @@ -54,17 +57,15 @@ export const action = async ({ request }: ActionFunctionArgs) => { }); const session = await getSession(request.headers.get("Cookie")); session.set("user", sanitizeUser(updatedUser)); - - return redirect(`/${currentUser.userName}`, { - headers: { - "Set-Cookie": await commitSession(session), - }, - }); + await commitSession(session); + return null; }; export default function EditProfile() { const { currentUser } = useTypedLoaderData(); - + const [isGeminiApiKeyDialogOpen, setIsGeminiApiKeyDialogOpen] = + useState(false); + const navigation = useNavigation(); const [form, { displayName, profile }] = useForm({ id: "edit-profile-form", constraint: getZodConstraint(schema), @@ -80,27 +81,51 @@ export default function EditProfile() { }); return (
-

Edit Profile

-
-
- - -
- {displayName.errors} + + + +
+

Edit Profile

+ +
+ + +
+ {displayName.errors} +
-
-
- -