SPB Git

Repository Public

ProductCard.tsx 5.8 KB 142 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : agentilab-web8 * File             : components/marketing/ProductCard.tsx9 * Module           : User Interface10 * Repository       : https://git.spboucher.ai/agentilab-web11 * Project Website  : Not specified12 * Created          : 2026-12-0513 * Last Modified    : 2026-12-0514 *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: contact@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          : Proprietary34 *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 */4243import Image from 'next/image';44import type { Locale } from '@/lib/i18n/config';45import { formatDate } from '@/lib/i18n/config';46import { getCopy } from '@/lib/i18n/copy';47import type { PublicProduct } from '@/lib/catalog/types';48import { ExternalLink } from '@/components/ui/primitives';4950export function StatusBadge({ status, locale }: { status: PublicProduct['status']; locale: Locale }) {51  if (status === 'unverified') return null;52  return <span className={`badge badge--${status}`}>{getCopy(locale).labels.status[status]}</span>;53}5455interface ProductCardProps {56  product: PublicProduct;57  locale: Locale;58  /** Niveau du titre, selon la place de la carte dans la page. */59  heading?: 'h3' | 'h4';60  /** Affiche la capture d’écran (pages de marque) ou non (vue compacte du portefeuille). */61  withScreenshot?: boolean;62}6364export function ProductCard({ product, locale, heading = 'h3', withScreenshot = false }: ProductCardProps) {65  const copy = getCopy(locale);66  const Heading = heading;67  const shot = withScreenshot ? product.screenshots[0] : undefined;68  // Les sites du Groupe Ka sont publiés en français : on le signale aux lecteurs anglophones.69  const frenchOnly = locale === 'en' && product.brandId === 'groupe-ka';70  const linkLabel = product.brandId === 'groupe-ka' ? copy.labels.officialSite : copy.labels.productPage;71  return (72    <article className="card product">73      {shot ? (74        <div className={shot.height > shot.width ? 'product__shot product__shot--tall' : 'product__shot'}>75          <Image src={shot.src} width={shot.width} height={shot.height} alt={shot.alt[locale]} sizes="(min-width: 1100px) 400px, (min-width: 700px) 50vw, 100vw" />76        </div>77      ) : null}78      <div className="product__body">79        <div className="product__head">80          {product.icon ? (81            <Image className="product__icon" src={product.icon.src} width={44} height={44} alt="" unoptimized={product.icon.src.endsWith('.svg')} />82          ) : (83            <span className="product__mono" aria-hidden="true">84              {product.name[locale].replace(/[^A-Z]/g, '').slice(0, 2)}85            </span>86          )}87          <div>88            <Heading>{product.name[locale]}</Heading>89            <span className="product__cat">{copy.labels.category[product.category]}</span>90          </div>91        </div>92        <div className="product__meta">93          <StatusBadge status={product.status} locale={locale} />94          {product.platforms.map((platform) => (95            <span key={platform} className="badge badge--plain">96              {copy.labels.platform[platform]}97            </span>98          ))}99          {product.version ? (100            <span className="muted">101              {copy.labels.version} {product.version}102            </span>103          ) : null}104          {frenchOnly ? <span className="muted">{copy.labels.siteLanguageNote}</span> : null}105        </div>106        <p className="product__desc">{product.description[locale]}</p>107        {product.privacyNote ? (108          <p className="product__privacy">109            <strong>{copy.labels.privacy}</strong>110            {product.privacyNote[locale]}111          </p>112        ) : null}113        <div className="product__links">114          <ExternalLink href={product.officialUrl[locale]} externalLabel={`— ${product.name[locale]} ${copy.labels.external}`} hrefLang={frenchOnly ? 'fr-CA' : undefined}>115            {linkLabel}116          </ExternalLink>117          {product.storeLinks.map((link) => (118            <ExternalLink key={link.url} href={link.url} externalLabel={`— ${product.name[locale]} ${copy.labels.external}`}>119              {copy.labels.appStore}120            </ExternalLink>121          ))}122        </div>123        <p className="small muted">124          {copy.labels.verifiedOn} <time dateTime={product.verifiedAt}>{formatDate(product.verifiedAt, locale)}</time>125        </p>126      </div>127    </article>128  );129}130131export function ProductGrid({ products, locale, heading, withScreenshot }: Omit<ProductCardProps, 'product'> & { products: PublicProduct[] }) {132  return (133    <ul className="products">134      {products.map((product) => (135        <li key={product.id} id={product.slug}>136          <ProductCard product={product} locale={locale} heading={heading} withScreenshot={withScreenshot} />137        </li>138      ))}139    </ul>140  );141}142
Files main
Menu

Theme