Skip to content

Commit 87352ab

Browse files
committed
Revert "onboarding: Validate slug length on correct step"
This reverts commit c3cca12.
1 parent c3cca12 commit 87352ab

4 files changed

Lines changed: 15 additions & 131 deletions

File tree

clients/apps/web/src/components/Onboarding/v2/BusinessDetailsStep.tsx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { CurrencySelector } from '../../CurrencySelector'
2424
import { SUPPORTED_PAYOUT_COUNTRIES } from './config/supported-payout-countries'
2525
import { useOnboardingData } from './OnboardingContext'
2626
import { OnboardingShell } from './OnboardingShell'
27-
import { ORGANIZATION_MIN_LENGTH } from './validation'
2827

2928
interface FormSchema {
3029
organizationType: 'individual' | 'company'
@@ -208,12 +207,13 @@ function CurrencyAndCountryFields() {
208207
function SubmitButton({ loading }: { loading: boolean }) {
209208
const orgName = useWatch<FormSchema, 'orgName'>({ name: 'orgName' })
210209
const orgSlug = useWatch<FormSchema, 'orgSlug'>({ name: 'orgSlug' })
211-
const isDisabled =
212-
orgName.length < ORGANIZATION_MIN_LENGTH ||
213-
orgSlug.length < ORGANIZATION_MIN_LENGTH
214-
215210
return (
216-
<Button type="submit" loading={loading} disabled={isDisabled} fullWidth>
211+
<Button
212+
type="submit"
213+
loading={loading}
214+
disabled={orgName.length === 0 || orgSlug.length === 0}
215+
fullWidth
216+
>
217217
Continue
218218
</Button>
219219
)
@@ -325,13 +325,7 @@ export function BusinessDetailsStep() {
325325
<FormField
326326
control={form.control}
327327
name="orgName"
328-
rules={{
329-
required: 'Organization name is required',
330-
minLength: {
331-
value: ORGANIZATION_MIN_LENGTH,
332-
message: `Organization name must be at least ${ORGANIZATION_MIN_LENGTH} characters`,
333-
},
334-
}}
328+
rules={{ required: 'Organization name is required' }}
335329
render={({ field }) => (
336330
<FormItem className="w-full">
337331
<FormLabel>Organization Name</FormLabel>
@@ -346,13 +340,7 @@ export function BusinessDetailsStep() {
346340
<FormField
347341
control={form.control}
348342
name="orgSlug"
349-
rules={{
350-
required: 'Organization slug is required',
351-
minLength: {
352-
value: ORGANIZATION_MIN_LENGTH,
353-
message: `Organization slug must be at least ${ORGANIZATION_MIN_LENGTH} characters`,
354-
},
355-
}}
343+
rules={{ required: 'Slug is required' }}
356344
render={({ field }) => (
357345
<FormItem className="w-full">
358346
<FormLabel>Organization Slug</FormLabel>

clients/apps/web/src/components/Onboarding/v2/ProductDetailsStep.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useAuth } from '@/hooks'
44
import * as Sentry from '@sentry/nextjs'
55
import { useCreateOrganization } from '@/hooks/queries'
6-
import { isValidationError, schemas } from '@polar-sh/client'
6+
import { schemas } from '@polar-sh/client'
77
import { Box } from '@polar-sh/orbit/Box'
88
import Button from '@polar-sh/ui/components/atoms/Button'
99
import Input from '@polar-sh/ui/components/atoms/Input'
@@ -24,7 +24,6 @@ import { AUPBlocker } from './AUPBlocker'
2424
import { ChipSelect } from './ChipSelect'
2525
import { useOnboardingData } from './OnboardingContext'
2626
import { OnboardingShell } from './OnboardingShell'
27-
import { getOrganizationCreateErrorMessage } from './validation'
2827

2928
const SELLING_CATEGORIES = [
3029
{ name: 'Software / SaaS', prohibited: false },
@@ -166,14 +165,13 @@ export function ProductDetailsStep() {
166165
})
167166

168167
if (error) {
169-
const errorMessage = isValidationError(error.detail)
170-
? getOrganizationCreateErrorMessage(error.detail)
171-
: typeof error.detail === 'string'
172-
? error.detail
173-
: 'Something went wrong, please try again.'
174-
175168
form.setError('root', {
176-
message: errorMessage,
169+
message:
170+
typeof error.detail === 'string'
171+
? error.detail
172+
: Array.isArray(error.detail)
173+
? (error.detail[0]?.msg ?? 'Validation failed')
174+
: 'Something went wrong, please try again.',
177175
})
178176
showApiResponse(400, 'Failed to create organization')
179177
return false

clients/apps/web/src/components/Onboarding/v2/validation.test.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

clients/apps/web/src/components/Onboarding/v2/validation.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)