Repertoire view routing

This commit is contained in:
2024-12-28 21:04:08 +01:00
parent e4aca69f62
commit 60bbcefa9d
2 changed files with 18 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ import { RepertoireId } from "common";
import { Cause, Clock, Duration, Effect, Option } from "effect";
import { Loader2, Plus } from "lucide-react";
import { FormEventHandler, ReactNode, useId, useState } from "react";
import { Link, useNavigate } from "react-router-dom";
export function Repertoires() {
@@ -127,7 +128,7 @@ function RepertoireRow(props: RepertoireRow.Props) {
return (
<TableRow>
<TableCell>
{repertoire.name}
<Link className="underline" to={repertoire.repertoireId}>{repertoire.name}</Link>
</TableCell>
<TableCell>
{...piecesParts}
@@ -148,6 +149,8 @@ function RepertoireRow(props: RepertoireRow.Props) {
function AddRepertoireDialogContent() {
const navigate = useNavigate();
const [name, setName] = useState("");
const nameId = useId();
@@ -160,7 +163,7 @@ function AddRepertoireDialogContent() {
try {
setIsLoading(true);
const { error } = await client.repertoire.post({
const { data, error } = await client.repertoire.post({
name,
entries: [],
});
@@ -169,6 +172,8 @@ function AddRepertoireDialogContent() {
console.error(error.value);
return;
}
navigate(data.repertoireId);
} finally {
setIsLoading(false);
}