From b83325b8e343d65d30261a9c2e34c49df744edc5 Mon Sep 17 00:00:00 2001 From: sazzadulalambd Date: Thu, 21 May 2026 11:40:03 +0600 Subject: [PATCH] refactor: overhaul project structure, update configuration, and improve consistency across admin and investor dashboard components. --- JML | 1 + .../settings/components/PlanSelection.tsx | 170 +++++++++++++++--- src/app/admin/settings/page.tsx | 39 ++++ 3 files changed, 189 insertions(+), 21 deletions(-) create mode 160000 JML diff --git a/JML b/JML new file mode 160000 index 0000000..7332f85 --- /dev/null +++ b/JML @@ -0,0 +1 @@ +Subproject commit 7332f855125c16aac91e30b94b1e6aa2e6a3e22e diff --git a/src/app/admin/settings/components/PlanSelection.tsx b/src/app/admin/settings/components/PlanSelection.tsx index 06a164e..28380e5 100644 --- a/src/app/admin/settings/components/PlanSelection.tsx +++ b/src/app/admin/settings/components/PlanSelection.tsx @@ -1,7 +1,7 @@ 'use client'; import { useState } from 'react'; -import { Plus, Save, Trash2, X } from 'lucide-react'; +import { Plus, Save, Trash2, X, Gift } from 'lucide-react'; import { CompanySettings } from '../page'; interface PlanSelectionProps { @@ -14,6 +14,108 @@ interface PlanSelectionProps { isDirty?: boolean; } +// Reusable Free Service Conditions editor +function FreeServiceConditions({ + conditions, + accentColor, + onChange, +}: { + conditions: { months: number; freeServices: number }[]; + accentColor: string; + onChange: (updated: { months: number; freeServices: number }[]) => void; +}) { + const addCondition = () => { + onChange([...conditions, { months: 3, freeServices: 1 }]); + }; + + const removeCondition = (i: number) => { + onChange(conditions.filter((_, idx) => idx !== i)); + }; + + const updateCondition = (i: number, field: 'months' | 'freeServices', value: number) => { + const updated = conditions.map((c, idx) => idx === i ? { ...c, [field]: value } : c); + onChange(updated); + }; + + return ( +
+
+
+ + + + e.g. "3 months → 2 free services" + +
+ +
+ + {conditions.length === 0 && ( +

+ No free service conditions set. Click "Add Condition" to add one. +

+ )} + +
+ {conditions.map((cond, i) => ( +
+ {/* Month input */} +
+ + updateCondition(i, 'months', parseInt(e.target.value) || 1)} + className="w-16 px-2 py-1 border border-slate-200 rounded-md text-xs text-slate-800 text-center font-semibold focus:outline-none focus:ring-1 focus:ring-amber-400" + /> +
+ + + + {/* Free services input */} +
+ + updateCondition(i, 'freeServices', parseInt(e.target.value) || 1)} + className="w-16 px-2 py-1 border border-slate-200 rounded-md text-xs text-slate-800 text-center font-semibold focus:outline-none focus:ring-1 focus:ring-amber-400" + /> +
+ + {/* Preview badge */} + + {cond.months} {cond.months === 1 ? 'month' : 'months'} → {cond.freeServices} free service{cond.freeServices !== 1 ? 's' : ''} free + + + {/* Remove */} + +
+ ))} +
+
+ ); +} + export default function PlanSelection({ settings, setSettings, @@ -172,6 +274,18 @@ export default function PlanSelection({ {plan.contractMonths.length === 0 &&

No contract months selected.

} + + {/* Free Service Conditions */} + { + const plans = [...settings.plans.singleRent]; + plans[idx] = { ...plans[idx], freeServiceConditions: updated }; + setSettings({ ...settings, plans: { ...settings.plans, singleRent: plans } }); + }} + /> +