Skip to content

Commit

Permalink
chore: run codemod use-form-query-and-mutation-result for all examp…
Browse files Browse the repository at this point in the history
…les (#6190)
  • Loading branch information
alicanerdurmaz authored Jul 30, 2024
1 parent 9be8601 commit ebe5643
Show file tree
Hide file tree
Showing 137 changed files with 284 additions and 182 deletions.
2 changes: 1 addition & 1 deletion examples/access-control-casbin/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IPost>();
const { formProps, saveButtonProps, query: queryResult } = useForm<IPost>();

const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
Expand Down
2 changes: 1 addition & 1 deletion examples/access-control-cerbos/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IPost>();
const { formProps, saveButtonProps, query: queryResult } = useForm<IPost>();

const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
Expand Down
2 changes: 1 addition & 1 deletion examples/access-control-permify/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IPost>();
const { formProps, saveButtonProps, query: queryResult } = useForm<IPost>();

const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ type Props = {
};

export const AccountSettings = ({ opened, setOpened, userId }: Props) => {
const { saveButtonProps, formProps, queryResult } = useForm<
const {
saveButtonProps,
formProps,
query: queryResult,
} = useForm<
GetFields<UpdateUserMutation>,
HttpError,
GetVariables<UpdateUserMutationVariables>
Expand Down
7 changes: 6 additions & 1 deletion examples/app-crm-minimal/src/routes/companies/edit/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ import { getNameInitials } from "@/utilities";
import { UPDATE_COMPANY_MUTATION } from "./queries";

export const CompanyForm = () => {
const { saveButtonProps, formProps, formLoading, queryResult } = useForm<
const {
saveButtonProps,
formProps,
formLoading,
query: queryResult,
} = useForm<
GetFields<UpdateCompanyMutation>,
HttpError,
GetVariables<UpdateCompanyMutationVariables>
Expand Down
27 changes: 16 additions & 11 deletions examples/app-crm/src/routes/calendar/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ export const CalendarEditPage: React.FC = () => {
const { id } = useResource();
const { list } = useNavigation();

const { formProps, saveButtonProps, form, onFinish, queryResult } =
useForm<Event>({
action: "edit",
id,
queryOptions: {
enabled: true,
},
meta: {
gqlMutation: CALENDAR_UPDATE_EVENT_MUTATION,
},
});
const {
formProps,
saveButtonProps,
form,
onFinish,
query: queryResult,
} = useForm<Event>({
action: "edit",
id,
queryOptions: {
enabled: true,
},
meta: {
gqlMutation: CALENDAR_UPDATE_EVENT_MUTATION,
},
});

useEffect(() => {
const startDate = queryResult?.data?.data.startDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import { COMPANY_TITLE_FORM_MUTATION, COMPANY_TITLE_QUERY } from "./queries";
import styles from "./title-form.module.css";

export const CompanyTitleForm = () => {
const { formProps, queryResult, onFinish } = useForm<
const {
formProps,
query: queryResult,
onFinish,
} = useForm<
GetFields<CompanyTitleFormMutation>,
HttpError,
GetVariables<CompanyTitleFormMutationVariables>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ const columns = [
export const ProductsServices = () => {
const params = useParams<{ id: string }>();

const { formProps, autoSaveProps, queryResult } = useForm<
const {
formProps,
autoSaveProps,
query: queryResult,
} = useForm<
GetFields<QuotesUpdateQuoteMutation>,
HttpError,
GetVariables<QuotesUpdateQuoteMutationVariables>
Expand Down Expand Up @@ -415,7 +419,7 @@ const TaxForm = (props: {
}) => {
const params = useParams<{ id: string }>();

const { formProps, queryResult } = useForm<
const { formProps, query: queryResult } = useForm<
Quote,
HttpError,
QuoteUpdateInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const MDEditor = lazy(() => import("@uiw/react-md-editor"));
export const ShowDescription = () => {
const params = useParams<{ id: string }>();

const { formProps, queryResult, autoSaveProps } = useForm<
Quote,
HttpError,
QuoteUpdateInput
>({
const {
formProps,
query: queryResult,
autoSaveProps,
} = useForm<Quote, HttpError, QuoteUpdateInput>({
resource: "quotes",
action: "edit",
id: params.id,
Expand Down
2 changes: 1 addition & 1 deletion examples/audit-log-provider/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const PostEdit: React.FC = () => {
const { resourceName, id } = useResource();

const {
refineCore: { onFinish, formLoading, queryResult },
refineCore: { onFinish, formLoading, query: queryResult },
register,
handleSubmit,
resetField,
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-antd/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IPost>();
const { formProps, saveButtonProps, query: queryResult } = useForm<IPost>();

const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-auth0/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IPost>();
const { formProps, saveButtonProps, query: queryResult } = useForm<IPost>();

const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-chakra-ui/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { IPost } from "../../interfaces";

export const PostEdit = () => {
const {
refineCore: { formLoading, queryResult },
refineCore: { formLoading, query: queryResult },
saveButtonProps,
register,
formState: { errors },
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-google-login/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IPost>();
const { formProps, saveButtonProps, query: queryResult } = useForm<IPost>();

const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-headless/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSelect } from "@refinedev/core";

export const PostEdit: React.FC = () => {
const {
refineCore: { onFinish, formLoading, queryResult },
refineCore: { onFinish, formLoading, query: queryResult },
register,
handleSubmit,
resetField,
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-keycloak/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IPost>();
const { formProps, saveButtonProps, query: queryResult } = useForm<IPost>();

const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-mantine/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const PostEdit: React.FC = () => {
const {
saveButtonProps,
getInputProps,
refineCore: { queryResult },
refineCore: { query: queryResult },
errors,
} = useForm({
initialValues: {
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-material-ui/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { IPost, ICategory, IStatus, Nullable } from "../../interfaces";
export const PostEdit: React.FC = () => {
const {
saveButtonProps,
refineCore: { queryResult },
refineCore: { query: queryResult },
register,
control,
formState: { errors },
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-otp/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IPost>();
const { formProps, saveButtonProps, query: queryResult } = useForm<IPost>();

const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
Expand Down
18 changes: 11 additions & 7 deletions examples/base-antd/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult, autoSaveProps } =
useForm<IPost>({
warnWhenUnsavedChanges: true,
autoSave: {
enabled: true,
},
});
const {
formProps,
saveButtonProps,
query: queryResult,
autoSaveProps,
} = useForm<IPost>({
warnWhenUnsavedChanges: true,
autoSave: {
enabled: true,
},
});

const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
Expand Down
2 changes: 1 addition & 1 deletion examples/base-chakra-ui/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { IPost } from "../../interfaces";

export const PostEdit = () => {
const {
refineCore: { formLoading, queryResult, autoSaveProps },
refineCore: { formLoading, query: queryResult, autoSaveProps },
saveButtonProps,
register,
formState: { errors },
Expand Down
2 changes: 1 addition & 1 deletion examples/base-headless/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSelect } from "@refinedev/core";

export const PostEdit: React.FC = () => {
const {
refineCore: { onFinish, formLoading, queryResult },
refineCore: { onFinish, formLoading, query: queryResult },
register,
handleSubmit,
resetField,
Expand Down
2 changes: 1 addition & 1 deletion examples/base-mantine/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const PostEdit: React.FC = () => {
saveButtonProps,
getInputProps,
errors,
refineCore: { queryResult, autoSaveProps },
refineCore: { query: queryResult, autoSaveProps },
} = useForm({
initialValues: {
title: "",
Expand Down
2 changes: 1 addition & 1 deletion examples/base-material-ui/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { IPost, ICategory, Nullable, IStatus } from "../../interfaces";
export const PostEdit: React.FC = () => {
const {
saveButtonProps,
refineCore: { queryResult, autoSaveProps },
refineCore: { query: queryResult, autoSaveProps },
register,
control,
formState: { errors },
Expand Down
6 changes: 5 additions & 1 deletion examples/blog-invoice-generator/src/pages/contacts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { Form, Select, Input } from "antd";
import type { IContact } from "interfaces";

export const ContactEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IContact>({
const {
formProps,
saveButtonProps,
query: queryResult,
} = useForm<IContact>({
metaData: { populate: ["client"] },
});

Expand Down
6 changes: 5 additions & 1 deletion examples/blog-invoice-generator/src/pages/invoice/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { Form, Input, Select } from "antd";
import type { IInvoice } from "interfaces";

export const InvoiceEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IInvoice>({
const {
formProps,
saveButtonProps,
query: queryResult,
} = useForm<IInvoice>({
metaData: { populate: ["company", "contact", "missions"] },
});

Expand Down
2 changes: 1 addition & 1 deletion examples/blog-material-ui/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { IPost, ICategory, Nullable } from "interfaces";

export const PostEdit: React.FC = () => {
const {
refineCore: { formLoading, queryResult },
refineCore: { formLoading, query: queryResult },
saveButtonProps,
register,
control,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useForm } from "@refinedev/react-hook-form";

export const PostCreate = () => {
const {
refineCore: { formLoading, queryResult },
refineCore: { formLoading, query: queryResult },
saveButtonProps,
register,
resetField,
Expand Down
2 changes: 1 addition & 1 deletion examples/blog-ra-chakra-tutorial/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useSelect } from "@refinedev/core";

export const PostEdit = () => {
const {
refineCore: { formLoading, queryResult },
refineCore: { formLoading, query: queryResult },
saveButtonProps,
register,
setValue,
Expand Down
2 changes: 1 addition & 1 deletion examples/blog-react-dnd/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost } from "interfaces";

export const PostEdit = () => {
const { formProps, saveButtonProps, queryResult } = useForm<IPost>();
const { formProps, saveButtonProps, query: queryResult } = useForm<IPost>();

const { selectProps: categorySelectProps } = useSelect<IPost>({
resource: "categories",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";

export const PostCreate: React.FC = () => {
const {
refineCore: { onFinish, formLoading, queryResult },
refineCore: { onFinish, formLoading, query: queryResult },
register,
handleSubmit,
formState: { errors },
Expand Down
2 changes: 1 addition & 1 deletion examples/blog-refine-airtable-crud/src/pages/post/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useEffect } from "react";

export const PostEdit: React.FC = () => {
const {
refineCore: { onFinish, formLoading, queryResult },
refineCore: { onFinish, formLoading, query: queryResult },
register,
handleSubmit,
resetField,
Expand Down
2 changes: 1 addition & 1 deletion examples/blog-refine-daisyui/src/pages/categories/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const CategoryEdit = () => {
const { list } = useNavigation();

const {
refineCore: { onFinish, queryResult },
refineCore: { onFinish, query: queryResult },
register,
handleSubmit,
formState: { errors },
Expand Down
2 changes: 1 addition & 1 deletion examples/blog-refine-daisyui/src/pages/products/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const ProductEdit = () => {
const { list } = useNavigation();

const {
refineCore: { onFinish, queryResult },
refineCore: { onFinish, query: queryResult },
register,
handleSubmit,
setValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const PostEdit = () => {
const {
getInputProps,
saveButtonProps,
refineCore: { queryResult },
refineCore: { query: queryResult },
} = useForm({
initialValues: {
id: "",
Expand Down
Loading

0 comments on commit ebe5643

Please sign in to comment.