polar
polar copied to clipboard
Button remains disabled after 'slug reserved' error (Organization Creation)
https://polar.sh/dashboard/create
after clicking the <Button> 'Create' </Button> with a reserved slug (in this case the slug is 'dashboard')
The <Button> 'Create' </Button> should be enabled once we change the slug to a non-reserved slug
maybe clearing errors when the slug changes would help?
useEffect(() => {
if (!editedSlug && name) {
setValue('slug', slugify(name, { lower: true, strict: true }))
} else if (slug) {
setValue(
'slug',
slugify(slug, { lower: true, trim: false, strict: true }),
)
clearErrors('root')
}
}, [name, editedSlug, slug, setValue])
useEffect(() => {
if (
existingOrganizations &&
existingOrganizations.pagination.total_count > 0
) {
setError('root', {
type: 'manual',
message: 'An organization with this slug already exists.',
})
} else {
clearErrors('root')
}
}, [existingOrganizations, setError, clearErrors])