@growflowstudio/growflowbilling-admin-ui 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -150,6 +150,10 @@ interface PlanFormData {
150
150
  price_yearly: string;
151
151
  currency: string;
152
152
  trial_days: number;
153
+ /** Day from signup (day 1 = signup day) on which billing starts. */
154
+ paid_start_day: number;
155
+ /** Absolute start date (YYYY-MM-DD); overrides `paid_start_day` when set. */
156
+ paid_start_date: string;
153
157
  is_active: boolean;
154
158
  contact_sales: boolean;
155
159
  is_public: boolean;
package/dist/index.d.ts CHANGED
@@ -150,6 +150,10 @@ interface PlanFormData {
150
150
  price_yearly: string;
151
151
  currency: string;
152
152
  trial_days: number;
153
+ /** Day from signup (day 1 = signup day) on which billing starts. */
154
+ paid_start_day: number;
155
+ /** Absolute start date (YYYY-MM-DD); overrides `paid_start_day` when set. */
156
+ paid_start_date: string;
153
157
  is_active: boolean;
154
158
  contact_sales: boolean;
155
159
  is_public: boolean;
package/dist/index.js CHANGED
@@ -214,7 +214,7 @@ function PlansTable({
214
214
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "h-12 px-4 text-left align-middle font-medium text-muted-foreground", children: "Modello" }),
215
215
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "h-12 px-4 text-left align-middle font-medium text-muted-foreground", children: "Prezzo Mensile" }),
216
216
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "h-12 px-4 text-left align-middle font-medium text-muted-foreground", children: "Prezzo Annuale" }),
217
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "h-12 px-4 text-left align-middle font-medium text-muted-foreground", children: "Trial" }),
217
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "h-12 px-4 text-left align-middle font-medium text-muted-foreground", children: "Inizio pagamento" }),
218
218
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "h-12 px-4 text-left align-middle font-medium text-muted-foreground", children: "Attivo" }),
219
219
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "h-12 px-4 text-left align-middle font-medium text-muted-foreground", children: "Stripe" }),
220
220
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "h-12 px-4 text-right align-middle font-medium text-muted-foreground", children: "Azioni" })
@@ -226,10 +226,7 @@ function PlansTable({
226
226
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "p-4 align-middle", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StatusBadge, { label: pricingModelLabels[plan.pricing_model], colorClass: "border" }) }),
227
227
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "p-4 align-middle", children: plan.contact_sales ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-muted-foreground", children: "Contattaci" }) : (0, import_growflowbilling_admin_core2.formatCurrency)(plan.price_monthly ?? 0, plan.currency) }),
228
228
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "p-4 align-middle", children: plan.contact_sales ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-muted-foreground", children: "Contattaci" }) : (0, import_growflowbilling_admin_core2.formatCurrency)(plan.price_yearly ?? 0, plan.currency) }),
229
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("td", { className: "p-4 align-middle", children: [
230
- plan.trial_days,
231
- " giorni"
232
- ] }),
229
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "p-4 align-middle whitespace-nowrap", children: plan.paid_start_date ? new Date(plan.paid_start_date).toLocaleDateString("it-IT") : `giorno ${plan.paid_start_day ?? plan.trial_days + 1}` }),
233
230
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "p-4 align-middle", children: plan.is_active ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.Check, { className: "w-4 h-4 text-green-600" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.X, { className: "w-4 h-4 text-muted-foreground" }) }),
234
231
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "p-4 align-middle", children: plan.stripe_price_id_monthly ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StatusBadge, { label: "Synced", colorClass: "bg-green-50 text-green-700 border-green-200" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
235
232
  "button",
@@ -426,17 +423,20 @@ function PlanPricingSection({ formData, onFormDataChange }) {
426
423
  )
427
424
  ] }),
428
425
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-2", children: [
429
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: "text-sm font-medium leading-none", htmlFor: "trial_days", children: "Giorni Trial" }),
426
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: "text-sm font-medium leading-none", htmlFor: "paid_start_day", children: "Inizio pagamento (giorno)" }),
430
427
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
431
428
  "input",
432
429
  {
433
- id: "trial_days",
430
+ id: "paid_start_day",
434
431
  type: "number",
432
+ min: 1,
435
433
  className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
436
- value: formData.trial_days,
437
- onChange: (e) => onFormDataChange({ trial_days: parseInt(e.target.value) || 0 })
434
+ value: formData.paid_start_day,
435
+ disabled: !!formData.paid_start_date,
436
+ onChange: (e) => onFormDataChange({ paid_start_day: Math.max(1, parseInt(e.target.value) || 1) })
438
437
  }
