Merge pull request 'feat/admin-eur-pricing' (#43) from feat/admin-eur-pricing into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-web-ui/pulls/43
This commit is contained in:
commit
dd7231b6a0
26
src/App.tsx
26
src/App.tsx
|
|
@ -115,6 +115,7 @@ export default function App() {
|
|||
const [selectedEditPricePlan, setSelectedEditPricePlan] = useState<any | null>(null);
|
||||
const [editPriceInr, setEditPriceInr] = useState<string>('');
|
||||
const [editPriceUsd, setEditPriceUsd] = useState<string>('');
|
||||
const [editPriceEur, setEditPriceEur] = useState<string>('');
|
||||
const [editPlanName, setEditPlanName] = useState<string>('');
|
||||
const [editPlanDesc, setEditPlanDesc] = useState<string>('');
|
||||
const [editPlanBadge, setEditPlanBadge] = useState<string>('');
|
||||
|
|
@ -134,6 +135,7 @@ export default function App() {
|
|||
const [createPlanDuration, setCreatePlanDuration] = useState<string>('yearly');
|
||||
const [createPlanPriceInr, setCreatePlanPriceInr] = useState<string>('');
|
||||
const [createPlanPriceUsd, setCreatePlanPriceUsd] = useState<string>('');
|
||||
const [createPlanPriceEur, setCreatePlanPriceEur] = useState<string>('');
|
||||
const [createPlanModuleIds, setCreatePlanModuleIds] = useState<string[]>([]);
|
||||
const [createPlanSaving, setCreatePlanSaving] = useState<boolean>(false);
|
||||
const [createPlanError, setCreatePlanError] = useState<string | null>(null);
|
||||
|
|
@ -595,6 +597,7 @@ export default function App() {
|
|||
setSelectedEditPricePlan(plan);
|
||||
setEditPriceInr(String(plan.price_inr ?? ''));
|
||||
setEditPriceUsd(String(plan.price_usd ?? ''));
|
||||
setEditPriceEur(String(plan.price_eur ?? plan.price_usd ?? ''));
|
||||
setEditPlanName(plan.name || '');
|
||||
setEditPlanDesc(plan.description || '');
|
||||
setEditPlanBadge(plan.badge_text || '');
|
||||
|
|
@ -607,7 +610,8 @@ export default function App() {
|
|||
if (!selectedEditPricePlan || !userToken) return;
|
||||
const inrVal = parseFloat(editPriceInr);
|
||||
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.');
|
||||
return;
|
||||
}
|
||||
|
|
@ -618,6 +622,7 @@ export default function App() {
|
|||
{
|
||||
price_inr: inrVal,
|
||||
price_usd: usdVal,
|
||||
price_eur: eurVal,
|
||||
name: editPlanName.trim() || undefined,
|
||||
description: editPlanDesc.trim() || undefined,
|
||||
badge_text: editPlanBadge.trim() || undefined,
|
||||
|
|
@ -638,6 +643,7 @@ export default function App() {
|
|||
subtitle: editPlanSubtitle.trim() || selectedEditPricePlan.subtitle,
|
||||
price_inr: inrVal,
|
||||
price_usd: usdVal,
|
||||
price_eur: eurVal,
|
||||
}
|
||||
: p
|
||||
)
|
||||
|
|
@ -665,6 +671,7 @@ export default function App() {
|
|||
setCreatePlanDuration('yearly');
|
||||
setCreatePlanPriceInr('');
|
||||
setCreatePlanPriceUsd('');
|
||||
setCreatePlanPriceEur('');
|
||||
setCreatePlanModuleIds([]);
|
||||
setCreatePlanError(null);
|
||||
setShowCreatePlanModal(true);
|
||||
|
|
@ -679,8 +686,9 @@ export default function App() {
|
|||
}
|
||||
const inrVal = parseFloat(createPlanPriceInr);
|
||||
const usdVal = parseFloat(createPlanPriceUsd);
|
||||
if (isNaN(inrVal) || inrVal < 0 || isNaN(usdVal) || usdVal < 0) {
|
||||
setCreatePlanError('Please provide valid positive prices for INR and USD.');
|
||||
const eurVal = createPlanPriceEur.trim() ? parseFloat(createPlanPriceEur) : usdVal;
|
||||
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;
|
||||
}
|
||||
if (createPlanModuleIds.length === 0) {
|
||||
|
|
@ -703,6 +711,7 @@ export default function App() {
|
|||
billing_period: createPlanDuration,
|
||||
price_inr: inrVal,
|
||||
price_usd: usdVal,
|
||||
price_eur: eurVal,
|
||||
module_ids: createPlanModuleIds,
|
||||
is_featured: false,
|
||||
},
|
||||
|
|
@ -1257,6 +1266,7 @@ export default function App() {
|
|||
duration={createPlanDuration}
|
||||
priceInr={createPlanPriceInr}
|
||||
priceUsd={createPlanPriceUsd}
|
||||
priceEur={createPlanPriceEur}
|
||||
selectedModuleIds={createPlanModuleIds}
|
||||
allModules={adminModulesList}
|
||||
saving={createPlanSaving}
|
||||
|
|
@ -1270,7 +1280,13 @@ export default function App() {
|
|||
onTypeChange={setCreatePlanType}
|
||||
onDurationChange={setCreatePlanDuration}
|
||||
onPriceInrChange={setCreatePlanPriceInr}
|
||||
onPriceUsdChange={setCreatePlanPriceUsd}
|
||||
onPriceUsdChange={(v) => {
|
||||
setCreatePlanPriceUsd(v);
|
||||
if (!createPlanPriceEur || createPlanPriceEur === createPlanPriceUsd) {
|
||||
setCreatePlanPriceEur(v);
|
||||
}
|
||||
}}
|
||||
onPriceEurChange={setCreatePlanPriceEur}
|
||||
onToggleModule={(id) =>
|
||||
setCreatePlanModuleIds((prev) =>
|
||||
prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id]
|
||||
|
|
@ -1291,6 +1307,7 @@ export default function App() {
|
|||
subtitle={editPlanSubtitle}
|
||||
priceInr={editPriceInr}
|
||||
priceUsd={editPriceUsd}
|
||||
priceEur={editPriceEur}
|
||||
saving={editPriceSaving}
|
||||
onNameChange={setEditPlanName}
|
||||
onDescChange={setEditPlanDesc}
|
||||
|
|
@ -1299,6 +1316,7 @@ export default function App() {
|
|||
onSubtitleChange={setEditPlanSubtitle}
|
||||
onPriceInrChange={setEditPriceInr}
|
||||
onPriceUsdChange={setEditPriceUsd}
|
||||
onPriceEurChange={setEditPriceEur}
|
||||
onSave={handleSavePlanPrice}
|
||||
onClose={() => setSelectedEditPricePlan(null)}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ interface CreatePlanModalProps {
|
|||
duration: string;
|
||||
priceInr: string;
|
||||
priceUsd: string;
|
||||
priceEur: string;
|
||||
selectedModuleIds: string[];
|
||||
allModules: any[];
|
||||
saving: boolean;
|
||||
|
|
@ -28,6 +29,7 @@ interface CreatePlanModalProps {
|
|||
onDurationChange: (v: string) => void;
|
||||
onPriceInrChange: (v: string) => void;
|
||||
onPriceUsdChange: (v: string) => void;
|
||||
onPriceEurChange: (v: string) => void;
|
||||
onToggleModule: (id: string) => void;
|
||||
onSelectAllModules: () => void;
|
||||
onClearAllModules: () => void;
|
||||
|
|
@ -47,6 +49,7 @@ export const CreatePlanModal: React.FC<CreatePlanModalProps> = ({
|
|||
duration,
|
||||
priceInr,
|
||||
priceUsd,
|
||||
priceEur,
|
||||
selectedModuleIds,
|
||||
allModules,
|
||||
saving,
|
||||
|
|
@ -61,6 +64,7 @@ export const CreatePlanModal: React.FC<CreatePlanModalProps> = ({
|
|||
onDurationChange,
|
||||
onPriceInrChange,
|
||||
onPriceUsdChange,
|
||||
onPriceEurChange,
|
||||
onToggleModule,
|
||||
onSelectAllModules,
|
||||
onClearAllModules,
|
||||
|
|
@ -193,8 +197,8 @@ export const CreatePlanModal: React.FC<CreatePlanModalProps> = ({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{/* Dual Currency Pricing */}
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
{/* Multi-Currency Pricing (INR / USD / EUR) */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
|
||||
<div>
|
||||
<label className="block text-xs font-bold text-slate-600 mb-1">Price (₹ INR)</label>
|
||||
<div className="relative">
|
||||
|
|
@ -227,6 +231,21 @@ export const CreatePlanModal: React.FC<CreatePlanModalProps> = ({
|
|||
/>
|
||||
</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>
|
||||
|
||||
{/* Module Selection */}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ interface EditPriceModalProps {
|
|||
subtitle: string;
|
||||
priceInr: string;
|
||||
priceUsd: string;
|
||||
priceEur: string;
|
||||
saving: boolean;
|
||||
onNameChange: (v: string) => void;
|
||||
onDescChange: (v: string) => void;
|
||||
|
|
@ -18,6 +19,7 @@ interface EditPriceModalProps {
|
|||
onSubtitleChange: (v: string) => void;
|
||||
onPriceInrChange: (v: string) => void;
|
||||
onPriceUsdChange: (v: string) => void;
|
||||
onPriceEurChange: (v: string) => void;
|
||||
onSave: (e: React.FormEvent) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
|
@ -31,6 +33,7 @@ export const EditPriceModal: React.FC<EditPriceModalProps> = ({
|
|||
subtitle,
|
||||
priceInr,
|
||||
priceUsd,
|
||||
priceEur,
|
||||
saving,
|
||||
onNameChange,
|
||||
onDescChange,
|
||||
|
|
@ -39,6 +42,7 @@ export const EditPriceModal: React.FC<EditPriceModalProps> = ({
|
|||
onSubtitleChange,
|
||||
onPriceInrChange,
|
||||
onPriceUsdChange,
|
||||
onPriceEurChange,
|
||||
onSave,
|
||||
onClose,
|
||||
}) => {
|
||||
|
|
@ -114,7 +118,7 @@ export const EditPriceModal: React.FC<EditPriceModalProps> = ({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
|
||||
<div>
|
||||
<label className="block text-xs font-bold text-slate-600 mb-1">Price (₹ INR)</label>
|
||||
<div className="relative">
|
||||
|
|
@ -146,6 +150,22 @@ export const EditPriceModal: React.FC<EditPriceModalProps> = ({
|
|||
/>
|
||||
</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 className="flex gap-2 pt-2">
|
||||
|
|
|
|||
|
|
@ -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-3">Type & Duration</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">Status</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">
|
||||
<div className="space-y-0.5 font-bold">
|
||||
<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>
|
||||
</td>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue