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;
|
||||
seasons: SerieSeason[];
|
||||
posterPath: string;
|
||||
requestedSeasons: number[];
|
||||
requestedSeasons?: number[];
|
||||
}
|
||||
|
||||
interface MovieInformation {
|
||||
id: number;
|
||||
overview: string;
|
||||
posterPath: string;
|
||||
requestedSeasons: number[];
|
||||
requestedSeasons?: number[];
|
||||
}
|
||||
|
||||
export type MediaInformation = SeriesInformation | MovieInformation;
|
||||
|
||||
@@ -15,13 +15,8 @@ import { createGroup } from "../../lib/group";
|
||||
import { mediaRequestSearchScopeAtom } from "../../spotlight-store";
|
||||
import { useMediaRequestSearchInteraction } from "../external/search-engines-search-group";
|
||||
|
||||
const availabilityLabels: Partial<Record<MediaAvailability, string>> = {
|
||||
available: "Available",
|
||||
partiallyAvailable: "Partial",
|
||||
processing: "Processing",
|
||||
requested: "Requested",
|
||||
pending: "Requested",
|
||||
};
|
||||
const availabilityLabelKeys = ["available", "partiallyAvailable", "processing", "requested", "pending"] as const;
|
||||
type AvailabilityWithLabel = (typeof availabilityLabelKeys)[number];
|
||||
|
||||
type MediaRequestSearchResult = RouterOutputs["integration"]["searchMediaRequests"][number];
|
||||
|
||||
@@ -42,6 +37,8 @@ export const mediaRequestSearchGroup = createGroup<MediaRequestSearchOption>({
|
||||
keyPath: "key",
|
||||
title: (t) => t("search.mode.media.group.title"),
|
||||
Component(option) {
|
||||
const tMedia = useScopedI18n("search.mode.media");
|
||||
|
||||
if (option.kind !== "result") {
|
||||
return (
|
||||
<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 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
|
||||
? mediaAvailabilityConfiguration[result.availability as MediaAvailability]?.color
|
||||
: undefined;
|
||||
|
||||
@@ -4567,6 +4567,13 @@
|
||||
"scoped": "This widget does not have an accessible media request integration."
|
||||
}
|
||||
}
|
||||
},
|
||||
"availability": {
|
||||
"available": "Available",
|
||||
"partiallyAvailable": "Partial",
|
||||
"processing": "Processing",
|
||||
"requested": "Requested",
|
||||
"pending": "Requested"
|
||||
}
|
||||
},
|
||||
"external": {
|
||||
|
||||
Reference in new issue
Block a user