sacred-roseS
Refine2y ago
4 replies
sacred-rose

Custom Edit Page not finding id

Trying to use this format to recognise the resource and id to edit
<Edit resource='apps' recordItemId={id}

Not working. URL with id

http://localhost:5173/apps/builder/edit/9346e949-de1e-408f-b6a0-0c90c1f7d30f/core

Full code

import React from 'react'; import { Edit, useForm, useSelect } from "@refinedev/mantine"; import { Select, TextInput } from "@mantine/core"; import { IApp} from '../../../interfaces'; import { useLocation } from 'react-router-dom'; export const AppEdit: React.FC = () => { const location = useLocation(); const id = location.pathname.split('/')[4]; console.log(id); const { saveButtonProps, getInputProps, refineCore: { queryResult }, } = useForm<IApp>({ initialValues: { name: "", status: 5, }, validate: { name: (value) => (value.length < 2 ? "Too short title" : null), status: (value) => (value.length <= 0 ? "Status is required" : null), }, }); const appData = queryResult?.data?.data; return ( <Edit resource='apps' recordItemId={id} saveButtonProps={saveButtonProps}> <form> <TextInput mt={8} label="Name" placeholder="Name" {...getInputProps("name")} /> <Select mt={8} label="Status" placeholder="Pick one" {...getInputProps("status")} data={[ { label: "Published", value: "published" }, { label: "Draft", value: "draft" }, { label: "Rejected", value: "rejected" }, ]} /> </form> </Edit> ); };
Was this page helpful?