Hide insights when are aren't photos

This commit is contained in:
Sam Becker 2025-02-15 22:54:12 -06:00
parent 3afafb47a4
commit b9baf65bf9
2 changed files with 21 additions and 12 deletions

View File

@ -31,6 +31,8 @@ export default async function AdminNav() {
getPhotosMostRecentUpdateCached().catch(() => undefined), getPhotosMostRecentUpdateCached().catch(() => undefined),
]); ]);
const includeInsights = countPhotos > 0;
// Photos // Photos
const items = [{ const items = [{
label: 'Photos', label: 'Photos',
@ -53,6 +55,10 @@ export default async function AdminNav() {
}); } }); }
return ( return (
<AdminNavClient {...{ items, mostRecentPhotoUpdateTime }} /> <AdminNavClient {...{
items,
mostRecentPhotoUpdateTime,
includeInsights,
}} />
); );
} }

View File

@ -29,6 +29,7 @@ const areTimesRecent = (dates: Date[]) => dates
export default function AdminNavClient({ export default function AdminNavClient({
items, items,
mostRecentPhotoUpdateTime, mostRecentPhotoUpdateTime,
includeInsights,
}: { }: {
items: { items: {
label: string, label: string,
@ -36,6 +37,7 @@ export default function AdminNavClient({
count: number, count: number,
}[] }[]
mostRecentPhotoUpdateTime?: Date mostRecentPhotoUpdateTime?: Date
includeInsights?: boolean
}) { }) {
const pathname = usePathname(); const pathname = usePathname();
@ -90,17 +92,18 @@ export default function AdminNavClient({
</LinkWithStatus>)} </LinkWithStatus>)}
</div> </div>
<div className="flex gap-3"> <div className="flex gap-3">
<LinkWithLoader {includeInsights &&
href={PATH_ADMIN_INSIGHTS} <LinkWithLoader
className={clsx( href={PATH_ADMIN_INSIGHTS}
'translate-y-[-2px]', className={clsx(
isPathAdminInsights(pathname) 'translate-y-[-2px]',
? 'font-bold' isPathAdminInsights(pathname)
: 'text-dim')} ? 'font-bold'
loader={<Spinner className="translate-y-[1px]" />} : 'text-dim')}
> loader={<Spinner className="translate-y-[1px]" />}
<AdminAppInsightsIcon /> >
</LinkWithLoader> <AdminAppInsightsIcon />
</LinkWithLoader>}
<LinkWithLoader <LinkWithLoader
href={PATH_ADMIN_CONFIGURATION} href={PATH_ADMIN_CONFIGURATION}
className={isPathAdminConfiguration(pathname) className={isPathAdminConfiguration(pathname)