- Partager sur les réseaux
+ Diffusion réseaux
- {networks.map((network) => {
+ {chosenNetworks.map((network) => {
const last = lastShare.get(`${p.id}:${network}`);
- if (!last) return null;
+ const posted = last?.status === "posted";
return (
-
- {last.status === "posted" ? (
- <>
- ✓ {SOCIAL_LABELS[network]} · {fmtDate(last.createdAt)}
- {last.authorName ? ` · ${last.authorName}` : ""}
- {last.url && (
- <>
- {" "}
-
- voir
-
- >
- )}
- >
- ) : (
- <>✕ {SOCIAL_LABELS[network]} — échec : {last.error?.slice(0, 160)}>
+
+
+
+
+
+ {SOCIAL_LABELS[network]} ·{" "}
+ {posted ? `publié le ${fmtDate(last!.createdAt)}` : "non publié"}
+ {posted && last?.url && (
+
+ voir
+
+ )}
+
+ {!posted && last?.error && (
+
+ {last.error.slice(0, 200)}
+
+ )}
+ {!posted && p.status === "live" && (
+
)}
);
@@ -279,42 +324,3 @@ export default async function PromotionsPage() {
);
}
-function ShareButton({
- network,
- promoId,
- disabled,
- last,
-}: {
- network: SocialNetwork;
- promoId: number;
- disabled: boolean;
- last?: { status: string };
-}) {
- const alreadyPosted = last?.status === "posted";
- const brand = network === "facebook" ? "#1877F2" : "#0A66C2";
- return (
-
- );
-}
diff --git a/src/db/schema.ts b/src/db/schema.ts
index 9bd4ee3..a28370a 100644
--- a/src/db/schema.ts
+++ b/src/db/schema.ts
@@ -100,6 +100,10 @@ export const promotions = pgTable("promotions", {
memberId: integer("member_id").references(() => members.id),
status: promoStatusEnum("status").notNull().default("pending"),
validUntil: varchar("valid_until", { length: 120 }),
+ // Réseaux demandés à la soumission. Le choix reste modifiable tant que la
+ // promo est « pending » ; la validation le fige ET déclenche la publication.
+ shareFacebook: boolean("share_facebook").notNull().default(false),
+ shareLinkedin: boolean("share_linkedin").notNull().default(false),
suspendedBy: promoSuspendedByEnum("suspended_by"),
suspendedById: integer("suspended_by_id").references(() => users.id, { onDelete: "set null" }),
suspendedAt: timestamp("suspended_at", { withTimezone: true }),