feat(admin): payment management tab in the session edit page
EditSessionPage now has سرویسها/پرداختها tabs; the payments tab renders PaymentStep so payments can be added, edited, and deleted (with audit) while editing a session, not only from the pay flow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { api } from '../lib/api';
|
||||
@@ -5,12 +6,14 @@ import type { ApiResponse } from '../lib/api';
|
||||
import type { PatientRecord } from '../types';
|
||||
import type { SessionCardData } from '../components/SessionServiceCard';
|
||||
import CreateStep from '../components/session/CreateStep';
|
||||
import PaymentStep from '../components/session/PaymentStep';
|
||||
import { ArrowLeftPH, ArrowLeftD, CloseModalD } from '../components/icons/FilesServiceIcons';
|
||||
|
||||
/** ویرایش مراجعهی ثبتشده — همان فرم «ایجاد سرویس» در حالت ویرایش (PATCH). */
|
||||
/** ویرایش مراجعهی ثبتشده — دو تب: ویرایش سرویسها + مدیریت پرداختها. */
|
||||
export default function EditSessionPage() {
|
||||
const { recordUuid = '', sessionUuid = '' } = useParams();
|
||||
const nav = useNavigate();
|
||||
const [tab, setTab] = useState<'service' | 'payment'>('service');
|
||||
|
||||
const recordQ = useQuery<ApiResponse<PatientRecord>>({
|
||||
queryKey: ['patient-detail', recordUuid],
|
||||
@@ -27,6 +30,13 @@ export default function EditSessionPage() {
|
||||
});
|
||||
const session = (sessionsQ.data?.data ?? []).find((s) => s.uuid === sessionUuid);
|
||||
|
||||
const walletQ = useQuery<ApiResponse<{ balance_rials: number }>>({
|
||||
queryKey: ['patient-wallet', recordUuid],
|
||||
queryFn: () => api.get(`/api/v1/patient/${recordUuid}/wallet`),
|
||||
enabled: !!recordUuid,
|
||||
});
|
||||
const walletBalance = (walletQ.data?.data as any)?.balance_rials ?? 0;
|
||||
|
||||
const finish = () => nav(`/admin/patients/${recordUuid}?tab=services`);
|
||||
|
||||
return (
|
||||
@@ -46,7 +56,7 @@ export default function EditSessionPage() {
|
||||
|
||||
<div style={{ width: '100%', display: 'flex', justifyContent: 'center' }}>
|
||||
<div className="bg-white dark:bg-[#222433]" style={{ width: 748, maxWidth: '100%', padding: 24 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }}>
|
||||
<h2 style={{ fontSize: 16, fontWeight: 700 }}>ویرایش مراجعه</h2>
|
||||
<button type="button" aria-label="بستن" onClick={() => nav(-1)}
|
||||
style={{ minWidth: 40, height: 40, borderRadius: '50%', border: 'none', background: 'transparent', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
@@ -54,10 +64,17 @@ export default function EditSessionPage() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{session ? (
|
||||
<div className="seg" style={{ marginBottom: 16 }}>
|
||||
<button className={tab === 'service' ? 'on' : ''} onClick={() => setTab('service')}>سرویسها</button>
|
||||
<button className={tab === 'payment' ? 'on' : ''} onClick={() => setTab('payment')}>پرداختها</button>
|
||||
</div>
|
||||
|
||||
{!session ? (
|
||||
<div style={{ padding: '40px 0', textAlign: 'center', color: 'var(--text-3)', fontSize: 14 }}>در حال بارگذاری...</div>
|
||||
) : tab === 'service' ? (
|
||||
<CreateStep recordUuid={recordUuid} profile={record?.profile} editSession={session} onCreated={finish} onCancel={() => nav(-1)} />
|
||||
) : (
|
||||
<div style={{ padding: '40px 0', textAlign: 'center', color: 'var(--text-3)', fontSize: 14 }}>در حال بارگذاری...</div>
|
||||
<PaymentStep recordUuid={recordUuid} session={session} walletBalance={walletBalance} onContinue={finish} onCancel={() => nav(-1)} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user