fix(subscription): sidebar layout, responsive cards, feature labels

- Drop leaking mobile tab strip; settings sidebar is now desktop-only (hidden
  lg:block) and pinned right via grid lg:grid-cols-[280px_minmax(0,1fr)],
  matching the SettingsLayout pattern
- Make plan cards responsive (flex 1 1 280px, min 250 / max 340) instead of
  fixed 300px width
- Fix secretaries pill bidi rendering (rtl, single label)
- Add Persian label for the 'insurance' plan feature

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-14 14:43:28 +03:30
co-authored by Claude Opus 4.8
parent 6f5ce1696f
commit 37ddd47342
2 changed files with 83 additions and 114 deletions
@@ -5,11 +5,12 @@ import { menuForRole } from './SettingsLayout';
import { SearchHeaderP } from '../../pages/subscriptionIcons'; import { SearchHeaderP } from '../../pages/subscriptionIcons';
/** /**
* PurchaseSubscriptionSidebar — pixel-faithful port of clinic-pro-tauri's * PurchaseSubscriptionSidebar — settings sub-navigation styled after
* `PurchaseSubscriptionSidebar.jsx` (title + search + tab list, orange active * clinic-pro-tauri's `PurchaseSubscriptionSidebar.jsx` (title + search + tab
* pill #f17732). Unlike the Tauri original it does not switch content inline; * list, orange active pill #f17732). Desktop-only, like the rest of the
* each item is a real admin route (from SETTINGS_MENU / menuForRole), so the * clinicpro settings area (mobile nav is owned by the standalone settings list
* clinicpro routing architecture is preserved. `active` marks the open section. * page). Each item is a real admin route (SETTINGS_MENU / menuForRole) so the
* routing architecture is preserved. `active` marks the open section.
*/ */
export default function PurchaseSubscriptionSidebar({ active }: { active: string }) { export default function PurchaseSubscriptionSidebar({ active }: { active: string }) {
const primaryRole = useAuthStore((s) => s.primaryRole); const primaryRole = useAuthStore((s) => s.primaryRole);
@@ -20,109 +21,76 @@ export default function PurchaseSubscriptionSidebar({ active }: { active: string
); );
return ( return (
<div <aside
dir="ltr" dir="ltr"
style={{ aria-label="منوی تنظیمات"
flexShrink: 0, className="hidden lg:block"
borderRadius: 8, style={{ alignSelf: 'start', position: 'sticky', top: 'calc(var(--topbar-h) + 16px)' }}
background: 'transparent',
alignSelf: 'start',
position: 'sticky',
top: 'calc(var(--topbar-h) + 16px)',
}}
className="w-full md:w-[240px] lg:w-[280px] md:py-4"
> >
{/* Mobile/Tablet: horizontal scrollable tab strip */} <div style={{
<div fontSize: 16, fontWeight: 800, color: 'var(--text-2)', textAlign: 'left',
className="flex md:hidden" marginBottom: 10, padding: '0 4px',
style={{ }}>
flexDirection: 'row-reverse', overflowX: 'auto', gap: 8, تنظیمات
padding: '12px 8px', whiteSpace: 'nowrap', scrollbarWidth: 'none', </div>
}}
> <div style={{ marginBottom: 16 }}>
<div style={{
display: 'flex', alignItems: 'center', flexDirection: 'row-reverse', gap: 8,
background: 'var(--surface)', border: '1px solid var(--border)',
borderRadius: 'var(--r-sm)', padding: '8px 12px',
}}>
<SearchHeaderP />
<input
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="جستجو در تنظیمات"
aria-label="جستجو در تنظیمات"
style={{
border: 'none', outline: 'none', background: 'transparent',
fontFamily: 'inherit', fontSize: 13, color: 'var(--text)', width: '100%',
textAlign: 'right', direction: 'rtl',
}}
/>
</div>
</div>
<nav>
{items.map((item) => { {items.map((item) => {
const isActive = item.key === active; const isActive = item.key === active;
const inner = ( const rowStyle: React.CSSProperties = {
<span style={{ borderRadius: 12, height: 44, marginBottom: 8,
flexShrink: 0, borderRadius: 12, padding: '8px 16px', minWidth: 'auto', display: 'flex', alignItems: 'center', justifyContent: 'flex-start',
display: 'inline-block', fontSize: 14, fontWeight: isActive ? 700 : 500, padding: '0 14px', fontSize: 16, fontWeight: isActive ? 700 : 500,
background: isActive ? '#f17732' : 'var(--surface-2)', lineHeight: 1, textAlign: 'left',
color: isActive ? '#FFFFFF' : 'var(--text-2)', cursor: item.to ? 'pointer' : 'not-allowed', background: isActive ? '#f17732' : 'transparent',
}}>{item.label}</span> color: isActive ? '#FFFFFF' : 'var(--text-2)',
cursor: item.to ? 'pointer' : 'not-allowed',
transition: 'background .14s',
};
const inner = <span style={{ flex: 1 }}>{item.label}</span>;
if (!item.to) {
return <div key={item.key} style={{ ...rowStyle, opacity: 0.55 }}>{inner}</div>;
}
return (
<Link
key={item.key}
to={item.to}
aria-current={isActive ? 'page' : undefined}
style={rowStyle}
onMouseEnter={(e) => { if (!isActive) (e.currentTarget as HTMLElement).style.background = 'var(--surface-2)'; }}
onMouseLeave={(e) => { if (!isActive) (e.currentTarget as HTMLElement).style.background = 'transparent'; }}
>
{inner}
</Link>
); );
return item.to
? <Link key={item.key} to={item.to}>{inner}</Link>
: <span key={item.key}>{inner}</span>;
})} })}
</div> {items.length === 0 && (
<div style={{ padding: '12px 4px', fontSize: 13, color: 'var(--text-3)', textAlign: 'center' }}>
{/* Desktop: Title + Search + vertical list */} موردی یافت نشد
<div className="hidden md:block">
<div style={{
fontSize: 16, fontWeight: 800, color: 'var(--text-2)', textAlign: 'left',
marginBottom: 10, padding: '0 16px',
}}>
تنظیمات
</div>
<div style={{ padding: '0 16px', marginBottom: 16 }}>
<div style={{
display: 'flex', alignItems: 'center', flexDirection: 'row-reverse', gap: 8,
background: 'var(--surface)', border: '1px solid var(--border)',
borderRadius: 'var(--r-sm)', padding: '8px 12px',
}}>
<SearchHeaderP />
<input
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="جستجو در تنظیمات"
aria-label="جستجو در تنظیمات"
style={{
border: 'none', outline: 'none', background: 'transparent',
fontFamily: 'inherit', fontSize: 13, color: 'var(--text)', width: '100%',
textAlign: 'right', direction: 'rtl',
}}
/>
</div> </div>
</div> )}
</nav>
<nav style={{ padding: '0 16px' }}> </aside>
{items.map((item) => {
const isActive = item.key === active;
const rowStyle: React.CSSProperties = {
borderRadius: 12, height: 44, marginBottom: 8,
display: 'flex', alignItems: 'center', justifyContent: 'flex-start',
padding: '0 14px', fontSize: 16, fontWeight: isActive ? 700 : 500,
lineHeight: 1, textAlign: 'left',
background: isActive ? '#f17732' : 'transparent',
color: isActive ? '#FFFFFF' : 'var(--text-2)',
cursor: item.to ? 'pointer' : 'not-allowed',
transition: 'background .14s',
};
const inner = <span style={{ flex: 1 }}>{item.label}</span>;
if (!item.to) {
return <div key={item.key} style={{ ...rowStyle, opacity: 0.55 }}>{inner}</div>;
}
return (
<Link
key={item.key}
to={item.to}
aria-current={isActive ? 'page' : undefined}
style={rowStyle}
onMouseEnter={(e) => { if (!isActive) (e.currentTarget as HTMLElement).style.background = 'var(--surface-2)'; }}
onMouseLeave={(e) => { if (!isActive) (e.currentTarget as HTMLElement).style.background = 'transparent'; }}
>
{inner}
</Link>
);
})}
{items.length === 0 && (
<div style={{ padding: '12px 4px', fontSize: 13, color: 'var(--text-3)', textAlign: 'center' }}>
موردی یافت نشد
</div>
)}
</nav>
</div>
</div>
); );
} }
+13 -12
View File
@@ -21,6 +21,7 @@ export const PLAN_FEATURE_LABELS: Record<string, string> = {
patient_records: 'پرونده بیمار', patient_records: 'پرونده بیمار',
services: 'مدیریت سرویس‌ها', services: 'مدیریت سرویس‌ها',
sms_panel: 'پنل پیامک', sms_panel: 'پنل پیامک',
insurance: 'مدیریت بیمه',
}; };
/** Feature labels used on the plan cards — wording copied from clinic-pro-tauri. */ /** Feature labels used on the plan cards — wording copied from clinic-pro-tauri. */
@@ -28,6 +29,7 @@ const CARD_FEATURE_LABELS: Record<string, string> = {
patient_records: 'مدیریت پرونده بیمار', patient_records: 'مدیریت پرونده بیمار',
services: 'مدیریت سرویس ها', services: 'مدیریت سرویس ها',
sms_panel: 'پنل پیامک', sms_panel: 'پنل پیامک',
insurance: 'مدیریت بیمه',
}; };
/** The plan highlighted as "most popular" in the UI (no backend flag exists). */ /** The plan highlighted as "most popular" in the UI (no backend flag exists). */
@@ -114,12 +116,12 @@ export default function SubscriptionPage() {
return ( return (
<div className="fade-in" dir="rtl" style={{ maxWidth: 1180, margin: '0 auto' }}> <div className="fade-in" dir="rtl" style={{ maxWidth: 1180, margin: '0 auto' }}>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'stretch', gap: 0 }} className="flex-col md:flex-row"> <div className="grid grid-cols-1 lg:grid-cols-[280px_minmax(0,1fr)] gap-5">
<PurchaseSubscriptionSidebar active="subscription" /> <PurchaseSubscriptionSidebar active="subscription" />
<div <div
style={{ flex: 1, background: 'var(--surface)', minWidth: 0 }} style={{ background: 'var(--surface)', minWidth: 0 }}
className="px-4 py-4 md:px-8 md:py-6 md:mr-2 rounded-[var(--r-lg)]" className="px-4 py-4 md:px-6 md:py-6 rounded-[var(--r-lg)]"
> >
<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) ── */}
@@ -137,7 +139,7 @@ export default function SubscriptionPage() {
{plansLoading ? ( {plansLoading ? (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 16, justifyContent: 'flex-end', width: '100%' }}> <div style={{ display: 'flex', flexWrap: 'wrap', gap: 16, justifyContent: 'flex-end', width: '100%' }}>
{[1, 2, 3].map((i) => ( {[1, 2, 3].map((i) => (
<div key={i} className="skeleton" style={{ width: 300, height: 522, borderRadius: 10 }} /> <div key={i} className="skeleton" style={{ flex: '1 1 280px', minWidth: 250, maxWidth: 340, height: 522, borderRadius: 10 }} />
))} ))}
</div> </div>
) : plans.length === 0 ? ( ) : plans.length === 0 ? (
@@ -362,7 +364,7 @@ function PlanCard({
<div <div
data-testid={`plan-card-${plan.name}`} data-testid={`plan-card-${plan.name}`}
style={{ style={{
width: 300, maxWidth: '100%', height: 522, borderRadius: 10, flex: '1 1 280px', minWidth: 250, maxWidth: 340, height: 522, borderRadius: 10,
border: isSelected ? '2px solid #494cb3' : '2px solid var(--border)', border: isSelected ? '2px solid #494cb3' : '2px solid var(--border)',
background: 'var(--surface)', display: 'flex', flexDirection: 'column', background: 'var(--surface)', display: 'flex', flexDirection: 'column',
padding: 16, position: 'relative', overflow: 'hidden', padding: 16, position: 'relative', overflow: 'hidden',
@@ -398,15 +400,14 @@ function PlanCard({
{/* Secretaries pill */} {/* Secretaries pill */}
<div style={{ width: '100%', display: 'flex', justifyContent: 'flex-end' }}> <div style={{ width: '100%', display: 'flex', justifyContent: 'flex-end' }}>
<div style={{ <div dir="rtl" style={{
minWidth: 86, height: 32, borderRadius: 29, background: 'var(--surface-3)', minWidth: 86, height: 32, borderRadius: 29, background: 'var(--surface-3)',
color: 'var(--text)', display: 'flex', gap: 5, alignItems: 'center', justifyContent: 'center', color: 'var(--text)', display: 'flex', gap: 6, alignItems: 'center', justifyContent: 'center',
padding: '0 8px', padding: '0 12px',
}}> }}>
<div style={{ display: 'flex', gap: 4, alignItems: 'center' }}> <span style={{ fontSize: 14, fontWeight: 500, whiteSpace: 'nowrap' }}>
<span style={{ fontSize: 14 }}>منشی</span> {formatNumber(plan.max_secretaries)} منشی
<span style={{ fontSize: 14, fontWeight: 500 }}>{formatNumber(plan.max_secretaries)}</span> </span>
</div>
<PlanCardPerson size={18} /> <PlanCardPerson size={18} />
</div> </div>
</div> </div>