From b023d0feffc8b6ed91877afda3e5cf51d63c4669 Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Fri, 15 Nov 2024 13:21:39 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(ui):=20Bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/app/(auth)/page.tsx | 6 +-- apps/admin/app/(auth)/user-auth-form.tsx | 7 +--- apps/admin/app/(auth)/user-check-form.tsx | 29 ++++++-------- .../dashboard/subscribe/subscribe-form.tsx | 2 +- apps/admin/locales/en-US/system.json | 2 +- apps/admin/locales/zh-CN/system.json | 2 +- packages/ui/src/enhanced-input.tsx | 9 +++-- packages/ui/src/markdown.tsx | 40 +++++++++---------- 8 files changed, 46 insertions(+), 51 deletions(-) diff --git a/apps/admin/app/(auth)/page.tsx b/apps/admin/app/(auth)/page.tsx index 31eb3cd..532ac15 100644 --- a/apps/admin/app/(auth)/page.tsx +++ b/apps/admin/app/(auth)/page.tsx @@ -36,10 +36,10 @@ export default function Page() {
-
-
+
+ {/*
{t('tos')} -
+
*/}
diff --git a/apps/admin/app/(auth)/user-auth-form.tsx b/apps/admin/app/(auth)/user-auth-form.tsx index 8f6b31b..d02b384 100644 --- a/apps/admin/app/(auth)/user-auth-form.tsx +++ b/apps/admin/app/(auth)/user-auth-form.tsx @@ -7,10 +7,7 @@ import { import useGlobalStore from '@/config/use-global'; import { checkUser, resetPassword, userLogin, userRegister } from '@/services/common/auth'; import { getRedirectUrl, setAuthorization } from '@/utils/common'; -import { Icon } from '@iconify/react'; -import { Button } from '@shadcn/ui/button'; import { toast } from '@shadcn/ui/lib/sonner'; -import { cn } from '@shadcn/ui/lib/utils'; import { useTranslations } from 'next-intl'; import { useRouter } from 'next/navigation'; import { ReactNode, useState, useTransition } from 'react'; @@ -131,7 +128,7 @@ export default function UserAuthForm() { {t(`${type || 'check'}.description`)}
- {!((type === 'register' && register.stop_register) || type === 'reset') && ( + {/* {!((type === 'register' && register.stop_register) || type === 'reset') && ( <>
- )} + )} */} {UserForm} diff --git a/apps/admin/app/(auth)/user-check-form.tsx b/apps/admin/app/(auth)/user-check-form.tsx index 506db63..e510996 100644 --- a/apps/admin/app/(auth)/user-check-form.tsx +++ b/apps/admin/app/(auth)/user-check-form.tsx @@ -1,4 +1,3 @@ -import useGlobalStore from '@/config/use-global'; import { Icon } from '@iconify/react'; import { Button } from '@shadcn/ui/button'; import { Form, FormControl, FormField, FormItem, FormMessage } from '@shadcn/ui/form'; @@ -18,22 +17,20 @@ export default function UserCheckForm({ initialValues: any; }) { const t = useTranslations('auth.check'); - const { common } = useGlobalStore(); - const { register } = common; + // const { common } = useGlobalStore(); + // const { register } = common; const formSchema = z.object({ - email: z - .string() - .email(t('email')) - .refine( - (email) => { - if (!register.enable_email_domain_suffix) return true; - const domain = email.split('@')[1] as string; - return register.email_domain_suffix_list.split('\n').includes(domain); - }, - { - message: t('whitelist'), - }, - ), + email: z.string().email(t('email')), + // .refine( + // (email) => { + // if (!register.enable_email_domain_suffix) return true; + // const domain = email.split('@')[1] as string; + // return register.email_domain_suffix_list.split('\n').includes(domain); + // }, + // { + // message: t('whitelist'), + // }, + // ), }); const form = useForm>({ diff --git a/apps/admin/app/dashboard/subscribe/subscribe-form.tsx b/apps/admin/app/dashboard/subscribe/subscribe-form.tsx index ba08625..2e16776 100644 --- a/apps/admin/app/dashboard/subscribe/subscribe-form.tsx +++ b/apps/admin/app/dashboard/subscribe/subscribe-form.tsx @@ -491,7 +491,7 @@ export default function SubscribeForm>({
-
+
{ - const newValue = String(inputValue ?? ''); + const newValue = inputValue === '' || inputValue === 0 ? '' : String(inputValue ?? ''); return formatInput ? formatInput(newValue) : newValue; }; @@ -47,16 +47,19 @@ export function EnhancedInput({ const handleChange = (e: ChangeEvent) => { let inputValue = e.target.value; - if (props.type === 'number') { + if (props.type === 'number' && inputValue) { const numericValue = Number(inputValue); if (!isNaN(numericValue)) { const min = Number.isFinite(props.min) ? props.min : -Infinity; const max = Number.isFinite(props.max) ? props.max : Infinity; inputValue = String(Math.max(min!, Math.min(max!, numericValue))); } + setValue(inputValue === '0' ? '' : inputValue); + } else { + setValue(inputValue); } - setValue(inputValue); const outputValue = processValue(inputValue); + console.log(); onValueChange?.(outputValue); }; diff --git a/packages/ui/src/markdown.tsx b/packages/ui/src/markdown.tsx index 21aaa19..c5e5bca 100644 --- a/packages/ui/src/markdown.tsx +++ b/packages/ui/src/markdown.tsx @@ -2,13 +2,12 @@ import { Button } from '@shadcn/ui/button'; import { cn } from '@shadcn/ui/lib/utils'; -import { ScrollArea } from '@shadcn/ui/scroll-area'; import 'katex/dist/katex.min.css'; import { Check, Copy } from 'lucide-react'; import { useCallback, useState } from 'react'; import ReactMarkdown from 'react-markdown'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; -import { oneDark, oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism'; +import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism'; import rehypeKatex from 'rehype-katex'; import rehypeRaw from 'rehype-raw'; import remarkGfm from 'remark-gfm'; @@ -39,39 +38,38 @@ function CodeBlock({ className, children, dark, ...props }: CodeBlockProps) { if (match) { return ( -
-
+
+
{match[1]}
- - - {String(children).replace(/\n$/, '')} - - + + {String(children).replace(/\n$/, '')} +
); } return ( - + {children} );