Implement URL validation on default videos links (#7087)
This commit is contained in:
1 parent
77600f8168
commit
1c97e549eb
6 files changed
+47
-6
No files matched your search
@@ -1,7 +1,9 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { EventLocationType } from "@calcom/app-store/locations";
|
||||
import { EventLocationType, getEventLocationType } from "@calcom/app-store/locations";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import {
|
||||
@@ -31,13 +33,22 @@ export function AppSetDefaultLinkDailog({
|
||||
const utils = trpc.useContext();
|
||||
|
||||
const { t } = useLocale();
|
||||
const form = useForm<LocationTypeSetLinkDialogFormProps>({});
|
||||
const eventLocationTypeOptions = getEventLocationType(locationType.type);
|
||||
|
||||
const form = useForm<LocationTypeSetLinkDialogFormProps>({
|
||||
resolver: zodResolver(
|
||||
z.object({ link: z.string().regex(new RegExp(eventLocationTypeOptions?.urlRegExp ?? "")) })
|
||||
),
|
||||
});
|
||||
|
||||
const updateDefaultAppMutation = trpc.viewer.updateUserDefaultConferencingApp.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast("Default app updated successfully", "success");
|
||||
utils.viewer.getUsersDefaultConferencingApp.invalidate();
|
||||
},
|
||||
onError: () => {
|
||||
showToast(`Invalid App Link Format`, "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user