import { NextResponse } from 'next/server'; import { Gallery } from '@/components/gallery'; import { getSpreadsheetData } from '@/utils/sheets'; import * as query from '@/utils/query'; const defaultSheetUrl = 'https://cdn.raydiant.com/raydiant-sdk-examples/gallery/NationalParks.xlsx'; export default async function Page({ searchParams, }: { searchParams: { [key: string]: string | string[] | undefined }; }) { // Parse input values from query string when rendering server-side. const sheetUrl = query.string(searchParams['sheet']) || defaultSheetUrl; const showDescriptions = query.boolean(searchParams['descriptions']); // It's possible for the Dashboard to send a local blob URL for the file input. This can // happen after a file has been uploaded and the URL navigates to the Playlist Builder. The // file may not be uploaded yet, so the Dashboard will send the local blob URL instead. We // throw and error in this case because blob URLs cannot be parsed server-side. // // The app router in NextJS 13 doesn't seem to allow specifying the response code, ideally // we would set a 400 (bad request) response code here. if (sheetUrl.startsWith('blob:')) { throw new Error('Spreadsheet still uploading'); } // Get SSR sheet data. We use SSR to fetch data server-side when the app is running // in a playlist, allowing the runtime to know when the app is ready to render. const sheetData = await getSpreadsheetData(sheetUrl); return (
); }