1088f7bbab
## Summary
This PR adds the `lingui/no-unlocalized-strings` ESLint rule to detect
untranslated strings and fixes translation issues across multiple
components.
## Changes
### ESLint Configuration (`eslint.config.react.mjs`)
- Added comprehensive `ignore` patterns for non-translatable strings
(CSS values, HTML attributes, technical identifiers)
- Added `ignoreNames` for props that don't need translation (className,
data-*, aria-*, etc.)
- Added `ignoreFunctions` for console methods, URL APIs, and other
non-user-facing functions
- Disabled rule for debug files, storybook, and test files
### Components Fixed (~19 files)
- Object record components (field inputs, pickers, merge dialogs)
- Settings components (accounts, admin panel)
- Serverless function components
- Record table and title cell components
## Status
🚧 **Work in Progress** - ~124 files remaining to fix
This PR is being submitted as draft to allow progressive fixing of
remaining translation issues.
## Testing
- Run `npx eslint "src/**/*.tsx"` in `packages/twenty-front` to check
remaining issues
70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
import { zodResolver } from '@hookform/resolvers/zod';
|
|
import { t } from '@lingui/core/macro';
|
|
import { useEffect } from 'react';
|
|
import { useForm } from 'react-hook-form';
|
|
import { useSearchParams } from 'react-router-dom';
|
|
import { useRecoilValue } from 'recoil';
|
|
import { z } from 'zod';
|
|
|
|
import {
|
|
SignInUpStep,
|
|
signInUpStepState,
|
|
} from '@/auth/states/signInUpStepState';
|
|
import { PASSWORD_REGEX } from '@/auth/utils/passwordRegex';
|
|
import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState';
|
|
import { isDefined } from 'twenty-shared/utils';
|
|
|
|
const makeValidationSchema = (signInUpStep: SignInUpStep) =>
|
|
z
|
|
.object({
|
|
exist: z.boolean(),
|
|
email: z
|
|
.string()
|
|
.trim()
|
|
.pipe(z.email({ error: t`Email must be a valid email` })),
|
|
password:
|
|
signInUpStep === SignInUpStep.Password
|
|
? z
|
|
.string()
|
|
.regex(PASSWORD_REGEX, t`Password must be min. 8 characters`)
|
|
: z.string().optional(),
|
|
captchaToken: z.string().default(''),
|
|
})
|
|
.required();
|
|
|
|
export type Form = z.infer<ReturnType<typeof makeValidationSchema>>;
|
|
export const useSignInUpForm = () => {
|
|
const signInUpStep = useRecoilValue(signInUpStepState);
|
|
|
|
const validationSchema = makeValidationSchema(signInUpStep); // Create schema based on the current step
|
|
|
|
const isDeveloperDefaultSignInPrefilled = useRecoilValue(
|
|
isDeveloperDefaultSignInPrefilledState,
|
|
);
|
|
const [searchParams] = useSearchParams();
|
|
const prefilledEmail = searchParams.get('email');
|
|
|
|
const form = useForm<Form>({
|
|
mode: 'onSubmit',
|
|
defaultValues: {
|
|
exist: false,
|
|
email: '',
|
|
password: '',
|
|
captchaToken: '',
|
|
},
|
|
resolver: zodResolver(validationSchema),
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (isDefined(prefilledEmail)) {
|
|
form.setValue('email', prefilledEmail);
|
|
}
|
|
|
|
if (isDeveloperDefaultSignInPrefilled === true) {
|
|
form.setValue('email', prefilledEmail ?? 'tim@apple.dev');
|
|
form.setValue('password', 'tim@apple.dev');
|
|
}
|
|
}, [form, isDeveloperDefaultSignInPrefilled, prefilledEmail]);
|
|
return { form };
|
|
};
|