fix: use i18n for availability badge labels and make requestedSeasons optional
This commit is contained in:
1 parent
6bf3c75f9f
commit
2bfe2caffc
3 files changed
+19
-10
No files matched your search
@@ -12,14 +12,14 @@ interface SeriesInformation {
|
|||||||
overview: string;
|
overview: string;
|
||||||
seasons: SerieSeason[];
|
seasons: SerieSeason[];
|
||||||
posterPath: string;
|
posterPath: string;
|
||||||
requestedSeasons: number[];
|
requestedSeasons?: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MovieInformation {
|
interface MovieInformation {
|
||||||
id: number;
|
id: number;
|
||||||
overview: string;
|
overview: string;
|
||||||
posterPath: string;
|
posterPath: string;
|
||||||
requestedSeasons: number[];
|
requestedSeasons?: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MediaInformation = SeriesInformation | MovieInformation;
|
export type MediaInformation = SeriesInformation | MovieInformation;
|
||||||
|
|||||||
@@ -15,13 +15,8 @@ import { createGroup } from "../../lib/group";
|
|||||||
import { mediaRequestSearchScopeAtom } from "../../spotlight-store";
|
import { mediaRequestSearchScopeAtom } from "../../spotlight-store";
|
||||||
import { useMediaRequestSearchInteraction } from "../external/search-engines-search-group";
|
import { useMediaRequestSearchInteraction } from "../external/search-engines-search-group";
|
||||||
|
|
||||||
const availabilityLabels: Partial<Record<MediaAvailability, string>> = {
|
const availabilityLabelKeys = ["available", "partiallyAvailable", "processing", "requested", "pending"] as const;
|
||||||
available: "Available",
|
type AvailabilityWithLabel = (typeof availabilityLabelKeys)[number];
|
||||||
partiallyAvailable: "Partial",
|
|
||||||
processing: "Processing",
|
|
||||||
requested: "Requested",
|
|
||||||
pending: "Requested",
|
|
||||||
};
|
|
||||||
|
|
||||||
type MediaRequestSearchResult = RouterOutputs["integration"]["searchMediaRequests"][number];
|
type MediaRequestSearchResult = RouterOutputs["integration"]["searchMediaRequests"][number];
|
||||||
|
|
||||||
@@ -42,6 +37,8 @@ export const mediaRequestSearchGroup = createGroup<MediaRequestSearchOption>({
|
|||||||
keyPath: "key",
|
keyPath: "key",
|
||||||
title: (t) => t("search.mode.media.group.title"),
|
title: (t) => t("search.mode.media.group.title"),
|
||||||
Component(option) {
|
Component(option) {
|
||||||
|
const tMedia = useScopedI18n("search.mode.media");
|
||||||
|
|
||||||
if (option.kind !== "result") {
|
if (option.kind !== "result") {
|
||||||
return (
|
return (
|
||||||
<Group w="100%" wrap="nowrap" align="center" px="md" py="xs" opacity={option.kind === "disabled" ? 0.55 : 1}>
|
<Group w="100%" wrap="nowrap" align="center" px="md" py="xs" opacity={option.kind === "disabled" ? 0.55 : 1}>
|
||||||
@@ -57,7 +54,12 @@ export const mediaRequestSearchGroup = createGroup<MediaRequestSearchOption>({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { result } = option;
|
const { result } = option;
|
||||||
const badgeLabel = result.availability ? availabilityLabels[result.availability as MediaAvailability] : undefined;
|
const hasAvailabilityLabel =
|
||||||
|
result.availability &&
|
||||||
|
(availabilityLabelKeys as readonly string[]).includes(result.availability);
|
||||||
|
const badgeLabel = hasAvailabilityLabel
|
||||||
|
? tMedia(`availability.${result.availability as AvailabilityWithLabel}`)
|
||||||
|
: undefined;
|
||||||
const badgeColor = result.availability
|
const badgeColor = result.availability
|
||||||
? mediaAvailabilityConfiguration[result.availability as MediaAvailability]?.color
|
? mediaAvailabilityConfiguration[result.availability as MediaAvailability]?.color
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|||||||
@@ -4567,6 +4567,13 @@
|
|||||||
"scoped": "This widget does not have an accessible media request integration."
|
"scoped": "This widget does not have an accessible media request integration."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"availability": {
|
||||||
|
"available": "Available",
|
||||||
|
"partiallyAvailable": "Partial",
|
||||||
|
"processing": "Processing",
|
||||||
|
"requested": "Requested",
|
||||||
|
"pending": "Requested"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"external": {
|
"external": {
|
||||||
|
|||||||
Reference in new issue
Block a user