From 177e827bf7cd74008ed73973dda5a8d4f11291cf Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Fri, 29 Mar 2024 20:57:31 +0000 Subject: fix(web): Disable keyboard shortcut submissions in demoMode --- apps/web/components/dashboard/bookmarks/EditorCard.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/web/components/dashboard/bookmarks/EditorCard.tsx b/apps/web/components/dashboard/bookmarks/EditorCard.tsx index 202b69ed..adada927 100644 --- a/apps/web/components/dashboard/bookmarks/EditorCard.tsx +++ b/apps/web/components/dashboard/bookmarks/EditorCard.tsx @@ -4,6 +4,7 @@ import { Form, FormControl, FormField, FormItem } from "@/components/ui/form"; import { Separator } from "@/components/ui/separator"; import { Textarea } from "@/components/ui/textarea"; import { toast } from "@/components/ui/use-toast"; +import { useClientConfig } from "@/lib/clientConfig"; import { api } from "@/lib/trpc"; import { cn } from "@/lib/utils"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -11,6 +12,7 @@ import { useForm } from "react-hook-form"; import { z } from "zod"; export default function EditorCard({ className }: { className?: string }) { + const demoMode = !!useClientConfig().demoMode; const formSchema = z.object({ text: z.string(), }); @@ -76,6 +78,9 @@ export default function EditorCard({ className }: { className?: string }) { "Paste a link, write a note or drag and drop an image in here ..." } onKeyDown={(e) => { + if (demoMode) { + return; + } if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { form.handleSubmit(onSubmit, onError)(); } @@ -88,7 +93,11 @@ export default function EditorCard({ className }: { className?: string }) { }} /> - {form.formState.dirtyFields.text ? "Press ⌘ + Enter to Save" : "Save"} + {form.formState.dirtyFields.text + ? demoMode + ? "Submissions are disabled" + : "Press ⌘ + Enter to Save" + : "Save"} -- cgit v1.2.3-70-g09d2