feat(housekeeping): deliver hotel operations
This commit is contained in:
1 parent
bfc5bd78a1
commit
abc707cfb2
43 files changed
+3749
-615
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import type { HotelQueryData, NormalizedHotelQueryInput } from "./rooms";
|
||||
|
||||
export async function loadHotelRadioQuery(
|
||||
input: NormalizedHotelQueryInput,
|
||||
): Promise<HotelQueryData> {
|
||||
if (input.routeId !== "hotel.radio.monitoring") {
|
||||
const { loadHotelDatabaseQuery } = await import("./hotel-production");
|
||||
return loadHotelDatabaseQuery(input);
|
||||
}
|
||||
const { fetchListeners, fetchNowPlaying } = await import(
|
||||
"@/lib/services/radio"
|
||||
);
|
||||
const [nowPlaying, listeners] = await Promise.all([
|
||||
fetchNowPlaying(),
|
||||
fetchListeners(),
|
||||
]);
|
||||
const items: Array<HotelQueryData["items"][number]> = [];
|
||||
if (nowPlaying) {
|
||||
items.push({
|
||||
id: "now-playing",
|
||||
title: nowPlaying.title,
|
||||
description: nowPlaying.artist ?? undefined,
|
||||
status: "playing",
|
||||
href: "/ase/hotel/radio/monitoring",
|
||||
});
|
||||
}
|
||||
if (listeners !== null) {
|
||||
items.push({
|
||||
id: "listeners",
|
||||
title: `${listeners} listeners`,
|
||||
status: "live",
|
||||
href: "/ase/hotel/radio/monitoring",
|
||||
});
|
||||
}
|
||||
return {
|
||||
kind: "radio",
|
||||
items,
|
||||
total: items.length,
|
||||
partialDependencies:
|
||||
nowPlaying === null && listeners === null ? ["radio"] : [],
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user