This commit is contained in:
@@ -23,7 +23,7 @@ const ActivityDetail = () => {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const { scrollY } = useScroll();
|
||||
const { login } = useAuth();
|
||||
const { login, user } = useAuth();
|
||||
const [loginVisible, setLoginVisible] = useState(false);
|
||||
const [signupFormVisible, setSignupFormVisible] = useState(false);
|
||||
const [paymentModalVisible, setPaymentModalVisible] = useState(false);
|
||||
@@ -68,6 +68,28 @@ const ActivityDetail = () => {
|
||||
return () => clearTimeout(timer);
|
||||
}, [id, refetch]);
|
||||
|
||||
// Auto-fill form fields when the signup form becomes visible
|
||||
useEffect(() => {
|
||||
if (signupFormVisible && user && activity?.signup_form_config) {
|
||||
const initialValues = {};
|
||||
|
||||
activity.signup_form_config.forEach(field => {
|
||||
// Auto-fill phone number
|
||||
if (field.name === 'phone' && user.phone_number) {
|
||||
initialValues[field.name] = user.phone_number;
|
||||
}
|
||||
// Auto-fill name (nickname) if the field name is 'name'
|
||||
if (field.name === 'name' && user.nickname) {
|
||||
initialValues[field.name] = user.nickname;
|
||||
}
|
||||
});
|
||||
|
||||
if (Object.keys(initialValues).length > 0) {
|
||||
form.setFieldsValue(initialValues);
|
||||
}
|
||||
}
|
||||
}, [signupFormVisible, user, activity, form]);
|
||||
|
||||
const signUpMutation = useMutation({
|
||||
mutationFn: (values) => signUpActivity(id, { signup_info: values || {} }),
|
||||
onSuccess: (data) => {
|
||||
|
||||
Reference in New Issue
Block a user