feat: 调整注册逻辑
This commit is contained in:
44
src/components/Auth/VerificationCodeInput.js
Normal file
44
src/components/Auth/VerificationCodeInput.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import React from "react";
|
||||
import { FormControl, FormErrorMessage, HStack, Input, Button } from "@chakra-ui/react";
|
||||
|
||||
/**
|
||||
* 通用验证码输入组件
|
||||
*/
|
||||
export default function VerificationCodeInput({
|
||||
value,
|
||||
onChange,
|
||||
onSendCode,
|
||||
countdown,
|
||||
isLoading,
|
||||
isSending,
|
||||
error,
|
||||
placeholder = "请输入6位验证码",
|
||||
buttonText = "获取验证码",
|
||||
countdownText = (count) => `${count}s`,
|
||||
colorScheme = "green",
|
||||
isRequired = true
|
||||
}) {
|
||||
return (
|
||||
<FormControl isRequired={isRequired} isInvalid={!!error}>
|
||||
<HStack>
|
||||
<Input
|
||||
name="verificationCode"
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
placeholder={placeholder}
|
||||
maxLength={6}
|
||||
/>
|
||||
<Button
|
||||
colorScheme={colorScheme}
|
||||
onClick={onSendCode}
|
||||
isDisabled={countdown > 0 || isLoading}
|
||||
isLoading={isSending}
|
||||
minW="120px"
|
||||
>
|
||||
{countdown > 0 ? countdownText(countdown) : buttonText}
|
||||
</Button>
|
||||
</HStack>
|
||||
<FormErrorMessage>{error}</FormErrorMessage>
|
||||
</FormControl>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user