Merge branch 'main' into enterprise-license

staging
kodiakhq[bot] 2022-04-26 02:15:48 +00:00 committed by GitHub
commit b0a6142ccc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 12 deletions

View File

@ -56,23 +56,32 @@ export default function CreateEventTypeButton(props: Props) {
: undefined; : undefined;
const pageSlug = router.query.eventPage || props.options[0].slug; const pageSlug = router.query.eventPage || props.options[0].slug;
const hasTeams = !!props.options.find((option) => option.teamId); const hasTeams = !!props.options.find((option) => option.teamId);
const title: string =
typeof router.query.title === "string" && router.query.title ? router.query.title : "";
const length: number =
typeof router.query.length === "string" && router.query.length ? parseInt(router.query.length) : 15;
const description: string =
typeof router.query.description === "string" && router.query.description ? router.query.description : "";
const slug: string = typeof router.query.slug === "string" && router.query.slug ? router.query.slug : "";
const type: string = typeof router.query.type == "string" && router.query.type ? router.query.type : ""; const type: string = typeof router.query.type == "string" && router.query.type ? router.query.type : "";
const form = useForm<z.infer<typeof createEventTypeInput>>({ const form = useForm<z.infer<typeof createEventTypeInput>>({
resolver: zodResolver(createEventTypeInput), resolver: zodResolver(createEventTypeInput),
}); });
const { setValue, watch, register } = form; const { setValue, watch, register } = form;
setValue("title", title);
setValue("length", length); useEffect(() => {
setValue("description", description); if (!router.isReady) return;
setValue("slug", slug);
const title: string =
typeof router.query.title === "string" && router.query.title ? router.query.title : "";
const length: number =
typeof router.query.length === "string" && router.query.length ? parseInt(router.query.length) : 15;
const description: string =
typeof router.query.description === "string" && router.query.description
? router.query.description
: "";
const slug: string = typeof router.query.slug === "string" && router.query.slug ? router.query.slug : "";
setValue("title", title);
setValue("length", length);
setValue("description", description);
setValue("slug", slug);
// If query params change, update the form
}, [router.isReady, router.query, setValue]);
useEffect(() => { useEffect(() => {
const subscription = watch((value, { name, type }) => { const subscription = watch((value, { name, type }) => {
@ -86,7 +95,7 @@ export default function CreateEventTypeButton(props: Props) {
const createMutation = trpc.useMutation("viewer.eventTypes.create", { const createMutation = trpc.useMutation("viewer.eventTypes.create", {
onSuccess: async ({ eventType }) => { onSuccess: async ({ eventType }) => {
await router.push("/event-types/" + eventType.id); await router.replace("/event-types/" + eventType.id);
showToast(t("event_type_created_successfully", { eventTypeTitle: eventType.title }), "success"); showToast(t("event_type_created_successfully", { eventTypeTitle: eventType.title }), "success");
}, },
onError: (err) => { onError: (err) => {