Skip to content

Commit 426b7ff

Browse files
committed
chore: AI feedback
1 parent 4110192 commit 426b7ff

File tree

4 files changed

+21
-36
lines changed

4 files changed

+21
-36
lines changed

src/components/FormFields/RegisterAccountFields.tsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Stack } from '@openedx/paragon';
33
import { Lock, Visibility, VisibilityOff } from '@openedx/paragon/icons';
44
import { useState } from 'react';
55

6-
import { useCountryOptions, useRecaptchaToken } from '@/components/app/data';
6+
import { useCountryOptions } from '@/components/app/data';
77
import { FieldContainer } from '@/components/FieldContainer';
88
import Field from '@/components/FormFields/Field';
99

@@ -230,24 +230,18 @@ export const RegisterAccountCountry = ({
230230
);
231231
};
232232

233-
const RegisterAccountFields = ({ form }: RegisterAccountFieldsProps) => {
234-
const { isLoading } = useRecaptchaToken('submit');
235-
if (isLoading) {
236-
return null;
237-
}
238-
return (
239-
<FieldContainer>
240-
<RegisterAccountFieldsHeader />
241-
<Stack gap={3}>
242-
<RegisterAccountAdminEmail form={form} />
243-
<RegisterAccountFullName form={form} />
244-
<RegisterAccountUsername form={form} />
245-
<RegisterAccountPassword form={form} />
246-
<RegisterAccountConfirmPassword form={form} />
247-
<RegisterAccountCountry form={form} />
248-
</Stack>
249-
</FieldContainer>
250-
);
251-
};
233+
const RegisterAccountFields = ({ form }: RegisterAccountFieldsProps) => (
234+
<FieldContainer>
235+
<RegisterAccountFieldsHeader />
236+
<Stack gap={3}>
237+
<RegisterAccountAdminEmail form={form} />
238+
<RegisterAccountFullName form={form} />
239+
<RegisterAccountUsername form={form} />
240+
<RegisterAccountPassword form={form} />
241+
<RegisterAccountConfirmPassword form={form} />
242+
<RegisterAccountCountry form={form} />
243+
</Stack>
244+
</FieldContainer>
245+
);
252246

253247
export default RegisterAccountFields;

src/components/app/data/hooks/useRecaptchaToken.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getConfig } from '@edx/frontend-platform';
2-
import { logError } from '@edx/frontend-platform/logging';
2+
import { logError, logInfo } from '@edx/frontend-platform/logging';
33
import { useCallback } from 'react';
44
import { useGoogleReCaptcha } from 'react-google-recaptcha-v3';
55

@@ -14,15 +14,14 @@ const useRecaptchaToken = (actionName = 'submit') => {
1414
if (isReady) {
1515
const token = await executeRecaptcha(actionName);
1616
if (!token) {
17-
throw new Error("Oopsie! reCAPTCHA didn't return a token.");
17+
throw new Error(`Failed to obtain reCAPTCHA verification token for action: ${actionName}. Please try again or contact support if the issue persists.`);
1818
}
1919
return token;
2020
}
2121

2222
// Fallback: no reCAPTCHA or not ready
2323
if (RECAPTCHA_SITE_KEY_WEB) {
24-
// eslint-disable-next-line no-console
25-
console.warn(`reCAPTCHA not ready for action: ${actionName}. Proceeding without token.`);
24+
logInfo(`reCAPTCHA not ready for action: ${actionName}. Proceeding without token.`);
2625
}
2726
return null;
2827
}, [isReady, RECAPTCHA_SITE_KEY_WEB, executeRecaptcha, actionName]);

src/components/app/data/services/registration.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,9 @@ declare global {
7070
country: string;
7171
}
7272

73-
interface RegistrationCreateRecaptchaRequestSchema extends BaseRegistrationCreateRequestSchema {
74-
recaptchaToken: string;
75-
}
76-
77-
interface RegistrationCreateRequestSchema extends
78-
BaseRegistrationCreateRequestSchema,
79-
RegistrationCreateRecaptchaRequestSchema {
73+
interface RegistrationCreateRequestSchema extends BaseRegistrationCreateRequestSchema {
8074
honorCode: boolean;
75+
recaptchaToken?: string;
8176
}
8277

8378
interface RegistrationCreateSuccessResponseSchema {

src/components/plan-details-pages/PlanDetailsPage.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ const PlanDetailsPage = () => {
175175
[SubmitCallbacks.PlanDetailsRegister]: async (data: PlanDetailsRegisterPageData) => {
176176
const recaptchaToken: string | null = await getToken();
177177

178-
let registerMutationPayload: Partial<RegistrationCreateRequestSchema> = {
178+
const registerMutationPayload: Partial<RegistrationCreateRequestSchema> = {
179179
name: data.fullName,
180180
email: data.adminEmail,
181181
username: data.username,
@@ -184,10 +184,7 @@ const PlanDetailsPage = () => {
184184
};
185185

186186
if (recaptchaToken) {
187-
registerMutationPayload = {
188-
...registerMutationPayload,
189-
recaptchaToken,
190-
} as RegistrationCreateRecaptchaRequestSchema;
187+
registerMutationPayload.recaptchaToken = recaptchaToken;
191188
}
192189
registerMutation.mutate(registerMutationPayload);
193190
},

0 commit comments

Comments
 (0)