mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-24 07:28:10 +02:00
feat: add PublicitesClient component for displaying and filtering advertising data by year
This commit is contained in:
1 parent
acd30cfdea
commit
5e6b1d354b
1 file changed
+11
-11
@@ -10,12 +10,12 @@ function fmtDate(iso: string) {
|
|||||||
return d.toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", year: "numeric" });
|
return d.toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", year: "numeric" });
|
||||||
}
|
}
|
||||||
|
|
||||||
function fmtCA(v: number) {
|
function fmtCA(v: number | string) {
|
||||||
return new Intl.NumberFormat("fr-FR", { style: "currency", currency: "EUR", maximumFractionDigits: 0 }).format(v);
|
return new Intl.NumberFormat("fr-FR", { style: "currency", currency: "EUR", maximumFractionDigits: 0 }).format(Number(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
function fmtPct(v: number) {
|
function fmtPct(v: number | string) {
|
||||||
return v.toFixed(2).replace(".", ",") + " %";
|
return Number(v).toFixed(2).replace(".", ",") + " %";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -97,9 +97,9 @@ export function PublicitesClient({ year, publicites }: Props) {
|
|||||||
</td>
|
</td>
|
||||||
<td className="bg-orange-50/60 px-3 py-2.5 text-right tabular-nums">
|
<td className="bg-orange-50/60 px-3 py-2.5 text-right tabular-nums">
|
||||||
<span className={`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${
|
<span className={`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${
|
||||||
pub.pourc_capub_catotal >= 20
|
Number(pub.pourc_capub_catotal) >= 20
|
||||||
? "bg-orange-100 text-orange-700"
|
? "bg-orange-100 text-orange-700"
|
||||||
: pub.pourc_capub_catotal >= 10
|
: Number(pub.pourc_capub_catotal) >= 10
|
||||||
? "bg-amber-100 text-amber-700"
|
? "bg-amber-100 text-amber-700"
|
||||||
: "bg-gray-100 text-gray-600"
|
: "bg-gray-100 text-gray-600"
|
||||||
}`}>
|
}`}>
|
||||||
@@ -107,13 +107,13 @@ export function PublicitesClient({ year, publicites }: Props) {
|
|||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-3 py-2.5 text-right tabular-nums text-gray-700 text-xs">
|
<td className="px-3 py-2.5 text-right tabular-nums text-gray-700 text-xs">
|
||||||
{pub.qte_vendue_pub.toLocaleString("fr-FR")}
|
{Number(pub.qte_vendue_pub).toLocaleString("fr-FR")}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-3 py-2.5 text-right tabular-nums text-gray-700 text-xs">
|
<td className="px-3 py-2.5 text-right tabular-nums text-gray-700 text-xs">
|
||||||
{pub.client_pub_periode.toLocaleString("fr-FR")}
|
{Number(pub.client_pub_periode).toLocaleString("fr-FR")}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-3 py-2.5 text-right tabular-nums text-gray-700 text-xs">
|
<td className="px-3 py-2.5 text-right tabular-nums text-gray-700 text-xs">
|
||||||
{pub.taux_sortie.toFixed(1).replace(".", ",")} %
|
{Number(pub.taux_sortie).toFixed(1).replace(".", ",")} %
|
||||||
</td>
|
</td>
|
||||||
<td className="px-3 py-2.5 text-right tabular-nums text-gray-500 text-xs">
|
<td className="px-3 py-2.5 text-right tabular-nums text-gray-500 text-xs">
|
||||||
{pub.nb_articles}
|
{pub.nb_articles}
|
||||||
@@ -127,13 +127,13 @@ export function PublicitesClient({ year, publicites }: Props) {
|
|||||||
TOTAL — {publicites.length} publicités
|
TOTAL — {publicites.length} publicités
|
||||||
</td>
|
</td>
|
||||||
<td className="bg-orange-100 px-3 py-3 text-right font-bold tabular-nums text-gray-900">
|
<td className="bg-orange-100 px-3 py-3 text-right font-bold tabular-nums text-gray-900">
|
||||||
{fmtCA(publicites.reduce((s, p) => s + p.ca_pub_periode_pub, 0))}
|
{fmtCA(publicites.reduce((s, p) => s + Number(p.ca_pub_periode_pub), 0))}
|
||||||
</td>
|
</td>
|
||||||
<td className="bg-orange-100 px-3 py-3 text-right tabular-nums text-xs font-semibold text-orange-700">
|
<td className="bg-orange-100 px-3 py-3 text-right tabular-nums text-xs font-semibold text-orange-700">
|
||||||
—
|
—
|
||||||
</td>
|
</td>
|
||||||
<td className="px-3 py-3 text-right font-bold tabular-nums text-gray-700 text-xs">
|
<td className="px-3 py-3 text-right font-bold tabular-nums text-gray-700 text-xs">
|
||||||
{publicites.reduce((s, p) => s + p.qte_vendue_pub, 0).toLocaleString("fr-FR")}
|
{publicites.reduce((s, p) => s + Number(p.qte_vendue_pub), 0).toLocaleString("fr-FR")}
|
||||||
</td>
|
</td>
|
||||||
<td colSpan={3} />
|
<td colSpan={3} />
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in new issue
Block a user