Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Music SP8 * File : src/app/(app)/favoris/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 type { Album, Track } from "@/lib/types";45import { useT } from "@/i18n";46import { AlbumCard, Async, Empty, PageHeader, PlayButtons, Section, TrackList, useApi } from "@/components/ui";47import { IHeart } from "@/components/icons";4849export default function FavoritesPage() {50 const t = useT();51 const res = useApi<{ tracks: Track[]; albums: Album[]; total: number }>("/api/v1/library/favorites?limit=100");52 return (53 <>54 <PageHeader title={t("fav.title")}>{res.data && res.data.tracks.length > 0 && <PlayButtons tracks={res.data.tracks} />}</PageHeader>55 <Async res={res}>{(d) => d.tracks.length + d.albums.length === 0 ? <Empty icon={<IHeart size={28} />} title={t("fav.emptyTitle")} body={t("fav.emptyBody")} /> : (56 <>57 {d.albums.length > 0 && <Section title={t("lib.albums")}><div className="scroll-x -mx-4 px-4 sm:mx-0 sm:px-0">{d.albums.map((a) => <AlbumCard key={a.id} album={a} className="w-36 sm:w-44" />)}</div></Section>}58 {d.tracks.length > 0 && <Section title={t("lib.tracks")}>59 <TrackList tracks={d.tracks} onFavorite={(tr, on) => { if (!on) res.setData((x) => ({ ...x, tracks: x.tracks.filter((y) => y.id !== tr.id) })); }} />60 {d.total > d.tracks.length && <p className="mt-3 text-center text-xs text-muted">{t("fav.more", { shown: d.tracks.length, total: d.total })}</p>}61 </Section>}62 </>)}</Async>63 </>64 );65}66