refactor(services): merge insurance coverage into the service edit modal
- extract ContractCard + contracts list from ServiceInsuranceModal into a new inline ServiceInsuranceSection (no dialog wrapper; buttons type=button so they don't submit the parent service form) - ClinicServicesPage: drop the separate 'پوشش بیمه' menu action and its standalone modal; render coverage inline under the service fields in the edit modal (edit only — needs the item uuid; create shows a hint) - delete now-unused ServiceInsuranceModal.tsx - fix undefined --primary-subtle token → --primary-soft - test: coverage renders inline inside the service edit modal Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,7 @@ import Modal from '../components/ui/Modal';
|
||||
import PriceInput from '../components/ui/PriceInput';
|
||||
import ConfirmDialog from '../components/ui/ConfirmDialog';
|
||||
import ServiceTariffModal from '../components/ServiceTariffModal';
|
||||
import ServiceInsuranceModal from '../components/ServiceInsuranceModal';
|
||||
import ServiceInsuranceSection from '../components/ServiceInsuranceSection';
|
||||
import SearchableSelect from '../components/ui/SearchableSelect';
|
||||
import FeatureGate from '../components/ui/FeatureGate';
|
||||
|
||||
@@ -78,7 +78,6 @@ function ClinicServicesPageInner() {
|
||||
const [itemModal, setItemModal] = useState<'create' | ServiceItem | null>(null);
|
||||
const [toggleItem, setToggleItem] = useState<ServiceItem | null>(null);
|
||||
const [tariffItem, setTariffItem] = useState<ServiceItem | null>(null);
|
||||
const [insuranceItem, setInsuranceItem] = useState<ServiceItem | null>(null);
|
||||
const [search, setSearch] = useState('');
|
||||
const [showInactive, setShowInactive] = useState(true);
|
||||
const [menuOpen, setMenuOpen] = useState<string | null>(null);
|
||||
@@ -360,7 +359,6 @@ function ClinicServicesPageInner() {
|
||||
<div style={{ position: 'absolute', top: 40, left: 8, zIndex: 41, background: 'var(--surface)', border: '1px solid var(--border)', borderRadius: 'var(--r-sm)', boxShadow: 'var(--shadow)', padding: 6, minWidth: 176, display: 'flex', flexDirection: 'column', gap: 2 }}>
|
||||
<button style={menuItemStyle} onClick={() => { setMenuOpen(null); openEditItem(item); }}><PencilIcon style={{ width: 15 }} /> ویرایش</button>
|
||||
<button style={menuItemStyle} onClick={() => { setMenuOpen(null); setTariffItem(item); }}><BanknotesIcon style={{ width: 15 }} /> تعرفههای سالانه</button>
|
||||
<button style={menuItemStyle} onClick={() => { setMenuOpen(null); setInsuranceItem(item); }}><ShieldCheckIcon style={{ width: 15 }} /> پوشش بیمه</button>
|
||||
<button style={menuItemStyle} onClick={() => { setMenuOpen(null); setToggleItem(item); }}>{item.active ? <EyeSlashIcon style={{ width: 15 }} /> : <EyeIcon style={{ width: 15 }} />}{item.active ? ' غیرفعالکردن' : ' فعالکردن'}</button>
|
||||
</div>
|
||||
</>
|
||||
@@ -574,12 +572,25 @@ function ClinicServicesPageInner() {
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{/* پوشش بیمه — پیوسته داخل همان مودال، فقط برای سرویس ذخیرهشده */}
|
||||
{itemModal !== null && typeof itemModal === 'object' ? (
|
||||
<div style={{ marginTop: 22, paddingTop: 20, borderTop: '1px solid var(--border)' }}>
|
||||
<ServiceInsuranceSection item={itemModal} />
|
||||
</div>
|
||||
) : (
|
||||
<div style={{
|
||||
marginTop: 22, paddingTop: 20, borderTop: '1px solid var(--border)',
|
||||
fontSize: 12.5, color: 'var(--text-3)', display: 'flex', alignItems: 'center', gap: 8,
|
||||
}}>
|
||||
<ShieldCheckIcon style={{ width: 16, flexShrink: 0, color: 'var(--text-3)' }} />
|
||||
<span>برای تنظیم پوشش بیمه، ابتدا سرویس را ذخیره کنید و سپس آن را ویرایش کنید.</span>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
|
||||
<ServiceTariffModal item={tariffItem} onClose={() => setTariffItem(null)} />
|
||||
|
||||
<ServiceInsuranceModal item={insuranceItem} onClose={() => setInsuranceItem(null)} />
|
||||
|
||||
{/* Confirm حذف بخش */}
|
||||
<ConfirmDialog
|
||||
open={!!deleteSection}
|
||||
|
||||
Reference in New Issue
Block a user