Support missing roles and deleted user
This commit is contained in:
@@ -8,7 +8,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@
|
||||
import { useLoadingEffect } from "@/hooks/useLoading";
|
||||
import { authors, created, DEBOUNCE, modified } from "@/snippets";
|
||||
import { PieceId } from "common";
|
||||
import { Cause, Effect } from "effect";
|
||||
import { Cause, Effect, Match } from "effect";
|
||||
import { Loader2, Plus } from "lucide-react";
|
||||
import { FormEventHandler, useId, useRef, useState } from "react";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
@@ -91,7 +91,7 @@ export function Pieces() {
|
||||
) : error !== null ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={4} className="text-center">
|
||||
{Cause.isUnknownException(error) ? "Wystąpił nieznany błąd" : `Wystąpił błąd: ${error.value}`}
|
||||
{Cause.isUnknownException(error) ? "Wystąpił nieznany błąd" : `Wystąpił błąd: ${JSON.stringify(error.value)}`}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : (
|
||||
@@ -124,7 +124,14 @@ function PieceRow(props: PieceRow.Props) {
|
||||
if (error !== null) {
|
||||
return (
|
||||
<TableRow>
|
||||
<TableCell colSpan={4}>Wystąpił błąd: {error.status === 422 ? error.value.message : error.value}</TableCell>
|
||||
<TableCell colSpan={4}>
|
||||
Wystąpił błąd: {Match.value(error).pipe(
|
||||
Match.when({ status: 401 }, () => "Zaloguj się ponownie"),
|
||||
Match.when({ status: 422 }, ({ value }) => value.message),
|
||||
Match.when({ status: 404 }, () => "Utwór nie istnieje"),
|
||||
Match.exhaustive,
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user