@@ -16,6 +16,7 @@ import { Button } from "./ui/button";
1616import { useState } from "react" ;
1717import { useToast } from "@app/hooks/useToast" ;
1818import { createApiClient , formatAxiosError } from "@app/lib/api" ;
19+ import { useRouter , usePathname } from "next/navigation" ;
1920
2021type SiteInfoCardProps = { } ;
2122
@@ -24,6 +25,8 @@ export default function SiteInfoCard({ }: SiteInfoCardProps) {
2425 const t = useTranslations ( ) ;
2526 const { env } = useEnvContext ( ) ;
2627 const api = createApiClient ( useEnvContext ( ) ) ;
28+ const router = useRouter ( ) ;
29+ const pathname = usePathname ( ) ;
2730
2831 const [ isEditing , setIsEditing ] = useState ( false ) ;
2932 const [ niceId , setNiceId ] = useState ( site . niceId ) ;
@@ -82,6 +85,10 @@ export default function SiteInfoCard({ }: SiteInfoCardProps) {
8285 niceId : tempNiceId . trim ( )
8386 } ) ;
8487
88+ // update the URL to reflect the new niceId
89+ const newPath = pathname . replace ( `/sites/${ niceId } ` , `/sites/${ tempNiceId . trim ( ) } ` ) ;
90+ router . replace ( newPath ) ;
91+
8592 toast ( {
8693 title : t ( "niceIdUpdated" ) ,
8794 description : t ( "niceIdUpdatedSuccessfully" )
0 commit comments