fix: workspace url error message (#809)

This commit is contained in:
Anmol Singh Bhatia 2023-04-13 15:46:25 +05:30 committed by GitHub
parent 3457411c6a
commit dc9ce5101c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,6 +42,7 @@ export const CreateWorkspaceForm: React.FC<Props> = ({
setDefaultValues,
}) => {
const [slugError, setSlugError] = useState(false);
const [invalidSlug, setInvalidSlug] = useState(false);
const { setToastAlert } = useToast();
@ -130,11 +131,20 @@ export const CreateWorkspaceForm: React.FC<Props> = ({
name="slug"
register={register}
className="block w-full rounded-md bg-transparent py-2 px-0 text-sm"
validations={{
required: "Workspace URL is required",
}}
onChange={(e) =>
/^[a-zA-Z0-9_-]+$/.test(e.target.value) ? setInvalidSlug(false) : setInvalidSlug(true)
}
/>
</div>
{slugError && (
<span className="-mt-3 text-sm text-red-500">Workspace URL is already taken!</span>
)}
{invalidSlug && (
<span className="text-sm text-red-500">{`URL can only contain ( - ), ( _ ) & Alphanumeric characters.`}</span>
)}
</div>
</div>