mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-06 03:30:25 -05:00
🐛 fix(user): Refactor user form validation and reset password fields
This commit is contained in:
parent
f60d40c06d
commit
6733fc211c
@ -21,7 +21,6 @@ import {
|
||||
SheetTrigger,
|
||||
} from '@workspace/ui/components/sheet';
|
||||
import { Switch } from '@workspace/ui/components/switch';
|
||||
import { AreaCodeSelect } from '@workspace/ui/custom-components/area-code-select';
|
||||
import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input';
|
||||
import { Icon } from '@workspace/ui/custom-components/icon';
|
||||
import { unitConversion } from '@workspace/ui/utils';
|
||||
@ -52,9 +51,9 @@ export default function UserForm<T extends Record<string, any>>({
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
const formSchema = z.object({
|
||||
email: z.string().email(t('form.invalidEmailFormat')),
|
||||
telephone_area_code: z.string().optional(),
|
||||
telephone: z.string().optional(),
|
||||
// email: z.string().email(t('form.invalidEmailFormat')),
|
||||
// telephone_area_code: z.string().optional(),
|
||||
// telephone: z.string().optional(),
|
||||
password: z.string().optional(),
|
||||
referer_id: z.number().optional(),
|
||||
refer_code: z.string().optional(),
|
||||
@ -99,7 +98,7 @@ export default function UserForm<T extends Record<string, any>>({
|
||||
<ScrollArea className='-mx-6 h-[calc(100dvh-48px-36px-36px-env(safe-area-inset-top))]'>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(handleSubmit)} className='space-y-4 px-6 pt-4'>
|
||||
<FormField
|
||||
{/* <FormField
|
||||
control={form.control}
|
||||
name='email'
|
||||
render={({ field }) => (
|
||||
@ -159,7 +158,7 @@ export default function UserForm<T extends Record<string, any>>({
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
/> */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='password'
|
||||
|
||||
@ -59,18 +59,6 @@ export default function ResetForm({
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='password'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input placeholder='Enter your password...' type='password' {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{auth?.email?.email_enable_verify && (
|
||||
<FormField
|
||||
@ -101,6 +89,18 @@ export default function ResetForm({
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='password'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input placeholder='Enter your new password...' type='password' {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{verify.enable_reset_password_verify && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
||||
@ -91,20 +91,6 @@ export default function ResetForm({
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='password'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input placeholder='Enter your password...' type='password' {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{auth?.email?.email_enable_verify && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='code'
|
||||
@ -125,7 +111,18 @@ export default function ResetForm({
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='password'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input placeholder='Enter your new password...' type='password' {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{verify.enable_reset_password_verify && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Skip script in CI environment
|
||||
# Skip entire script in CI environment
|
||||
if [ "$CI" = "true" ]; then
|
||||
echo "CI environment detected, skipping script execution."
|
||||
exit 0
|
||||
@ -12,39 +12,28 @@ if [ ! -d ".git" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if .husky folder exists and skip `npx husky install` if it does
|
||||
if [ -d ".husky" ]; then
|
||||
echo ".husky folder already exists. Skipping npx husky install."
|
||||
else
|
||||
echo "Setting up Husky..."
|
||||
if npx husky; then
|
||||
echo "Husky has been successfully set up."
|
||||
else
|
||||
echo "Failed to set up Husky. Skipping."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Function to set up a Husky hook
|
||||
setup_husky_hook() {
|
||||
local hook_name=$1
|
||||
local hook_content=$2
|
||||
local hook_file=".husky/$hook_name"
|
||||
|
||||
if [ -f "$hook_file" ]; then
|
||||
echo "$hook_name hook is already set up. Skipping."
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f ".husky/$hook_name" ]; then
|
||||
echo "Setting up $hook_name hook..."
|
||||
echo "$hook_content" > "$hook_file" && chmod +x "$hook_file"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "$hook_name hook has been successfully set up."
|
||||
echo "$hook_content" > ".husky/$hook_name" || echo "Failed to set up $hook_name hook. Skipping."
|
||||
chmod +x ".husky/$hook_name" || echo "Failed to make $hook_name hook executable. Skipping."
|
||||
else
|
||||
echo "Failed to set up $hook_name hook. Skipping."
|
||||
echo "$hook_name hook is already set up."
|
||||
fi
|
||||
}
|
||||
|
||||
# Ensure Husky is installed and initialized
|
||||
if [ ! -d ".husky" ]; then
|
||||
echo "Setting up Husky..."
|
||||
npx husky || echo "Failed to set up Husky. Skipping."
|
||||
else
|
||||
echo "Husky is already set up."
|
||||
fi
|
||||
|
||||
# Set up pre-commit hook
|
||||
setup_husky_hook "pre-commit" "#!/bin/sh
|
||||
. \"\$(dirname \"\$0\")/_/husky.sh\"
|
||||
@ -61,16 +50,11 @@ npx --no-install commitlint --edit \"\$1\""
|
||||
install_global_package() {
|
||||
local package_name=$1
|
||||
|
||||
if npm list -g --depth=0 "$package_name" > /dev/null 2>&1; then
|
||||
echo "$package_name is already installed. Skipping installation."
|
||||
return
|
||||
fi
|
||||
|
||||
if ! npm list -g --depth=0 "$package_name" > /dev/null 2>&1; then
|
||||
echo "Installing $package_name globally..."
|
||||
if npm install -g "$package_name"; then
|
||||
echo "$package_name has been successfully installed."
|
||||
npm install -g "$package_name" || echo "Failed to install $package_name globally. Skipping."
|
||||
else
|
||||
echo "Failed to install $package_name globally. Skipping."
|
||||
echo "$package_name is already installed."
|
||||
fi
|
||||
}
|
||||
|
||||
@ -78,24 +62,6 @@ install_global_package() {
|
||||
install_global_package "@lobehub/i18n-cli"
|
||||
install_global_package "@lobehub/commit-cli"
|
||||
|
||||
# Check if .husky/_/prepare-commit-msg contains lobe-commit --hook
|
||||
if grep -q "lobe-commit --hook" ".husky/_/prepare-commit-msg"; then
|
||||
echo "prepare-commit-msg hook already contains lobe-commit --hook. Skipping lobe-commit -i."
|
||||
else
|
||||
# If the hook does not contain lobe-commit --hook, set it up and run lobe-commit -i
|
||||
echo "Setting up prepare-commit-msg hook..."
|
||||
if npx husky add .husky/prepare-commit-msg "exec < /dev/tty && npx lobe-commit -i"; then
|
||||
echo "prepare-commit-msg hook has been successfully set up."
|
||||
|
||||
# Run lobe-commit interactively
|
||||
echo "Running lobe-commit -i..."
|
||||
if lobe-commit -i; then
|
||||
echo "lobe-commit executed successfully."
|
||||
else
|
||||
echo "lobe-commit failed. Skipping."
|
||||
fi
|
||||
else
|
||||
echo "Failed to set up prepare-commit-msg hook. Skipping lobe-commit."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# Run lobe-commit interactively
|
||||
echo "Running lobe-commit -i..."
|
||||
lobe-commit -i || echo "lobe-commit failed. Skipping."
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user