Skip to content

Commit

Permalink
fix: route redirect with push
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo-battista committed Oct 26, 2023
1 parent 1fdcea9 commit cebe583
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion crud/common/CrudAddEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export function CrudAddEdit(props: CrudProps) {
const [loading, setLoading] = useState(true);
const { arkeId, open, title, unitId, onClose, onSubmit, include } = props;
const router = useRouter();
const {
query: { project },
} = router;

const onFormSubmit = useCallback(
(data: Record<string, unknown>) => {
Expand Down Expand Up @@ -99,7 +102,7 @@ export function CrudAddEdit(props: CrudProps) {
id: "error_unit_no_parameters",
}
);
void router.push(`/arke/${arkeId}#parameters`);
void router.push(`${project}/arke/${arkeId}#parameters`);
}
});
}, [unitId, arkeId, client]);
Expand Down
5 changes: 4 additions & 1 deletion pages/[project]/arke/[arkeId]/[unitId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ function UnitDetail({ detail }: { detail: TUnit }) {
delete: false,
});
const router = useRouter();
const {
query: { project },
} = router;

return (
<ProjectLayout>
Expand Down Expand Up @@ -102,7 +105,7 @@ function UnitDetail({ detail }: { detail: TUnit }) {
onSubmit={() => {
toast.success(`Unit deleted correctly`);
setCrud((prevState) => ({ ...prevState, delete: false }));
void router.push(`/arke/${detail.arke_id}#units`);
void router.push(`${project}/arke/${detail.arke_id}#units`);
}}
/>
</ProjectLayout>
Expand Down

0 comments on commit cebe583

Please sign in to comment.