fair-rose
fair-rose2y ago

Navigation not properly working if the resource has custom route

Hi, I am using react-router-6, We have configured a resource with a route called '/config/units'. when using edit function from useNavigation, it redirecting to http://config/units/edit... instead of http://localhost:3000/config/units/edit/...
5 Replies
xenial-black
xenial-black2y ago
Hey @msp5608, Can you share us your code to learn how you use useNavigation?
fair-rose
fair-rose2y ago
Sorry, I just figured out what was the issue. we should have put the options like
{route: "config/units"}
{route: "config/units"}
instead of this
{route: "/config/units"}
{route: "/config/units"}
But we are facing another issue, I am using useForm inside edit page
const { form, formProps, saveButtonProps, id } = useForm({
action: "edit",
submitOnEnter: false,
metaData: {
fields: [
"id",
"center_name",
"unit_type",
"unit_code",
"unit_name",
"postfix",
"contact_person",
"contact_person_mobile_no",
"contact_person_phone",
"contact_person_email",
"website",
"fax_no",
"address_line_1",
"address_line_2",
"postal_code",
"country",
"state",
"city",
"active",
"latitude",
"longitude",
"organization_id",
],
},
onMutationSuccess: data => {
updateDocuments();
},
});
const { form, formProps, saveButtonProps, id } = useForm({
action: "edit",
submitOnEnter: false,
metaData: {
fields: [
"id",
"center_name",
"unit_type",
"unit_code",
"unit_name",
"postfix",
"contact_person",
"contact_person_mobile_no",
"contact_person_phone",
"contact_person_email",
"website",
"fax_no",
"address_line_1",
"address_line_2",
"postal_code",
"country",
"state",
"city",
"active",
"latitude",
"longitude",
"organization_id",
],
},
onMutationSuccess: data => {
updateDocuments();
},
});
We are using hasura data provider It is returning the following - { "errors": [ { "extensions": { "code": "validation-failed", "path": "$.selectionSet.organization_units_by_pk.selectionSet" }, "message": "missing selection set for 'organization_units'" } ] } the fields provided in metadata are not added in the query
xenial-black
xenial-black2y ago
the organization_units didn't provide in your metaData but you say it's provided. Are you adding it elsewhere?
fair-rose
fair-rose2y ago
it is the resource name even if i added the resource name, getting the same result we are using useModalforms elsewhere, it is working fine only the useForm is not fetching the data using metadata fields
xenial-black
xenial-black2y ago
It's interesting that it works in useModalForm and not useForm. Are you sure that the codes are exactly the same? Because useModalForm internally uses useForm.