saveButtonProps property.onSuccess prop in the Create or Edit component. This prop is a callback function that is executed after the mutation is successfully completed.onSuccess to navigate to another page. For that, you would typically use a routing library like react-router-dom or next/router to programmatically navigate to another page.saveButtonProps, you can refer to the documentation:onSuccess prop in the Edit component. This prop is a callback function that is executed after the mutation is successfully completed.onSuccess to edit the same row. For that, you would typically use a state management library like React Context or Redux to keep track of the row that is currently being edited.saveButtonProps, you can refer to the documentation:dayjs library and the Ant Design's DatePicker which is default for Refine.getValueProps. Here is an example of how to do this:dayjs(value) is used to convert the value into a format that the DatePicker component can understand.dayjs that Refine is using. As of the time the issue was reported, the version was 1.10.5. If you are using yarn, you might encounter problems, so it's recommended to use npm instead.dayjs library is not installed or not imported correctly in your project. dayjs is a lightweight JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers. It's often used in Refine projects for handling date and time data.dayjs in your project. You can do this using npm or yarn:dayjs, you need to import it in the file where you want to use it:dayjs in your project without any issues.dayjs in a Refine project, you can refer to the Refine blog post (https://refine.dev/blog/daisy-ui-react-admin-panel#other-packages) and the Github issues (https://github.com/refinedev/refine/issues/4251) related to this topic.onSuccess prop in the Create or Edit component. This prop is a callback function that is executed after the mutation is successfully completed.onSuccess to navigate to a view page. For that, you would typically use a routing library like react-router-dom or next/router to programmatically navigate to the view page.saveButtonProps, you can refer to the documentation:modalProps in Refine, you can use the useModalForm hook. This hook manages UI, state, error, and data fetching for the modal and form components. useModalForm:useModalForm is used to create a post. The action prop is set to "create" and the resource prop is set to "posts". The modalProps and formProps returned by useModalForm are then passed to the Modal and Form components respectively.useModalForm in the Refine documentation (https://refine.dev/docs/api-reference/antd/hooks/form/useModalForm/).redirect function from the useForm hook in Refine. useForm hook at the top of your component:onFinish function, you can call redirect to navigate to the view page. You would typically redirect to the "show" page of the resource with the ID of the newly created item:handleOnFinish is assumed to be an async function that creates a new item and returns its data, including its ID. You would need to adjust this based on how your handleOnFinish function is implemented.routerProvider defined in your <Refine> component along with the proper resource definition with routes and actions. You can find more information on how to use useForm and redirect in the Refine documentation (https://refine.dev/docs/data/hooks/use-form/#redirect).handleOnFinish might be returning a promise that TypeScript infers as Promise<never>, which means it's not expecting this promise to ever resolve. When you try to access the data property on the result, TypeScript throws an error because it doesn't expect the promise to have a data property.handleOnFinish. Here's an example of how to do this:handleOnFinish is declared as an async function that takes an ITaxes object as a parameter and returns a promise that resolves to an object with a data property, which is an object with an id property of type string.handleOnFinish function.handleOnFinish function seems to be asynchronous, which means it returns a Promise. You need to await the Promise to get the actual data. Here's how you can modify your code:await keyword before handleOnFinish to wait for the Promise to resolve. Now, data should contain the actual data returned by handleOnFinish, and you should be able to access data?.data?.id without any TypeScript errors.handleOnFinish is defined as an async function that returns a Promise. If handleOnFinish is not an async function, you'll need to modify it to return a Promise.await keyword on a value that is not a Promise. This means that TypeScript does not recognize handleOnFinish as an async function that returns a Promise.data as never, which means it's not expecting this variable to ever have a value. This can happen when TypeScript cannot infer the correct type of a variable or the return type of a function.handleOnFinish is declared as an async function that returns a Promise. Here's an example of how to do this:handleOnFinish is declared as an async function that takes an IPurchases object as a parameter and returns a Promise that resolves to an object with a data property, which is an object with an id property of type string.onFinish function, you can use the await keyword to wait for the Promise to resolve:handleOnFinish function.handleOnFinish as an async function that returns a Promise<{ data: { id: string } }>. This means that TypeScript expects every code path in handleOnFinish to return a Promise that resolves to an object of the shape { data: { id: string } }.handleOnFinish always returns a Promise:handleOnFinish is declared as an async function that returns a new Promise. Inside the Promise, you can put your async code. When the async operation is successful, you call resolve with the data. If the async operation fails, you call reject with an error.handleOnFinish function.next/routernext/routerReact ContextReduxdayjsdayjsdayjsdayjsdayjsdayjsdayjsdayjsgetValuePropsdayjs(value)1.10.5modalPropsmodalProps"create""posts"ModalredirectredirectredirectrouterProviderPromise<never>ITaxesdata?.data?.idIPurchasesPromise<{ data: { id: string } }>{ data: { id: string } }resolverejectimport { Create } from "@refinedev/antd";
import { useHistory } from "react-router-dom";
const PostCreate: React.FC = () => {
const history = useHistory();
return (
<Create
saveButtonProps={{ size: "small" }}
onSuccess={() => history.push('/another-page')}
>
<p>Rest of your page here</p>
</Create>
);
}; import { Edit } from "@refinedev/antd";
import { useHistory } from "react-router-dom";
const PostEdit: React.FC = () => {
const history = useHistory();
return (
<Edit
saveButtonProps={{ size: "small" }}
onSuccess={() => history.push('/edit-same-row')}
>
<p>Rest of your page here</p>
</Edit>
);
}; <Form.Item
label="Published At"
name="publishedAt"
getValueProps={(value) => ({
value: value ? dayjs(value) : "",
})}
>
<DatePicker />
</Form.Item>npm install dayjsyarn add dayjsimport dayjs from 'dayjs';import { Edit } from "@refinedev/antd";
import { useHistory } from "react-router-dom";
const PostEdit: React.FC = () => {
const history = useHistory();
return (
<Edit
saveButtonProps={{ size: "small" }}
onSuccess={() => history.push('/view-page')}
>
<p>Rest of your page here</p>
</Edit>
);
}; import { useModalForm } from "@pankod/refine";
const {
modalProps: createModalProps,
formProps: createFormProps,
show: createShow,
} = useModalForm({
action: "create",
resource: "posts",
});
// In your component
<Modal {...createModalProps} title="Create Post">
<Form {...createFormProps}>
{/* Your form fields go here */}
</Form>
</Modal>import { useForm } from "@pankod/refine";
const { redirect } = useForm();<Form
{...formProps}
onFinish={async (values) => {
const data = await handleOnFinish(values as ITaxes);
redirect("show", data?.data?.id);
}}
layout="vertical"
>const handleOnFinish = async (values: ITaxes): Promise<{ data: { id: string } }> => {
// Your code here
};onFinish={async (values) => {
const data = await handleOnFinish(values as IPurchases);
redirect("show", data?.data?.id);
}}onFinish={async (values) => {
const data = await handleOnFinish(values as IPurchases);
redirect("show", data?.data?.id);
}}const handleOnFinish = async (values: IPurchases): Promise<{ data: { id: string } }> => {
// Your code here
};const handleOnFinish = async (values: IPurchases): Promise<{ data: { id: string } }> => {
// Your code here
// Make sure to return a Promise that resolves to an object of the shape { data: { id: string } }
return new Promise((resolve, reject) => {
// Your async code here
// Call resolve with the data when the async operation is successful
// Call reject with an error if the async operation fails
});
};