Include locale on all links and routers

This commit is contained in:
Takeshi Kimata
2024-05-04 12:19:53 +09:00
parent ec9e2da7bc
commit 747d191412
20 changed files with 104 additions and 61 deletions

View File

@@ -7,9 +7,10 @@ import { fetchRuns, createRun, deleteRun } from "./runsControl";
type Props = {
projectId: string;
locale: string;
};
export default function RunsPage({ projectId }: Props) {
export default function RunsPage({ projectId, locale }: Props) {
const [runs, setRuns] = useState([]);
useEffect(() => {
@@ -66,6 +67,7 @@ export default function RunsPage({ projectId }: Props) {
projectId={projectId}
runs={runs}
onDeleteRun={onDeleteClick}
locale={locale}
/>
</div>
);

View File

@@ -12,8 +12,8 @@ import {
DropdownMenu,
DropdownItem,
SortDescriptor,
Link,
} from "@nextui-org/react";
import { Link, NextUiLinkClasses } from "@/src/navigation";
import { MoreVertical } from "lucide-react";
import { RunType } from "@/types/run";
import dayjs from "dayjs";
@@ -30,9 +30,15 @@ type Props = {
projectId: string;
runs: RunType[];
onDeleteRun: (runId: number) => void;
locale: string;
};
export default function RunsTable({ projectId, runs, onDeleteRun }: Props) {
export default function RunsTable({
projectId,
runs,
onDeleteRun,
locale,
}: Props) {
const [sortDescriptor, setSortDescriptor] = useState<SortDescriptor>({
column: "id",
direction: "ascending",
@@ -61,9 +67,9 @@ export default function RunsTable({ projectId, runs, onDeleteRun }: Props) {
case "name":
return (
<Link
underline="hover"
href={`/projects/${projectId}/runs/${run.id}`}
className="text-blue-500"
locale={locale}
className={NextUiLinkClasses}
>
{cellValue}
</Link>

View File

@@ -1,7 +1,7 @@
"use client";
import React from "react";
import { useState, useEffect } from "react";
import { useRouter } from "next/navigation";
import { useRouter } from "@/src/navigation";
import {
Button,
Input,
@@ -63,9 +63,10 @@ const defaultTestRun = {
type Props = {
projectId: string;
runId: string;
locale: string;
};
export default function RunEditor({ projectId, runId }: Props) {
export default function RunEditor({ projectId, runId, locale }: Props) {
const [testRun, setTestRun] = useState<RunType>(defaultTestRun);
const [folders, setFolders] = useState([]);
const [runCases, setRunCases] = useState<RunCaseType[]>([]);
@@ -220,7 +221,9 @@ export default function RunEditor({ projectId, runId }: Props) {
isIconOnly
size="sm"
className="rounded-full bg-neutral-50 dark:bg-neutral-600"
onPress={() => router.push(`/projects/${projectId}/runs`)}
onPress={() =>
router.push(`/projects/${projectId}/runs`, { locale: locale })
}
>
<ArrowLeft size={16} />
</Button>

View File

@@ -3,7 +3,13 @@ import RunEditor from "./RunEditor";
export default function Page({
params,
}: {
params: { projectId: string; runId: string };
params: { projectId: string; runId: string; locale: string };
}) {
return <RunEditor projectId={params.projectId} runId={params.runId} />;
return (
<RunEditor
projectId={params.projectId}
runId={params.runId}
locale={params.locale}
/>
);
}

View File

@@ -1,9 +1,13 @@
import RunsPage from "./RunsPage";
export default function Page({ params }: { params: { projectId: string } }) {
export default function Page({
params,
}: {
params: { projectId: string; locale: string };
}) {
return (
<>
<RunsPage projectId={params.projectId} />
<RunsPage projectId={params.projectId} locale={params.locale} />
</>
);
}