Skip to content

Commit b004b8a

Browse files
authored
Merge pull request #112 from lambda-curry/codegen-bot/cleanup-console-logs-1754060163
2 parents 42a91f8 + 20eca0f commit b004b8a

22 files changed

Lines changed: 186 additions & 260 deletions

apps/docs/src/remix-hook-form/data-table/data-table-router-form.stories.tsx

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -132,41 +132,11 @@ const bazzaFilterColumnConfigs: BazzaFilterColumnConfig[] = [
132132
// Add more configs for other filterable columns as needed
133133
];
134134

135-
// Log all options for each config to help debug undefined labels
136-
bazzaFilterColumnConfigs.forEach((config) => {
137-
// Log the options array for each config, if present
138-
console.log(`Config id: ${config.id}, options:`, config.options);
139-
if (config.options) {
140-
config.options.forEach((opt, idx) => {
141-
// Log if label is missing or undefined
142-
if (!opt || typeof opt.label !== 'string') {
143-
// eslint-disable-next-line no-console
144-
console.warn(`Option label is missing or not a string in config '${config.id}' at index ${idx}:`, opt);
145-
}
146-
});
147-
}
148-
});
149-
150135
function DataTableRouterFormExample() {
151136
const loaderData = useLoaderData<DataResponse>();
152137
const data = loaderData?.data ?? [];
153138
const pageCount = loaderData?.meta.pageCount ?? 0;
154139

155-
// Log options before rendering to catch runtime issues
156-
bazzaFilterColumnConfigs.forEach((config) => {
157-
if (config.options) {
158-
config.options.forEach((opt, idx) => {
159-
if (!opt || typeof opt.label !== 'string') {
160-
// eslint-disable-next-line no-console
161-
console.warn(
162-
`[Render] Option label is missing or not a string in config '${config.id}' at index ${idx}:`,
163-
opt,
164-
);
165-
}
166-
});
167-
}
168-
});
169-
170140
return (
171141
<div className="container mx-auto py-10">
172142
<h1 className="text-2xl font-bold mb-4">Users Table (Bazza UI Filters)</h1>

apps/docs/src/remix-hook-form/date-picker.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ export const Default: Story = {
131131
// Find any available day button in the calendar (look for a button with a number)
132132
// We'll look for any day button that's not disabled
133133
const dayButtons = await dialogCanvas.findAllByRole('button');
134-
const availableDayButton = dayButtons.find(button => {
134+
const availableDayButton = dayButtons.find((button) => {
135135
const text = button.textContent;
136136
return text && DAY_BUTTON_REGEX.test(text.trim()) && !button.hasAttribute('disabled');
137137
});
138-
138+
139139
if (!availableDayButton) {
140140
throw new Error('No available day button found in calendar');
141141
}
142-
142+
143143
await userEvent.click(availableDayButton);
144144
});
145145

apps/docs/src/remix-hook-form/form-error-basic.stories.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ const formSchema = z.object({
1616
type FormData = z.infer<typeof formSchema>;
1717

1818
const BasicFormErrorExample = () => {
19-
const fetcher = useFetcher<{
20-
message?: string;
21-
errors?: Record<string, { message: string }>
19+
const fetcher = useFetcher<{
20+
message?: string;
21+
errors?: Record<string, { message: string }>;
2222
}>();
23-
23+
2424
const methods = useRemixForm<FormData>({
2525
resolver: zodResolver(formSchema),
2626
defaultValues: {
@@ -40,30 +40,30 @@ const BasicFormErrorExample = () => {
4040
<RemixFormProvider {...methods}>
4141
<fetcher.Form onSubmit={methods.handleSubmit} className="max-w-md mx-auto p-6 space-y-4">
4242
<h2 className="text-xl font-semibold text-gray-900">Login Form</h2>
43-
43+
4444
{/* Form-level error display */}
4545
<FormError className="mb-4" />
46-
46+
4747
<TextField
4848
name="email"
4949
type="email"
5050
label="Email Address"
5151
placeholder="Enter your email"
5252
disabled={isSubmitting}
5353
/>
54-
54+
5555
<TextField
5656
name="password"
5757
type="password"
5858
label="Password"
5959
placeholder="Enter your password"
6060
disabled={isSubmitting}
6161
/>
62-
62+
6363
<Button type="submit" disabled={isSubmitting} className="w-full">
6464
{isSubmitting ? 'Signing In...' : 'Sign In'}
6565
</Button>
66-
66+
6767
{fetcher.data?.message && (
6868
<div className="mt-4 p-4 bg-green-50 border border-green-200 rounded-md">
6969
<p className="text-green-700 font-medium">{fetcher.data.message}</p>
@@ -76,28 +76,28 @@ const BasicFormErrorExample = () => {
7676

7777
const handleFormSubmission = async (request: Request) => {
7878
const { data, errors } = await getValidatedFormData<FormData>(request, zodResolver(formSchema));
79-
79+
8080
if (errors) {
8181
return { errors };
8282
}
83-
83+
8484
// Simulate server-side authentication
8585
if (data.email === 'wrong@email.com' && data.password === 'wrongpass') {
8686
return {
8787
errors: {
88-
_form: { message: 'Invalid email or password. Please try again.' }
89-
}
88+
_form: { message: 'Invalid email or password. Please try again.' },
89+
},
9090
};
9191
}
92-
92+
9393
if (data.email === 'user@example.com' && data.password === 'password123') {
9494
return { message: 'Login successful! Welcome back.' };
9595
}
96-
96+
9797
return {
9898
errors: {
99-
_form: { message: 'Invalid email or password. Please try again.' }
100-
}
99+
_form: { message: 'Invalid email or password. Please try again.' },
100+
},
101101
};
102102
};
103103

@@ -191,7 +191,7 @@ The FormError component automatically displays when \`errors._form\` exists in t
191191

192192
// Wait for form-level error to appear
193193
await expect(canvas.findByText(/invalid email or password/i)).resolves.toBeInTheDocument();
194-
194+
195195
// Verify field-level errors are cleared
196196
expect(canvas.queryByText(/please enter a valid email address/i)).not.toBeInTheDocument();
197197
});

apps/docs/src/remix-hook-form/form-error-custom.stories.tsx

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ type FormData = z.infer<typeof formSchema>;
2020
const AlertErrorMessage = (props: React.ComponentProps<typeof FormMessage>) => (
2121
<div className="flex items-center p-4 bg-red-50 border-l-4 border-red-400 rounded-md">
2222
<svg className="h-5 w-5 text-red-400 mr-3" viewBox="0 0 20 20" fill="currentColor">
23-
<path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
23+
<path
24+
fillRule="evenodd"
25+
d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"
26+
clipRule="evenodd"
27+
/>
2428
</svg>
2529
<FormMessage className="text-red-800 font-medium" {...props} />
2630
</div>
2731
);
2832

2933
const CustomStyledFormErrorExample = () => {
30-
const fetcher = useFetcher<{
31-
message?: string;
32-
errors?: Record<string, { message: string }>
34+
const fetcher = useFetcher<{
35+
message?: string;
36+
errors?: Record<string, { message: string }>;
3337
}>();
34-
38+
3539
const methods = useRemixForm<FormData>({
3640
resolver: zodResolver(formSchema),
3741
defaultValues: {
@@ -51,34 +55,34 @@ const CustomStyledFormErrorExample = () => {
5155
<RemixFormProvider {...methods}>
5256
<fetcher.Form onSubmit={methods.handleSubmit} className="max-w-md mx-auto p-6 space-y-4">
5357
<h2 className="text-xl font-semibold text-gray-900">Sign In</h2>
54-
58+
5559
{/* Custom styled form error */}
56-
<FormError
60+
<FormError
5761
components={{
5862
FormMessage: AlertErrorMessage,
5963
}}
6064
/>
61-
65+
6266
<TextField
6367
name="email"
6468
type="email"
6569
label="Email Address"
6670
placeholder="Enter your email"
6771
disabled={isSubmitting}
6872
/>
69-
73+
7074
<TextField
7175
name="password"
7276
type="password"
7377
label="Password"
7478
placeholder="Enter your password"
7579
disabled={isSubmitting}
7680
/>
77-
81+
7882
<Button type="submit" disabled={isSubmitting} className="w-full">
7983
{isSubmitting ? 'Signing In...' : 'Sign In'}
8084
</Button>
81-
85+
8286
{fetcher.data?.message && (
8387
<div className="mt-4 p-4 bg-green-50 border border-green-200 rounded-md">
8488
<p className="text-green-700 font-medium">{fetcher.data.message}</p>
@@ -91,16 +95,16 @@ const CustomStyledFormErrorExample = () => {
9195

9296
const handleFormSubmission = async (request: Request) => {
9397
const { data, errors } = await getValidatedFormData<FormData>(request, zodResolver(formSchema));
94-
98+
9599
if (errors) {
96100
return { errors };
97101
}
98-
102+
99103
// Always show form error for demo purposes
100104
return {
101105
errors: {
102-
_form: { message: 'Authentication service is temporarily unavailable. Please try again in a few minutes.' }
103-
}
106+
_form: { message: 'Authentication service is temporarily unavailable. Please try again in a few minutes.' },
107+
},
104108
};
105109
};
106110

@@ -188,21 +192,29 @@ The custom component receives all the same props as the default FormMessage comp
188192
await userEvent.click(submitButton);
189193

190194
// Wait for error to appear
191-
await new Promise(resolve => setTimeout(resolve, 500));
192-
195+
await new Promise((resolve) => setTimeout(resolve, 500));
196+
193197
// Check for error message
194198
const errorMessage = canvas.queryByText(/authentication service is temporarily unavailable/i);
195199
expect(errorMessage).toBeInTheDocument();
196200
});
197201

198202
await step('Verify custom error styling and structure', async () => {
199203
// Wait for error message to be available
200-
await new Promise(resolve => setTimeout(resolve, 500));
204+
await new Promise((resolve) => setTimeout(resolve, 500));
201205
const errorMessage = canvas.queryByText(/authentication service is temporarily unavailable/i);
202206
expect(errorMessage).toBeInTheDocument();
203207

204208
const errorContainer = errorMessage?.closest('div');
205-
expect(errorContainer).toHaveClass('flex', 'items-center', 'p-4', 'bg-red-50', 'border-l-4', 'border-red-400', 'rounded-md');
209+
expect(errorContainer).toHaveClass(
210+
'flex',
211+
'items-center',
212+
'p-4',
213+
'bg-red-50',
214+
'border-l-4',
215+
'border-red-400',
216+
'rounded-md',
217+
);
206218

207219
const icon = errorContainer?.querySelector('svg');
208220
expect(icon).toBeInTheDocument();

0 commit comments

Comments
 (0)