From e339cc9bca7648d02a2a53cb2205dcf24cffd3d5 Mon Sep 17 00:00:00 2001 From: chronark Date: Mon, 23 Dec 2024 19:58:24 +0100 Subject: [PATCH] feat: add rewrites and upserts for gateway.new --- .../app/(app)/apis/create-api-button.tsx | 14 ++++++-- apps/dashboard/app/(app)/apis/page.tsx | 11 ++++-- apps/dashboard/app/(app)/gateway-new/page.tsx | 35 +++++++++++++++++++ apps/dashboard/middleware.ts | 1 + apps/dashboard/next.config.js | 12 ++++++- 5 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 apps/dashboard/app/(app)/gateway-new/page.tsx diff --git a/apps/dashboard/app/(app)/apis/create-api-button.tsx b/apps/dashboard/app/(app)/apis/create-api-button.tsx index f29a5952d7..207f2c5674 100644 --- a/apps/dashboard/app/(app)/apis/create-api-button.tsx +++ b/apps/dashboard/app/(app)/apis/create-api-button.tsx @@ -19,6 +19,7 @@ import { Button } from "@unkey/ui"; import { Plus } from "lucide-react"; import { useRouter } from "next/navigation"; import type React from "react"; +import { useState } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; @@ -26,11 +27,20 @@ const formSchema = z.object({ name: z.string().trim().min(3, "Name must be at least 3 characters long").max(50), }); -export const CreateApiButton = ({ ...rest }: React.ButtonHTMLAttributes) => { +type Props = { + defaultOpen?: boolean; +}; + +export const CreateApiButton = ({ + defaultOpen, + ...rest +}: React.ButtonHTMLAttributes & Props) => { const form = useForm>({ resolver: zodResolver(formSchema), }); + const [open, setOpen] = useState(defaultOpen ?? false); + const create = trpc.api.create.useMutation({ async onSuccess(res) { toast.success("Your API has been created"); @@ -49,7 +59,7 @@ export const CreateApiButton = ({ ...rest }: React.ButtonHTMLAttributes - + setOpen(o)}>