Skip to content

Commit

Permalink
chore: revert examples changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alicanerdurmaz committed Jul 26, 2024
1 parent 6770046 commit 9be8601
Show file tree
Hide file tree
Showing 148 changed files with 385 additions and 377 deletions.
4 changes: 2 additions & 2 deletions examples/access-control-casbin/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

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

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

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

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

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

const postData = query?.data?.data;
const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
resource: "categories",
defaultValue: postData?.category.id,
Expand Down
20 changes: 10 additions & 10 deletions examples/app-crm-minimal/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,10 @@ export const AccountSettings = ({ opened, setOpened, userId }: Props) => {
* formProps -> It's an instance of HTML form that manages form state and actions like onFinish, onValuesChange, etc.
* https://refine.dev/docs/ui-integrations/ant-design/hooks/use-form/#form
*
* query -> contains the result of the query. For example, isLoading, data, error, etc.
* https://refine.dev/docs/packages/react-hook-form/use-form/#query
* queryResult -> contains the result of the query. For example, isLoading, data, error, etc.
* https://refine.dev/docs/packages/react-hook-form/use-form/#queryresult
*/
const { saveButtonProps, formProps, query } = useForm<
const { saveButtonProps, formProps, queryResult } = useForm<
/**
* GetFields is used to get the fields of the mutation i.e., in this case, fields are name, email, jobTitle, and phone
* https://refine.dev/docs/data/packages/nestjs-query/#getfields
Expand Down Expand Up @@ -878,14 +878,14 @@ export const AccountSettings = ({ opened, setOpened, userId }: Props) => {
gqlMutation: UPDATE_USER_MUTATION,
},
});
const { avatarUrl, name } = query?.data?.data || {};
const { avatarUrl, name } = queryResult?.data?.data || {};

const closeModal = () => {
setOpened(false);
};

// if query is processing, show a loading indicator
if (query?.isLoading) {
if (queryResult?.isLoading) {
return (
<Drawer
open={opened}
Expand Down Expand Up @@ -1769,8 +1769,8 @@ const TasksEditPage = () => {
// create a modal form to edit a task using the useModalForm hook
// modalProps -> It's an instance of Modal that manages modal state and actions like onOk, onCancel, etc.
// close -> It's a function that closes the modal
// query -> It's an instance of useQuery from react-query
const { modalProps, close, query } = useModalForm<Task>({
// queryResult -> It's an instance of useQuery from react-query
const { modalProps, close, queryResult } = useModalForm<Task>({
// specify the action to perform i.e., create or edit
action: "edit",
// specify whether the modal should be visible by default
Expand All @@ -1781,10 +1781,10 @@ const TasksEditPage = () => {
},
});

// get the data of the task from the query
const { description, dueDate, users, title } = query?.data?.data ?? {};
// get the data of the task from the queryResult
const { description, dueDate, users, title } = queryResult?.data?.data ?? {};

const isLoading = query?.isLoading ?? true;
const isLoading = queryResult?.isLoading ?? true;

return (
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Props = {
};

export const AccountSettings = ({ opened, setOpened, userId }: Props) => {
const { saveButtonProps, formProps, query } = useForm<
const { saveButtonProps, formProps, queryResult } = useForm<
GetFields<UpdateUserMutation>,
HttpError,
GetVariables<UpdateUserMutationVariables>
Expand All @@ -35,13 +35,13 @@ export const AccountSettings = ({ opened, setOpened, userId }: Props) => {
gqlMutation: UPDATE_USER_MUTATION,
},
});
const { avatarUrl, name } = query?.data?.data || {};
const { avatarUrl, name } = queryResult?.data?.data || {};

const closeModal = () => {
setOpened(false);
};

if (query?.isLoading) {
if (queryResult?.isLoading) {
return (
<Drawer
open={opened}
Expand Down
4 changes: 2 additions & 2 deletions 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,7 @@ import { getNameInitials } from "@/utilities";
import { UPDATE_COMPANY_MUTATION } from "./queries";

export const CompanyForm = () => {
const { saveButtonProps, formProps, formLoading, query } = useForm<
const { saveButtonProps, formProps, formLoading, queryResult } = useForm<
GetFields<UpdateCompanyMutation>,
HttpError,
GetVariables<UpdateCompanyMutationVariables>
Expand All @@ -35,7 +35,7 @@ export const CompanyForm = () => {
gqlMutation: UPDATE_COMPANY_MUTATION,
},
});
const { avatarUrl, name } = query?.data?.data || {};
const { avatarUrl, name } = queryResult?.data?.data || {};

const { selectProps: selectPropsUsers, queryResult: queryResultUsers } =
useSelect<GetFieldsFromList<UsersSelectQuery>>({
Expand Down
6 changes: 3 additions & 3 deletions examples/app-crm-minimal/src/routes/tasks/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ export const TasksEditPage = () => {
const [activeKey, setActiveKey] = useState<string | undefined>();

const { list } = useNavigation();
const { modalProps, close, query } = useModalForm<Task>({
const { modalProps, close, queryResult } = useModalForm<Task>({
action: "edit",
defaultVisible: true,
meta: {
gqlMutation: UPDATE_TASK_MUTATION,
},
});

const { description, dueDate, users, title } = query?.data?.data ?? {};
const isLoading = query?.isLoading ?? true;
const { description, dueDate, users, title } = queryResult?.data?.data ?? {};
const isLoading = queryResult?.isLoading ?? true;

return (
<Modal
Expand Down
31 changes: 16 additions & 15 deletions examples/app-crm/src/routes/calendar/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,27 @@ export const CalendarEditPage: React.FC = () => {
const { id } = useResource();
const { list } = useNavigation();

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

useEffect(() => {
const startDate = query?.data?.data.startDate;
const endDate = query?.data?.data.endDate;
const startDate = queryResult?.data?.data.startDate;
const endDate = queryResult?.data?.data.endDate;
const utcStartDate = dayjs(startDate).utc();
const utcEndDate = dayjs(endDate).utc();

form.setFieldsValue({
categoryId: query?.data?.data.category.id,
participantIds: query?.data?.data.participants.map(
categoryId: queryResult?.data?.data.category.id,
participantIds: queryResult?.data?.data.participants.map(
(participant) => participant.id,
),
});
Expand All @@ -54,7 +55,7 @@ export const CalendarEditPage: React.FC = () => {
time: [utcStartDate, utcEndDate],
});
}
}, [query?.data]);
}, [queryResult?.data]);

const handleOnFinish = async (values: any) => {
const { rangeDate, date, time, color, ...otherValues } = values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { COMPANY_TITLE_FORM_MUTATION, COMPANY_TITLE_QUERY } from "./queries";
import styles from "./title-form.module.css";

export const CompanyTitleForm = () => {
const { formProps, query, onFinish } = useForm<
const { formProps, queryResult, onFinish } = useForm<
GetFields<CompanyTitleFormMutation>,
HttpError,
GetVariables<CompanyTitleFormMutationVariables>
Expand All @@ -32,8 +32,8 @@ export const CompanyTitleForm = () => {
},
});

const company = query?.data?.data;
const loading = query?.isLoading;
const company = queryResult?.data?.data;
const loading = queryResult?.isLoading;

return (
<Form {...formProps}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const columns = [
export const ProductsServices = () => {
const params = useParams<{ id: string }>();

const { formProps, autoSaveProps, query } = useForm<
const { formProps, autoSaveProps, queryResult } = useForm<
GetFields<QuotesUpdateQuoteMutation>,
HttpError,
GetVariables<QuotesUpdateQuoteMutationVariables>
Expand Down Expand Up @@ -149,9 +149,9 @@ export const ProductsServices = () => {
},
});

const { isLoading = false, isFetching = false, refetch } = query ?? {};
const { isLoading = false, isFetching = false, refetch } = queryResult ?? {};

const { total, subTotal, items } = query?.data?.data ?? {};
const { total, subTotal, items } = queryResult?.data?.data ?? {};

return (
<div
Expand Down Expand Up @@ -415,7 +415,11 @@ const TaxForm = (props: {
}) => {
const params = useParams<{ id: string }>();

const { formProps, query } = useForm<Quote, HttpError, QuoteUpdateInput>({
const { formProps, queryResult } = useForm<
Quote,
HttpError,
QuoteUpdateInput
>({
resource: "quotes",
action: "edit",
id: params.id,
Expand All @@ -433,7 +437,7 @@ const TaxForm = (props: {
},
});

const formLoading = query?.isLoading ?? false;
const formLoading = queryResult?.isLoading ?? false;

if (formLoading) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const MDEditor = lazy(() => import("@uiw/react-md-editor"));
export const ShowDescription = () => {
const params = useParams<{ id: string }>();

const { formProps, query, autoSaveProps } = useForm<
const { formProps, queryResult, autoSaveProps } = useForm<
Quote,
HttpError,
QuoteUpdateInput
Expand All @@ -35,7 +35,7 @@ export const ShowDescription = () => {
},
});

const formLoading = query?.isLoading ?? false;
const formLoading = queryResult?.isLoading ?? false;

return (
<Spin spinning={formLoading}>
Expand Down
4 changes: 2 additions & 2 deletions examples/app-crm/src/routes/scrumboard/sales/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
export const SalesEditPage = () => {
const { list } = useNavigation();

const { formProps, modalProps, close, query } = useModalForm<
const { formProps, modalProps, close, queryResult } = useModalForm<
GetFields<SalesUpdateDealMutation>,
HttpError,
DealUpdateInput
Expand Down Expand Up @@ -53,7 +53,7 @@ export const SalesEditPage = () => {
const { selectProps: userSelectProps, queryResult: userSelectQueryResult } =
useUsersSelect();

const deal = query?.data?.data;
const deal = queryResult?.data?.data;

const companyIdField = Form.useWatch("companyId", formProps.form);

Expand Down
12 changes: 7 additions & 5 deletions examples/app-crm/src/routes/scrumboard/sales/finalize-deal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const SalesFinalizeDeal = () => {
const invalidate = useInvalidate();
const { list } = useNavigation();

const { formProps, modalProps, close, query } = useModalForm<
const { formProps, modalProps, close, queryResult } = useModalForm<
Deal,
HttpError,
FormValues
Expand All @@ -48,14 +48,16 @@ export const SalesFinalizeDeal = () => {
});

useEffect(() => {
const month = query?.data?.data?.closeDateMonth ?? new Date().getMonth();
const day = query?.data?.data?.closeDateDay ?? new Date().getDay();
const year = query?.data?.data?.closeDateYear ?? new Date().getFullYear();
const month =
queryResult?.data?.data?.closeDateMonth ?? new Date().getMonth();
const day = queryResult?.data?.data?.closeDateDay ?? new Date().getDay();
const year =
queryResult?.data?.data?.closeDateYear ?? new Date().getFullYear();

formProps.form?.setFieldsValue({
closeDate: dayjs(new Date(year, month - 1, day)),
});
}, [query?.data?.data]);
}, [queryResult?.data?.data]);

return (
<Modal
Expand Down
6 changes: 3 additions & 3 deletions 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, query },
refineCore: { onFinish, formLoading, queryResult },
register,
handleSubmit,
resetField,
Expand All @@ -19,7 +19,7 @@ export const PostEdit: React.FC = () => {

const { options } = useSelect({
resource: "categories",
defaultValue: query?.data?.data.category.id,
defaultValue: queryResult?.data?.data.category.id,
});

useEffect(() => {
Expand Down Expand Up @@ -56,7 +56,7 @@ export const PostEdit: React.FC = () => {
{...register("category.id", {
required: true,
})}
defaultValue={query?.data?.data.category.id}
defaultValue={queryResult?.data?.data.category.id}
>
{options?.map((category) => (
<option key={category.value} value={category.value}>
Expand Down
4 changes: 2 additions & 2 deletions examples/auth-antd/src/pages/posts/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import MDEditor from "@uiw/react-md-editor";
import type { IPost, ICategory } from "../../interfaces";

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

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

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

const postData = query?.data?.data;
const postData = queryResult?.data?.data;
const { selectProps: categorySelectProps } = useSelect<ICategory>({
resource: "categories",
defaultValue: postData?.category.id,
Expand Down
Loading

0 comments on commit 9be8601

Please sign in to comment.