polar icon indicating copy to clipboard operation
polar copied to clipboard

Button remains disabled after 'slug reserved' error (Organization Creation)

Open chrisdadev13 opened this issue 1 year ago • 1 comments

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
Screenshot 2024-09-06 at 11 25 55 PM Screenshot 2024-09-06 at 11 27 04 PM

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])

chrisdadev13 avatar Sep 07 '24 03:09 chrisdadev13