SPB Git

Repository Public

page.tsx 3.6 KB 80 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Music SP8 * File             : src/app/(app)/page.tsx9 * Module           : app10 * Repository       : https://git.spboucher.ai/sp-music11 * Project Website  : https://music.spboucher.ai12 * Created          : 2026-11-1713 * Last Modified    : 2026-11-1714 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243"use client";44import Link from "next/link";45import type { Album, Artist, Playlist, Track } from "@/lib/types";46import { useT } from "@/i18n";47import { AlbumCard, ArtistCard, Async, Empty, GridSkeleton, PlaylistCard, Section, TrackList, useApi, useMe } from "@/components/ui";48import { IUpload } from "@/components/icons";4950interface Home { recentAlbums: Album[]; artists: Artist[]; recentTracks: Track[]; playlists: Playlist[]; counts: { tracks: number; albums: number; artists: number } }5152export default function HomePage() {53  const t = useT(); const me = useMe();54  const res = useApi<Home>("/api/v1/library/home");55  return (56    <>57      <h1 className="h-page mb-6">{t("home.title")}</h1>58      <Async res={res} skeleton={<GridSkeleton />}>{(d) => d.counts.tracks === 0 ? (59        <Empty title={t("home.emptyTitle")} body={t(me.role === "admin" ? "home.emptyAdmin" : "home.emptyListener")}60          action={me.role === "admin" ? <Link href="/admin" className="btn btn-primary"><IUpload size={16} />{t("home.firstUpload")}</Link> : undefined} />61      ) : (62        <>63          <Section title={t("home.recentAlbums")} href="/bibliotheque?tab=albums">64            <div className="scroll-x -mx-4 px-4 sm:mx-0 sm:px-0">{d.recentAlbums.map((a) => <AlbumCard key={a.id} album={a} className="w-36 sm:w-44" />)}</div>65          </Section>66          <Section title={t("home.artists")} href="/bibliotheque?tab=artists">67            <div className="scroll-x -mx-4 px-4 sm:mx-0 sm:px-0">{d.artists.map((a) => <ArtistCard key={a.id} artist={a} className="w-28 sm:w-36" />)}</div>68          </Section>69          {d.playlists.length > 0 && (70            <Section title={t("home.playlists")} href="/listes">71              <div className="scroll-x -mx-4 px-4 sm:mx-0 sm:px-0">{d.playlists.map((p) => <PlaylistCard key={p.id} playlist={p} className="w-36 sm:w-44" />)}</div>72            </Section>73          )}74          <Section title={t("home.recentTracks")} href="/bibliotheque?tab=tracks"><TrackList tracks={d.recentTracks} /></Section>75        </>76      )}</Async>77    </>78  );79}80
Files main
Menu

Theme