fix(discount): move Discount Management tab to the /admin/subscription page
The discount tab was wired into AdminSubscriptionPage (route /admin/admin-subscription, admin-only) but /admin/subscription renders the doctor/clinic SubscriptionPage. Since discount rules are owner-scoped, add the segmented «مدیریت تخفیفها» tab there and revert AdminSubscriptionPage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,6 @@ import Modal from '../components/ui/Modal';
|
|||||||
import ConfirmDialog from '../components/ui/ConfirmDialog';
|
import ConfirmDialog from '../components/ui/ConfirmDialog';
|
||||||
import PageHeader from '../components/ui/PageHeader';
|
import PageHeader from '../components/ui/PageHeader';
|
||||||
import Pagination from '../components/ui/Pagination';
|
import Pagination from '../components/ui/Pagination';
|
||||||
import DiscountTab from '../components/DiscountTab';
|
|
||||||
|
|
||||||
// ── Types ─────────────────────────────────────────────────────────────────
|
// ── Types ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -436,21 +435,19 @@ function ReportTab() {
|
|||||||
// ── Main ──────────────────────────────────────────────────────────────────
|
// ── Main ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function AdminSubscriptionPage() {
|
export default function AdminSubscriptionPage() {
|
||||||
const [tab, setTab] = useState<'plans' | 'report' | 'discounts'>('plans');
|
const [tab, setTab] = useState<'plans' | 'report'>('plans');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PageHeader title="مدیریت اشتراکها" description="تعریف پلنها، دورهها، تخفیفها و گزارش فروش" />
|
<PageHeader title="مدیریت اشتراکها" description="تعریف پلنها، دورهها و گزارش فروش" />
|
||||||
|
|
||||||
<div className="seg" style={{ marginBottom: 20 }}>
|
<div className="seg" style={{ marginBottom: 20 }}>
|
||||||
<button className={tab === 'plans' ? 'on' : ''} onClick={() => setTab('plans')}>پلنها و دورهها</button>
|
<button className={tab === 'plans' ? 'on' : ''} onClick={() => setTab('plans')}>پلنها و دورهها</button>
|
||||||
<button className={tab === 'discounts' ? 'on' : ''} onClick={() => setTab('discounts')}>مدیریت تخفیفها</button>
|
<button className={tab === 'report' ? 'on' : ''} onClick={() => setTab('report')}>گزارش فروش</button>
|
||||||
<button className={tab === 'report' ? 'on' : ''} onClick={() => setTab('report')}>گزارش فروش</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{tab === 'plans' && <PlansTab />}
|
{tab === 'plans' && <PlansTab />}
|
||||||
{tab === 'discounts' && <DiscountTab />}
|
{tab === 'report' && <ReportTab />}
|
||||||
{tab === 'report' && <ReportTab />}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { usePaymentConfig } from '../hooks/usePaymentConfig';
|
|||||||
import { formatRial, formatNumber } from '../lib/utils';
|
import { formatRial, formatNumber } from '../lib/utils';
|
||||||
import Modal from '../components/ui/Modal';
|
import Modal from '../components/ui/Modal';
|
||||||
import SettingsLayout from '../components/layout/SettingsLayout';
|
import SettingsLayout from '../components/layout/SettingsLayout';
|
||||||
|
import DiscountTab from '../components/DiscountTab';
|
||||||
import {
|
import {
|
||||||
SparkleIcon, PlanCardPerson, CloseCircleFilled, GiftIcon, InfoCircleRedFilled,
|
SparkleIcon, PlanCardPerson, CloseCircleFilled, GiftIcon, InfoCircleRedFilled,
|
||||||
} from './subscriptionIcons';
|
} from './subscriptionIcons';
|
||||||
@@ -55,6 +56,7 @@ export const planMetaOf = (name: string) => PLAN_META[name] ?? PLAN_META.free;
|
|||||||
|
|
||||||
export default function SubscriptionPage() {
|
export default function SubscriptionPage() {
|
||||||
const qc = useQueryClient();
|
const qc = useQueryClient();
|
||||||
|
const [tab, setTab] = useState<'plans' | 'discounts'>('plans');
|
||||||
const [purchaseTarget, setPurchaseTarget] = useState<{ period: SubscriptionPeriod; planName: string } | null>(null);
|
const [purchaseTarget, setPurchaseTarget] = useState<{ period: SubscriptionPeriod; planName: string } | null>(null);
|
||||||
const [selectedGateway, setSelectedGateway] = useState<string>('');
|
const [selectedGateway, setSelectedGateway] = useState<string>('');
|
||||||
|
|
||||||
@@ -122,6 +124,14 @@ export default function SubscriptionPage() {
|
|||||||
style={{ background: 'var(--surface)', minWidth: 0 }}
|
style={{ background: 'var(--surface)', minWidth: 0 }}
|
||||||
className="px-4 py-4 md:px-6 md:py-6 rounded-[var(--r-lg)]"
|
className="px-4 py-4 md:px-6 md:py-6 rounded-[var(--r-lg)]"
|
||||||
>
|
>
|
||||||
|
<div className="seg" style={{ marginBottom: 20 }}>
|
||||||
|
<button className={tab === 'plans' ? 'on' : ''} onClick={() => setTab('plans')}>اشتراک</button>
|
||||||
|
<button className={tab === 'discounts' ? 'on' : ''} onClick={() => setTab('discounts')}>مدیریت تخفیفها</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{tab === 'discounts' ? (
|
||||||
|
<DiscountTab />
|
||||||
|
) : (
|
||||||
<div dir="ltr" style={{ width: '100%', display: 'flex', flexDirection: 'column', gap: 32, paddingTop: 8 }}>
|
<div dir="ltr" style={{ width: '100%', display: 'flex', flexDirection: 'column', gap: 32, paddingTop: 8 }}>
|
||||||
{/* ── Header: current plan (left) + title (right) ── */}
|
{/* ── Header: current plan (left) + title (right) ── */}
|
||||||
<div style={{ display: 'flex', width: '100%', justifyContent: 'space-between', alignItems: 'center', gap: 16, flexWrap: 'wrap' }}>
|
<div style={{ display: 'flex', width: '100%', justifyContent: 'space-between', alignItems: 'center', gap: 16, flexWrap: 'wrap' }}>
|
||||||
@@ -163,6 +173,7 @@ export default function SubscriptionPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</SettingsLayout>
|
</SettingsLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user