Compare commits

..

2 Commits

4 changed files with 70 additions and 9 deletions

View File

@ -115,6 +115,7 @@ export default function App() {
const [selectedEditPricePlan, setSelectedEditPricePlan] = useState<any | null>(null); const [selectedEditPricePlan, setSelectedEditPricePlan] = useState<any | null>(null);
const [editPriceInr, setEditPriceInr] = useState<string>(''); const [editPriceInr, setEditPriceInr] = useState<string>('');
const [editPriceUsd, setEditPriceUsd] = useState<string>(''); const [editPriceUsd, setEditPriceUsd] = useState<string>('');
const [editPriceEur, setEditPriceEur] = useState<string>('');
const [editPlanName, setEditPlanName] = useState<string>(''); const [editPlanName, setEditPlanName] = useState<string>('');
const [editPlanDesc, setEditPlanDesc] = useState<string>(''); const [editPlanDesc, setEditPlanDesc] = useState<string>('');
const [editPlanBadge, setEditPlanBadge] = useState<string>(''); const [editPlanBadge, setEditPlanBadge] = useState<string>('');
@ -134,6 +135,7 @@ export default function App() {
const [createPlanDuration, setCreatePlanDuration] = useState<string>('yearly'); const [createPlanDuration, setCreatePlanDuration] = useState<string>('yearly');
const [createPlanPriceInr, setCreatePlanPriceInr] = useState<string>(''); const [createPlanPriceInr, setCreatePlanPriceInr] = useState<string>('');
const [createPlanPriceUsd, setCreatePlanPriceUsd] = useState<string>(''); const [createPlanPriceUsd, setCreatePlanPriceUsd] = useState<string>('');
const [createPlanPriceEur, setCreatePlanPriceEur] = useState<string>('');
const [createPlanModuleIds, setCreatePlanModuleIds] = useState<string[]>([]); const [createPlanModuleIds, setCreatePlanModuleIds] = useState<string[]>([]);
const [createPlanSaving, setCreatePlanSaving] = useState<boolean>(false); const [createPlanSaving, setCreatePlanSaving] = useState<boolean>(false);
const [createPlanError, setCreatePlanError] = useState<string | null>(null); const [createPlanError, setCreatePlanError] = useState<string | null>(null);
@ -595,6 +597,7 @@ export default function App() {
setSelectedEditPricePlan(plan); setSelectedEditPricePlan(plan);
setEditPriceInr(String(plan.price_inr ?? '')); setEditPriceInr(String(plan.price_inr ?? ''));
setEditPriceUsd(String(plan.price_usd ?? '')); setEditPriceUsd(String(plan.price_usd ?? ''));
setEditPriceEur(String(plan.price_eur ?? plan.price_usd ?? ''));
setEditPlanName(plan.name || ''); setEditPlanName(plan.name || '');
setEditPlanDesc(plan.description || ''); setEditPlanDesc(plan.description || '');
setEditPlanBadge(plan.badge_text || ''); setEditPlanBadge(plan.badge_text || '');
@ -607,7 +610,8 @@ export default function App() {
if (!selectedEditPricePlan || !userToken) return; if (!selectedEditPricePlan || !userToken) return;
const inrVal = parseFloat(editPriceInr); const inrVal = parseFloat(editPriceInr);
const usdVal = parseFloat(editPriceUsd); const usdVal = parseFloat(editPriceUsd);
if (isNaN(inrVal) || inrVal < 0 || isNaN(usdVal) || usdVal < 0) { const eurVal = editPriceEur.trim() ? parseFloat(editPriceEur) : usdVal;
if (isNaN(inrVal) || inrVal < 0 || isNaN(usdVal) || usdVal < 0 || isNaN(eurVal) || eurVal < 0) {
alert('Please enter valid positive pricing values.'); alert('Please enter valid positive pricing values.');
return; return;
} }
@ -618,6 +622,7 @@ export default function App() {
{ {
price_inr: inrVal, price_inr: inrVal,
price_usd: usdVal, price_usd: usdVal,
price_eur: eurVal,
name: editPlanName.trim() || undefined, name: editPlanName.trim() || undefined,
description: editPlanDesc.trim() || undefined, description: editPlanDesc.trim() || undefined,
badge_text: editPlanBadge.trim() || undefined, badge_text: editPlanBadge.trim() || undefined,
@ -638,6 +643,7 @@ export default function App() {
subtitle: editPlanSubtitle.trim() || selectedEditPricePlan.subtitle, subtitle: editPlanSubtitle.trim() || selectedEditPricePlan.subtitle,
price_inr: inrVal, price_inr: inrVal,
price_usd: usdVal, price_usd: usdVal,
price_eur: eurVal,
} }
: p : p
) )
@ -665,6 +671,7 @@ export default function App() {
setCreatePlanDuration('yearly'); setCreatePlanDuration('yearly');
setCreatePlanPriceInr(''); setCreatePlanPriceInr('');
setCreatePlanPriceUsd(''); setCreatePlanPriceUsd('');
setCreatePlanPriceEur('');
setCreatePlanModuleIds([]); setCreatePlanModuleIds([]);
setCreatePlanError(null); setCreatePlanError(null);
setShowCreatePlanModal(true); setShowCreatePlanModal(true);
@ -679,8 +686,9 @@ export default function App() {
} }
const inrVal = parseFloat(createPlanPriceInr); const inrVal = parseFloat(createPlanPriceInr);
const usdVal = parseFloat(createPlanPriceUsd); const usdVal = parseFloat(createPlanPriceUsd);
if (isNaN(inrVal) || inrVal < 0 || isNaN(usdVal) || usdVal < 0) { const eurVal = createPlanPriceEur.trim() ? parseFloat(createPlanPriceEur) : usdVal;
setCreatePlanError('Please provide valid positive prices for INR and USD.'); if (isNaN(inrVal) || inrVal < 0 || isNaN(usdVal) || usdVal < 0 || isNaN(eurVal) || eurVal < 0) {
setCreatePlanError('Please provide valid positive prices for INR, USD, and EUR.');
return; return;
} }
if (createPlanModuleIds.length === 0) { if (createPlanModuleIds.length === 0) {
@ -703,6 +711,7 @@ export default function App() {
billing_period: createPlanDuration, billing_period: createPlanDuration,
price_inr: inrVal, price_inr: inrVal,
price_usd: usdVal, price_usd: usdVal,
price_eur: eurVal,
module_ids: createPlanModuleIds, module_ids: createPlanModuleIds,
is_featured: false, is_featured: false,
}, },
@ -1257,6 +1266,7 @@ export default function App() {
duration={createPlanDuration} duration={createPlanDuration}
priceInr={createPlanPriceInr} priceInr={createPlanPriceInr}
priceUsd={createPlanPriceUsd} priceUsd={createPlanPriceUsd}
priceEur={createPlanPriceEur}
selectedModuleIds={createPlanModuleIds} selectedModuleIds={createPlanModuleIds}
allModules={adminModulesList} allModules={adminModulesList}
saving={createPlanSaving} saving={createPlanSaving}
@ -1270,7 +1280,13 @@ export default function App() {
onTypeChange={setCreatePlanType} onTypeChange={setCreatePlanType}
onDurationChange={setCreatePlanDuration} onDurationChange={setCreatePlanDuration}
onPriceInrChange={setCreatePlanPriceInr} onPriceInrChange={setCreatePlanPriceInr}
onPriceUsdChange={setCreatePlanPriceUsd} onPriceUsdChange={(v) => {
setCreatePlanPriceUsd(v);
if (!createPlanPriceEur || createPlanPriceEur === createPlanPriceUsd) {
setCreatePlanPriceEur(v);
}
}}
onPriceEurChange={setCreatePlanPriceEur}
onToggleModule={(id) => onToggleModule={(id) =>
setCreatePlanModuleIds((prev) => setCreatePlanModuleIds((prev) =>
prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id] prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id]
@ -1291,6 +1307,7 @@ export default function App() {
subtitle={editPlanSubtitle} subtitle={editPlanSubtitle}
priceInr={editPriceInr} priceInr={editPriceInr}
priceUsd={editPriceUsd} priceUsd={editPriceUsd}
priceEur={editPriceEur}
saving={editPriceSaving} saving={editPriceSaving}
onNameChange={setEditPlanName} onNameChange={setEditPlanName}
onDescChange={setEditPlanDesc} onDescChange={setEditPlanDesc}
@ -1299,6 +1316,7 @@ export default function App() {
onSubtitleChange={setEditPlanSubtitle} onSubtitleChange={setEditPlanSubtitle}
onPriceInrChange={setEditPriceInr} onPriceInrChange={setEditPriceInr}
onPriceUsdChange={setEditPriceUsd} onPriceUsdChange={setEditPriceUsd}
onPriceEurChange={setEditPriceEur}
onSave={handleSavePlanPrice} onSave={handleSavePlanPrice}
onClose={() => setSelectedEditPricePlan(null)} onClose={() => setSelectedEditPricePlan(null)}
/> />

View File

@ -14,6 +14,7 @@ interface CreatePlanModalProps {
duration: string; duration: string;
priceInr: string; priceInr: string;
priceUsd: string; priceUsd: string;
priceEur: string;
selectedModuleIds: string[]; selectedModuleIds: string[];
allModules: any[]; allModules: any[];
saving: boolean; saving: boolean;
@ -28,6 +29,7 @@ interface CreatePlanModalProps {
onDurationChange: (v: string) => void; onDurationChange: (v: string) => void;
onPriceInrChange: (v: string) => void; onPriceInrChange: (v: string) => void;
onPriceUsdChange: (v: string) => void; onPriceUsdChange: (v: string) => void;
onPriceEurChange: (v: string) => void;
onToggleModule: (id: string) => void; onToggleModule: (id: string) => void;
onSelectAllModules: () => void; onSelectAllModules: () => void;
onClearAllModules: () => void; onClearAllModules: () => void;
@ -47,6 +49,7 @@ export const CreatePlanModal: React.FC<CreatePlanModalProps> = ({
duration, duration,
priceInr, priceInr,
priceUsd, priceUsd,
priceEur,
selectedModuleIds, selectedModuleIds,
allModules, allModules,
saving, saving,
@ -61,6 +64,7 @@ export const CreatePlanModal: React.FC<CreatePlanModalProps> = ({
onDurationChange, onDurationChange,
onPriceInrChange, onPriceInrChange,
onPriceUsdChange, onPriceUsdChange,
onPriceEurChange,
onToggleModule, onToggleModule,
onSelectAllModules, onSelectAllModules,
onClearAllModules, onClearAllModules,
@ -193,8 +197,8 @@ export const CreatePlanModal: React.FC<CreatePlanModalProps> = ({
</div> </div>
</div> </div>
{/* Dual Currency Pricing */} {/* Multi-Currency Pricing (INR / USD / EUR) */}
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div> <div>
<label className="block text-xs font-bold text-slate-600 mb-1">Price (₹ INR)</label> <label className="block text-xs font-bold text-slate-600 mb-1">Price (₹ INR)</label>
<div className="relative"> <div className="relative">
@ -227,6 +231,21 @@ export const CreatePlanModal: React.FC<CreatePlanModalProps> = ({
/> />
</div> </div>
</div> </div>
<div>
<label className="block text-xs font-bold text-slate-600 mb-1">Price (€ EUR)</label>
<div className="relative">
<span className="absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 font-bold text-xs">€</span>
<input
type="number"
step="0.01"
min="0"
placeholder="19.99"
value={priceEur}
onChange={(e) => onPriceEurChange(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-xl pl-7 pr-3 py-2 text-xs font-bold text-slate-800 focus:outline-none focus:border-indigo-500"
/>
</div>
</div>
</div> </div>
{/* Module Selection */} {/* Module Selection */}

View File

@ -10,6 +10,7 @@ interface EditPriceModalProps {
subtitle: string; subtitle: string;
priceInr: string; priceInr: string;
priceUsd: string; priceUsd: string;
priceEur: string;
saving: boolean; saving: boolean;
onNameChange: (v: string) => void; onNameChange: (v: string) => void;
onDescChange: (v: string) => void; onDescChange: (v: string) => void;
@ -18,6 +19,7 @@ interface EditPriceModalProps {
onSubtitleChange: (v: string) => void; onSubtitleChange: (v: string) => void;
onPriceInrChange: (v: string) => void; onPriceInrChange: (v: string) => void;
onPriceUsdChange: (v: string) => void; onPriceUsdChange: (v: string) => void;
onPriceEurChange: (v: string) => void;
onSave: (e: React.FormEvent) => void; onSave: (e: React.FormEvent) => void;
onClose: () => void; onClose: () => void;
} }
@ -31,6 +33,7 @@ export const EditPriceModal: React.FC<EditPriceModalProps> = ({
subtitle, subtitle,
priceInr, priceInr,
priceUsd, priceUsd,
priceEur,
saving, saving,
onNameChange, onNameChange,
onDescChange, onDescChange,
@ -39,6 +42,7 @@ export const EditPriceModal: React.FC<EditPriceModalProps> = ({
onSubtitleChange, onSubtitleChange,
onPriceInrChange, onPriceInrChange,
onPriceUsdChange, onPriceUsdChange,
onPriceEurChange,
onSave, onSave,
onClose, onClose,
}) => { }) => {
@ -114,7 +118,7 @@ export const EditPriceModal: React.FC<EditPriceModalProps> = ({
</div> </div>
</div> </div>
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div> <div>
<label className="block text-xs font-bold text-slate-600 mb-1">Price (₹ INR)</label> <label className="block text-xs font-bold text-slate-600 mb-1">Price (₹ INR)</label>
<div className="relative"> <div className="relative">
@ -146,6 +150,22 @@ export const EditPriceModal: React.FC<EditPriceModalProps> = ({
/> />
</div> </div>
</div> </div>
<div>
<label className="block text-xs font-bold text-slate-600 mb-1">Price (€ EUR)</label>
<div className="relative">
<span className="absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 font-bold text-xs">€</span>
<input
type="number"
step="0.01"
min="0"
required
value={priceEur}
onChange={(e) => onPriceEurChange(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-xl pl-7 pr-3 py-2 text-xs font-bold text-slate-800 focus:outline-none focus:border-indigo-500"
/>
</div>
</div>
</div> </div>
<div className="flex gap-2 pt-2"> <div className="flex gap-2 pt-2">

View File

@ -139,7 +139,7 @@ export const PlansTab: React.FC<PlansTabProps> = ({
<th className="py-3.5 px-4">Plan Details</th> <th className="py-3.5 px-4">Plan Details</th>
<th className="py-3.5 px-3">Type & Duration</th> <th className="py-3.5 px-3">Type & Duration</th>
<th className="py-3.5 px-3">Included Modules</th> <th className="py-3.5 px-3">Included Modules</th>
<th className="py-3.5 px-3">Live Pricing (INR / USD)</th> <th className="py-3.5 px-3">Live Pricing (INR / USD / EUR)</th>
<th className="py-3.5 px-3 text-center">Subscribers</th> <th className="py-3.5 px-3 text-center">Subscribers</th>
<th className="py-3.5 px-3 text-center">Status</th> <th className="py-3.5 px-3 text-center">Status</th>
<th className="py-3.5 px-4 text-right">Actions</th> <th className="py-3.5 px-4 text-right">Actions</th>
@ -260,7 +260,11 @@ export const PlansTab: React.FC<PlansTabProps> = ({
<td className="py-3.5 px-3 whitespace-nowrap"> <td className="py-3.5 px-3 whitespace-nowrap">
<div className="space-y-0.5 font-bold"> <div className="space-y-0.5 font-bold">
<p className="text-xs text-slate-800 font-mono">₹{plan.price_inr ?? '—'}</p> <p className="text-xs text-slate-800 font-mono">₹{plan.price_inr ?? '—'}</p>
<p className="text-[10px] text-slate-400 font-mono">${plan.price_usd ?? '—'}</p> <div className="flex items-center gap-1.5 text-[10px] font-mono">
<span className="text-slate-400">${plan.price_usd ?? '—'}</span>
<span className="text-slate-300">•</span>
<span className="text-indigo-600 font-bold">€{plan.price_eur ?? plan.price_usd ?? '—'}</span>
</div>
</div> </div>
</td> </td>