439
- )
438
+ ),
439
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-xs text-muted-foreground", children: formData.paid_start_day > 1 ? `Trial dal giorno 1 al ${formData.paid_start_day - 1}, prima fattura il giorno ${formData.paid_start_day} dalla registrazione.` : "Fatturato dal primo giorno, nessun trial." })
440
440
  ] }),
441
441
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-2", children: [
442
442
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: "text-sm font-medium leading-none", htmlFor: "sort_order", children: "Ordine" }),
@@ -451,6 +451,31 @@ function PlanPricingSection({ formData, onFormDataChange }) {
451
451
  }
452
452
  )
453
453
  ] })
454
+ ] }),
455
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-2", children: [
456
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: "text-sm font-medium leading-none", htmlFor: "paid_start_date", children: "Data fissa di inizio pagamento (opzionale)" }),
457
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2", children: [
458
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
459
+ "input",
460
+ {
461
+ id: "paid_start_date",
462
+ type: "date",
463
+ className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring max-w-xs",
464
+ value: formData.paid_start_date,
465
+ onChange: (e) => onFormDataChange({ paid_start_date: e.target.value })
466
+ }
467
+ ),
468
+ formData.paid_start_date && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
469
+ "button",
470
+ {
471
+ type: "button",
472
+ className: "text-sm text-muted-foreground underline-offset-4 hover:underline",
473
+ onClick: () => onFormDataChange({ paid_start_date: "" }),
474
+ children: "Rimuovi"
475
+ }
476
+ )
477
+ ] }),
478
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-xs text-muted-foreground", children: "Se compilata, tutti gli store su questo piano vengono fatturati a partire da questa data, ignorando il giorno relativo." })
454
479
  ] })
455
480
  ] });
456
481
  }
@@ -789,6 +814,8 @@ function createDefaultPlanFormData(limitFields = []) {
789
814
  price_yearly: "",
790
815
  currency: "eur",
791
816
  trial_days: 14,
817
+ paid_start_day: 15,
818
+ paid_start_date: "",
792
819
  is_active: true,
793
820
  contact_sales: false,
794
821
  is_public: true,
@@ -977,11 +1004,11 @@ function PlansPage({ wrapper: Wrapper, header }) {
977
1004
  const deleteMutation = (0, import_growflowbilling_admin_core3.useDeletePlan)();
978
1005
  const syncMutation = (0, import_growflowbilling_admin_core3.useSyncPlanToStripe)();
979
1006
  const [publicPlanSlugs, setPublicPlanSlugs] = (0, import_react5.useState)([]);
980
- (0, import_react5.useState)(() => {
1007
+ (0, import_react5.useEffect)(() => {
981
1008
  if (publicPlansConfig?.enabled && publicPlansConfig.fetchFn) {
982
1009
  publicPlansConfig.fetchFn().then((r) => setPublicPlanSlugs(r.public_plan_slugs));
983
1010
  }
984
- });
1011
+ }, [publicPlansConfig]);
985
1012
  const plans = data?.items || [];
986
1013
  const resetForm = () => {
987
1014
  setFormData(createDefaultPlanFormData(limitFields));
@@ -1009,6 +1036,8 @@ function PlansPage({ wrapper: Wrapper, header }) {
1009
1036
  price_yearly: plan.price_yearly ? plan.price_yearly.toString() : "",
1010
1037
  currency: plan.currency,
1011
1038
  trial_days: plan.trial_days,
1039
+ paid_start_day: plan.paid_start_day ?? plan.trial_days + 1,
1040
+ paid_start_date: plan.paid_start_date ?? "",
1012
1041
  is_active: plan.is_active,
1013
1042
  contact_sales: plan.contact_sales,
1014
1043
  is_public: publicPlanSlugs.includes(plan.slug),
@@ -1044,7 +1073,8 @@ function PlansPage({ wrapper: Wrapper, header }) {
1044
1073
  price_monthly: formData.price_monthly ? parseFloat(formData.price_monthly) : void 0,
1045
1074
  price_yearly: formData.price_yearly ? parseFloat(formData.price_yearly) : void 0,
1046
1075
  currency: formData.currency,
1047
- trial_days: formData.trial_days,
1076
+ paid_start_day: formData.paid_start_day,
1077
+ paid_start_date: formData.paid_start_date || null,
1048
1078
  is_active: formData.is_active,
1049
1079
  contact_sales: formData.contact_sales,
1050
1080
  color: formData.color,