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:
1 parent
6d67808627
commit
db7c3fb52f
157 files changed
+3062
-3144
No files matched your search
@@ -62,7 +62,7 @@ export function NewWorkflowButton() {
|
||||
resolver: zodResolver(formSchema),
|
||||
});
|
||||
|
||||
const createMutation = trpc.useMutation("viewer.workflows.create", {
|
||||
const createMutation = trpc.viewer.workflows.create.useMutation({
|
||||
onSuccess: async ({ workflow }) => {
|
||||
await router.replace("/workflows/" + workflow.id);
|
||||
setIsPhoneNumberNeeded(false);
|
||||
|
||||
@@ -33,7 +33,7 @@ export default function WorkflowDetailsPage(props: Props) {
|
||||
const [reload, setReload] = useState(false);
|
||||
const [editCounter, setEditCounter] = useState(0);
|
||||
|
||||
const { data, isLoading } = trpc.useQuery(["viewer.eventTypes"]);
|
||||
const { data, isLoading } = trpc.viewer.eventTypes.getByViewer.useQuery();
|
||||
|
||||
const eventTypeOptions = useMemo(
|
||||
() =>
|
||||
@@ -50,10 +50,10 @@ export default function WorkflowDetailsPage(props: Props) {
|
||||
[data]
|
||||
);
|
||||
|
||||
const updateMutation = trpc.useMutation("viewer.workflows.update", {
|
||||
const updateMutation = trpc.viewer.workflows.update.useMutation({
|
||||
onSuccess: async ({ workflow }) => {
|
||||
if (workflow) {
|
||||
utils.setQueryData(["viewer.workflows.get", { id: +workflow.id }], workflow);
|
||||
utils.viewer.workflows.get.setData({ id: +workflow.id }, workflow);
|
||||
|
||||
showToast(
|
||||
t("workflow_updated_successfully", {
|
||||
@@ -95,6 +95,7 @@ export default function WorkflowDetailsPage(props: Props) {
|
||||
reminderBody: null,
|
||||
emailSubject: null,
|
||||
template: WorkflowTemplates.REMINDER,
|
||||
numberRequired: null,
|
||||
};
|
||||
steps?.push(step);
|
||||
form.setValue("steps", steps);
|
||||
|
||||
@@ -35,11 +35,11 @@ export default function WorkflowListPage({ workflows }: Props) {
|
||||
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
||||
const [deleteDialogTypeId, setDeleteDialogTypeId] = useState(0);
|
||||
|
||||
const query = trpc.useQuery(["viewer.workflows.list"]);
|
||||
const query = trpc.viewer.workflows.list.useQuery();
|
||||
|
||||
const deleteMutation = trpc.useMutation("viewer.workflows.delete", {
|
||||
const deleteMutation = trpc.viewer.workflows.delete.useMutation({
|
||||
onSuccess: async () => {
|
||||
await utils.invalidateQueries(["viewer.workflows.list"]);
|
||||
await utils.viewer.workflows.list.invalidate();
|
||||
showToast(t("workflow_deleted_successfully"), "success");
|
||||
setDeleteDialogOpen(false);
|
||||
},
|
||||
|
||||
@@ -122,7 +122,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
|
||||
}
|
||||
};
|
||||
|
||||
const testActionMutation = trpc.useMutation("viewer.workflows.testAction", {
|
||||
const testActionMutation = trpc.viewer.workflows.testAction.useMutation({
|
||||
onSuccess: async () => {
|
||||
showToast(t("notification_sent"), "success");
|
||||
},
|
||||
|
||||
@@ -19,9 +19,9 @@ export const DeleteDialog = (props: IDeleteDialog) => {
|
||||
const { isOpenDialog, setIsOpenDialog, workflowId, additionalFunction } = props;
|
||||
const utils = trpc.useContext();
|
||||
|
||||
const deleteMutation = trpc.useMutation("viewer.workflows.delete", {
|
||||
const deleteMutation = trpc.viewer.workflows.delete.useMutation({
|
||||
onSuccess: async () => {
|
||||
await utils.invalidateQueries(["viewer.workflows.list"]);
|
||||
await utils.viewer.workflows.list.invalidate();
|
||||
additionalFunction();
|
||||
showToast(t("workflow_deleted_successfully"), "success");
|
||||
setIsOpenDialog(false);
|
||||
|
||||
@@ -38,7 +38,7 @@ const WorkflowListItem = (props: ItemProps) => {
|
||||
|
||||
const isActive = activeEventTypeIds.includes(eventType.id);
|
||||
|
||||
const activateEventTypeMutation = trpc.useMutation("viewer.workflows.activateEventType", {
|
||||
const activateEventTypeMutation = trpc.viewer.workflows.activateEventType.useMutation({
|
||||
onSuccess: async () => {
|
||||
let offOn = "";
|
||||
if (activeEventTypeIds.includes(eventType.id)) {
|
||||
@@ -158,7 +158,7 @@ type Props = {
|
||||
function EventWorkflowsTab(props: Props) {
|
||||
const { workflows } = props;
|
||||
const { t } = useLocale();
|
||||
const { data, isLoading } = trpc.useQuery(["viewer.workflows.list"]);
|
||||
const { data, isLoading } = trpc.viewer.workflows.list.useQuery();
|
||||
const router = useRouter();
|
||||
const [sortedWorkflows, setSortedWorkflows] = useState<Array<WorkflowType>>([]);
|
||||
|
||||
@@ -179,7 +179,7 @@ function EventWorkflowsTab(props: Props) {
|
||||
}
|
||||
}, [isLoading]);
|
||||
|
||||
const createMutation = trpc.useMutation("viewer.workflows.createV2", {
|
||||
const createMutation = trpc.viewer.workflows.createV2.useMutation({
|
||||
onSuccess: async ({ workflow }) => {
|
||||
await router.replace("/workflows/" + workflow.id);
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export default function WorkflowDetailsPage(props: Props) {
|
||||
const [reload, setReload] = useState(false);
|
||||
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
||||
|
||||
const { data, isLoading } = trpc.useQuery(["viewer.eventTypes"]);
|
||||
const { data, isLoading } = trpc.viewer.eventTypes.getByViewer.useQuery();
|
||||
|
||||
const eventTypeOptions = useMemo(
|
||||
() =>
|
||||
|
||||
@@ -26,7 +26,7 @@ const CreateEmptyWorkflowView = () => {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
|
||||
const createMutation = trpc.useMutation("viewer.workflows.createV2", {
|
||||
const createMutation = trpc.viewer.workflows.createV2.useMutation({
|
||||
onSuccess: async ({ workflow }) => {
|
||||
await router.replace("/workflows/" + workflow.id);
|
||||
},
|
||||
@@ -208,7 +208,7 @@ export default function WorkflowListPage({ workflows }: Props) {
|
||||
setIsOpenDialog={setDeleteDialogOpen}
|
||||
workflowId={workflowToDeleteId}
|
||||
additionalFunction={async () => {
|
||||
await utils.invalidateQueries(["viewer.workflows.list"]);
|
||||
await utils.viewer.workflows.list.invalidate();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -113,7 +113,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
|
||||
}
|
||||
};
|
||||
|
||||
const testActionMutation = trpc.useMutation("viewer.workflows.testAction", {
|
||||
const testActionMutation = trpc.viewer.workflows.testAction.useMutation({
|
||||
onSuccess: async () => {
|
||||
showToast(t("notification_sent"), "success");
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user