Jonathan
Jonathan
Explore posts from servers
RRefine
Created by flat-fuchsia on 9/4/2024 in #ask-any-question
Closing modal after save, gives warning that you are leaving the page.
I have a modal like this:
import { Form, Input, Modal } from "antd";
import { useModalForm } from "@refinedev/antd";
import { useGetToPath, useGo } from "@refinedev/core";
import { useSearchParams } from "react-router-dom";

export const SourceCreate = () => {

const getToPath = useGetToPath();
const [searchParams] = useSearchParams();
const go = useGo();

const { modalProps, formProps, onFinish, close, form } = useModalForm<any>({
action: "create",
resource: "sources",
defaultVisible: true,
redirect: false,
mutationMode: "pessimistic",

});

const handleFinish = async (values: any) => {
try {
await onFinish(values);

close();
navigateToList();
} catch (error) {
console.error(error);
}
};

const navigateToList = () => {
go({
to: searchParams.get("to") ?? getToPath({ action: "list" }) ?? "",
query: { to: undefined },
options: { keepQuery: true },
type: "replace",
});
};

return (
<Modal
{...modalProps}
title="Create Source"
onCancel={() => {
close();
navigateToList();
}}
>
<Form
{...formProps}
layout="vertical"
onFinish={handleFinish}
>
<Form.Item label="Name" name="name" rules={[{ required: true }]}>
<Input />
</Form.Item>
</Form>
</Modal>
);
};
import { Form, Input, Modal } from "antd";
import { useModalForm } from "@refinedev/antd";
import { useGetToPath, useGo } from "@refinedev/core";
import { useSearchParams } from "react-router-dom";

export const SourceCreate = () => {

const getToPath = useGetToPath();
const [searchParams] = useSearchParams();
const go = useGo();

const { modalProps, formProps, onFinish, close, form } = useModalForm<any>({
action: "create",
resource: "sources",
defaultVisible: true,
redirect: false,
mutationMode: "pessimistic",

});

const handleFinish = async (values: any) => {
try {
await onFinish(values);

close();
navigateToList();
} catch (error) {
console.error(error);
}
};

const navigateToList = () => {
go({
to: searchParams.get("to") ?? getToPath({ action: "list" }) ?? "",
query: { to: undefined },
options: { keepQuery: true },
type: "replace",
});
};

return (
<Modal
{...modalProps}
title="Create Source"
onCancel={() => {
close();
navigateToList();
}}
>
<Form
{...formProps}
layout="vertical"
onFinish={handleFinish}
>
<Form.Item label="Name" name="name" rules={[{ required: true }]}>
<Input />
</Form.Item>
</Form>
</Modal>
);
};
When I hit save, it is giving the "Are you sure you want to leave? You have unsaved changes." alert despite actually saving.
6 replies
RRefine
Created by ambitious-aqua on 8/11/2024 in #ask-any-question
Enabling Sorting on Antd Table
How do you set Antd sorting on a table? We are using Antd with Supabase and refine.
13 replies
RRefine
Created by extended-salmon on 8/6/2024 in #ask-any-question
Expo Router integration
Is there Expo Router integration?
4 replies
RRefine
Created by unwilling-turquoise on 8/6/2024 in #ask-any-question
Better Error notifications on Supabase Provider
How can I get a more user friendly message from supabase database provider for things like a unique constraint error message? For example I get this message now:
duplicate key value violates unique constraint
duplicate key value violates unique constraint
But would be nice to give something specific to the field or at least friendly to the user.
16 replies
RRefine
Created by wise-white on 8/5/2024 in #ask-any-question
How to Change Page Title From Refine
I am using the CRM example as a starting point but I can't find how to change the Page title from having "Refine" in it. It is using the DocumentTitleHandler but I can't seem to figure out how to change it to our app name.
5 replies
RRefine
Created by absent-sapphire on 8/2/2024 in #ask-any-question
Starting a new Project with Refine, picking React or Next
I am starting a new project and planning on using Refine. It is a classic CRUD app with hundreds of types of datasources. I am also planning on a react-native app also. My question is this, would you start a new project with React-Vite and monolith so that you can share data sources between the react-native and react app. I have considered NextJS and have a version in NextJS. But I end up highly relying on client side code in the NextJS app. So my question is this: - If the long term goal is to have a react and expo based app, is it worth having a mono-repo with a traditional react and expo app? I am just thinking this may seem more consistent between the expo and react apps vs an expo and nextjs app. Thoughts?
5 replies