feat: trpc v10 migration (#5332)

* migrate router

* createTRPCReact

* frontend 1

* random format change

* frontend 2

* withQuery

* form router

* TS-ERROR: proxy on utils-client

* inferance

* ssg

* reuse

* trpc rc4

* Apply suggestions from code review

* skip test

* move skip one level up

* whops

* rc 6 with new setData func

Co-authored-by: zomars <[email protected]>
This commit is contained in:
Julius Marmingeandzomars authored and GitHub committed 2022-11-10 23:40:01 +00:00
1 parent 6d67808627
commit db7c3fb52f
157 files changed
+3062 -3144

No files matched your search

@@ -4,7 +4,7 @@ import { Controller, useForm } from "react-hook-form";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { inferQueryOutput } from "@calcom/trpc/react";
import { RouterOutputs } from "@calcom/trpc/react";
import { Button } from "@calcom/ui/components/button";
import { Form, Label, TextArea, TextField } from "@calcom/ui/components/form";
import Switch from "@calcom/ui/v2/core/Switch";
@@ -14,7 +14,7 @@ import Select from "@calcom/ui/v2/core/form/select";
import customTemplate, { hasTemplateIntegration } from "../lib/integrationTemplate";
import WebhookTestDisclosure from "./WebhookTestDisclosure";
export type TWebhook = inferQueryOutput<"viewer.webhook.list">[number];
export type TWebhook = RouterOutputs["viewer"]["webhook"]["list"][number];
export type WebhookFormData = {
id?: string;
@@ -1,6 +1,6 @@
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { inferQueryOutput, trpc } from "@calcom/trpc/react";
import { RouterOutputs, trpc } from "@calcom/trpc/react";
import { Icon } from "@calcom/ui/Icon";
import { Badge } from "@calcom/ui/components/badge";
import { Button } from "@calcom/ui/components/button";
@@ -8,7 +8,7 @@ import Switch from "@calcom/ui/v2/core/Switch";
import { Tooltip } from "@calcom/ui/v2/core/Tooltip";
import showToast from "@calcom/ui/v2/core/notifications";
export type TWebhook = inferQueryOutput<"viewer.webhook.list">[number];
export type TWebhook = RouterOutputs["viewer"]["webhook"]["list"][number];
export default function WebhookListItem(props: {
webhook: TWebhook;
@@ -18,16 +18,16 @@ export default function WebhookListItem(props: {
const { t } = useLocale();
const utils = trpc.useContext();
const { webhook } = props;
const deleteWebhook = trpc.useMutation("viewer.webhook.delete", {
const deleteWebhook = trpc.viewer.webhook.delete.useMutation({
async onSuccess() {
await utils.invalidateQueries(["viewer.webhook.list"]);
await utils.viewer.webhook.list.invalidate();
showToast(t("webhook_removed_successfully"), "success");
},
});
const toggleWebhook = trpc.useMutation("viewer.webhook.edit", {
const toggleWebhook = trpc.viewer.webhook.edit.useMutation({
async onSuccess(data) {
console.log("data", data);
await utils.invalidateQueries(["viewer.webhook.list"]);
await utils.viewer.webhook.list.invalidate();
// TODO: Better success message
showToast(t(data?.active ? "enabled" : "disabled"), "success");
},
@@ -11,7 +11,7 @@ export default function WebhookTestDisclosure() {
const subscriberUrl: string = useWatch({ name: "subscriberUrl" });
const payloadTemplate = useWatch({ name: "payloadTemplate" }) || null;
const { t } = useLocale();
const mutation = trpc.useMutation("viewer.webhook.testTrigger", {
const mutation = trpc.viewer.webhook.testTrigger.useMutation({
onError(err) {
showToast(err.message, "error");
},