Fix URL by removing slash and backslash (#1733)

* Fix URl by removing slash and backslash

* Implement slugify

* Add data type

* Fixing folder structure

* Solve zod-utils conflict
This commit is contained in:
Juan Esteban Nieto Cifuentes authored and GitHub committed 2022-02-21 09:53:16 -07:00
1 parent 95b3397e42
commit 7585e9b32e
3 files changed
+90 -84

No files matched your search

@@ -12,6 +12,7 @@ import { HttpError } from "@lib/core/http/error";
import { useLocale } from "@lib/hooks/useLocale";
import { useToggleQuery } from "@lib/hooks/useToggleQuery";
import showToast from "@lib/notification";
import { slugify } from "@lib/slugify";
import { trpc } from "@lib/trpc";
import { Dialog, DialogClose, DialogContent } from "@components/Dialog";
@@ -67,7 +68,7 @@ export default function CreateEventTypeButton(props: Props) {
useEffect(() => {
const subscription = watch((value, { name, type }) => {
if (name === "title" && type === "change") {
if (value.title) setValue("slug", value.title.replace(/\s+/g, "-").toLowerCase());
if (value.title) setValue("slug", slugify(value.title));
else setValue("slug", "");
}
});