fix(frontend): remove locale-dependent routing and migrate to centralized locale-aware router
- Replaced `next/navigation` with `@/lib/i18n/routing` across components, pages, and tests. - Removed redundant `locale` props from `ProjectWizard` and related pages. - Updated navigation to exclude explicit `locale` in paths. - Refactored tests to use mocks from `next-intl/navigation`.
This commit is contained in:
@@ -8,7 +8,8 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useRouter, useParams } from 'next/navigation';
|
||||
import { useParams } from 'next/navigation';
|
||||
import { useRouter } from '@/lib/i18n/routing';
|
||||
import { toast } from 'sonner';
|
||||
import { AgentTypeDetail, AgentTypeForm } from '@/components/agents';
|
||||
import {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useCallback, useMemo } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useRouter } from '@/lib/i18n/routing';
|
||||
import { toast } from 'sonner';
|
||||
import { AgentTypeList } from '@/components/agents';
|
||||
import { useAgentTypes } from '@/lib/api/hooks/useAgentTypes';
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
import { useState, use } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useRouter } from '@/lib/i18n/routing';
|
||||
import { Plus, Upload } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
@@ -25,7 +25,7 @@ interface ProjectIssuesPageProps {
|
||||
}
|
||||
|
||||
export default function ProjectIssuesPage({ params }: ProjectIssuesPageProps) {
|
||||
const { locale, id: projectId } = use(params);
|
||||
const { id: projectId } = use(params);
|
||||
const router = useRouter();
|
||||
|
||||
// Filter state
|
||||
@@ -49,7 +49,7 @@ export default function ProjectIssuesPage({ params }: ProjectIssuesPageProps) {
|
||||
const { data, isLoading, error } = useIssues(projectId, filters, sort);
|
||||
|
||||
const handleIssueClick = (issueId: string) => {
|
||||
router.push(`/${locale}/projects/${projectId}/issues/${issueId}`);
|
||||
router.push(`/projects/${projectId}/issues/${issueId}`);
|
||||
};
|
||||
|
||||
const handleBulkChangeStatus = () => {
|
||||
|
||||
@@ -13,17 +13,11 @@ export const metadata: Metadata = {
|
||||
description: 'Create a new Syndarix project with AI-powered agents',
|
||||
};
|
||||
|
||||
interface NewProjectPageProps {
|
||||
params: Promise<{ locale: string }>;
|
||||
}
|
||||
|
||||
export default async function NewProjectPage({ params }: NewProjectPageProps) {
|
||||
const { locale } = await params;
|
||||
|
||||
export default function NewProjectPage() {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<ProjectWizard locale={locale} />
|
||||
<ProjectWizard />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useCallback, useMemo } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useRouter } from '@/lib/i18n/routing';
|
||||
import { toast } from 'sonner';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useRouter } from '@/lib/i18n/routing';
|
||||
import { AlertCircle, RefreshCw } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useRouter } from '@/lib/i18n/routing';
|
||||
import { ArrowLeft, ArrowRight, Check, CheckCircle2, Loader2 } from 'lucide-react';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
|
||||
@@ -49,11 +49,10 @@ interface ProjectResponse {
|
||||
}
|
||||
|
||||
interface ProjectWizardProps {
|
||||
locale: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function ProjectWizard({ locale, className }: ProjectWizardProps) {
|
||||
export function ProjectWizard({ className }: ProjectWizardProps) {
|
||||
const router = useRouter();
|
||||
const [isCreated, setIsCreated] = useState(false);
|
||||
|
||||
@@ -106,9 +105,9 @@ export function ProjectWizard({ locale, className }: ProjectWizardProps) {
|
||||
const handleGoToProject = () => {
|
||||
// Navigate to project dashboard - using slug from successful creation
|
||||
if (createProjectMutation.data) {
|
||||
router.push(`/${locale}/projects/${createProjectMutation.data.slug}`);
|
||||
router.push(`/projects/${createProjectMutation.data.slug}`);
|
||||
} else {
|
||||
router.push(`/${locale}/projects`);
|
||||
router.push(`/projects`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user