feat: update SMS settings review functionality
- Changed the tab name from 'post-visit-review' to 'post-visit-approved' in SmsPage. - Introduced a new query for fetching approved post-visit texts. - Updated the UI to display approved post-visit texts and their details. - Enhanced the API endpoint to filter SMS settings based on status (pending/approved). - Added entity name resolution for doctors and clinics in the SMS settings. - Updated the SmsWalletPage to include new post-visit text variables for SMS templates. - Improved type definitions in index.ts for better clarity and consistency.
This commit is contained in:
@@ -1,47 +1,67 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export interface BeforeInstallPromptEvent extends Event {
|
||||
prompt(): Promise<void>;
|
||||
userChoice: Promise<{ outcome: 'accepted' | 'dismissed' }>;
|
||||
prompt(): Promise<void>;
|
||||
userChoice: Promise<{ outcome: "accepted" | "dismissed" }>;
|
||||
}
|
||||
|
||||
const DISMISSED_KEY = 'pwa-dismissed';
|
||||
const DISMISSED_KEY = "pwa-dismissed";
|
||||
|
||||
export function usePwaInstall() {
|
||||
const [promptEvent, setPromptEvent] = useState<BeforeInstallPromptEvent | null>(null);
|
||||
const [isInstalled, setIsInstalled] = useState(false);
|
||||
const [isDismissed, setIsDismissed] = useState(() => !!localStorage.getItem(DISMISSED_KEY));
|
||||
const [promptEvent, setPromptEvent] =
|
||||
useState<BeforeInstallPromptEvent | null>(null);
|
||||
const [isInstalled, setIsInstalled] = useState(false);
|
||||
const [isDismissed, setIsDismissed] = useState(
|
||||
() => !!localStorage.getItem(DISMISSED_KEY),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (window.matchMedia('(display-mode: standalone)').matches) {
|
||||
setIsInstalled(true);
|
||||
return;
|
||||
}
|
||||
useEffect(() => {
|
||||
if (window.matchMedia("(display-mode: standalone)").matches) {
|
||||
setIsInstalled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const handler = (e: Event) => {
|
||||
e.preventDefault();
|
||||
setPromptEvent(e as BeforeInstallPromptEvent);
|
||||
const handleBeforeInstallPrompt = (e: Event) => {
|
||||
e.preventDefault();
|
||||
setPromptEvent(e as BeforeInstallPromptEvent);
|
||||
};
|
||||
|
||||
const handleAppInstalled = () => {
|
||||
setIsInstalled(true);
|
||||
setPromptEvent(null);
|
||||
};
|
||||
|
||||
window.addEventListener(
|
||||
"beforeinstallprompt",
|
||||
handleBeforeInstallPrompt,
|
||||
);
|
||||
window.addEventListener("appinstalled", handleAppInstalled);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener(
|
||||
"beforeinstallprompt",
|
||||
handleBeforeInstallPrompt,
|
||||
);
|
||||
window.removeEventListener("appinstalled", handleAppInstalled);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const install = async (): Promise<boolean> => {
|
||||
if (!promptEvent) return false;
|
||||
|
||||
try {
|
||||
await promptEvent.prompt();
|
||||
const { outcome } = await promptEvent.userChoice;
|
||||
return outcome === "accepted";
|
||||
} finally {
|
||||
setPromptEvent(null);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('beforeinstallprompt', handler);
|
||||
return () => window.removeEventListener('beforeinstallprompt', handler);
|
||||
}, []);
|
||||
const dismiss = () => {
|
||||
localStorage.setItem(DISMISSED_KEY, "1");
|
||||
setIsDismissed(true);
|
||||
};
|
||||
|
||||
const install = async (): Promise<boolean> => {
|
||||
if (!promptEvent) return false;
|
||||
await promptEvent.prompt();
|
||||
const { outcome } = await promptEvent.userChoice;
|
||||
if (outcome === 'accepted') {
|
||||
setPromptEvent(null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const dismiss = () => {
|
||||
localStorage.setItem(DISMISSED_KEY, '1');
|
||||
setIsDismissed(true);
|
||||
};
|
||||
|
||||
return { promptEvent, isInstalled, isDismissed, install, dismiss };
|
||||
return { promptEvent, isInstalled, isDismissed, install, dismiss };
|
||||
}
|
||||
|
||||
+1293
-623
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@ const templateSchema = z.object({
|
||||
});
|
||||
type TemplateFormData = z.infer<typeof templateSchema>;
|
||||
|
||||
type Tab = 'samples' | 'pending' | 'logs' | 'post-visit-review' | 'messages';
|
||||
type Tab = 'samples' | 'pending' | 'logs' | 'post-visit-approved' | 'messages';
|
||||
|
||||
const STATUS_LOG_META: Record<string, { label: string; cls: string }> = {
|
||||
sent: { label: 'ارسال شده', cls: 'green' },
|
||||
@@ -167,10 +167,18 @@ export default function SmsPage() {
|
||||
onError: (err: Error) => toast.error(err.message),
|
||||
});
|
||||
|
||||
const postVisitReviewQuery = useQuery<ApiResponse<{ data: Array<{ id: number; entity_type: string; entity_id: number; post_visit_text_pending: string; post_visit_text_status: string }> }>>({
|
||||
type PostVisitItem = { id: number; entity_type: string; entity_id: number; entity_name?: string | null; post_visit_text_pending: string; post_visit_text: string | null; post_visit_text_status: string };
|
||||
|
||||
const postVisitReviewQuery = useQuery<ApiResponse<{ data: PostVisitItem[] }>>({
|
||||
queryKey: ['sms-post-visit-review'],
|
||||
queryFn: () => api.get('/api/v1/admin/sms/settings/review'),
|
||||
enabled: activeTab === 'post-visit-review',
|
||||
queryFn: () => api.get('/api/v1/admin/sms/settings/review?status=pending'),
|
||||
enabled: activeTab === 'pending',
|
||||
});
|
||||
|
||||
const postVisitApprovedQuery = useQuery<ApiResponse<{ data: PostVisitItem[] }>>({
|
||||
queryKey: ['sms-post-visit-approved'],
|
||||
queryFn: () => api.get('/api/v1/admin/sms/settings/review?status=approved'),
|
||||
enabled: activeTab === 'post-visit-approved',
|
||||
});
|
||||
|
||||
const postVisitApproveMutation = useMutation({
|
||||
@@ -178,6 +186,7 @@ export default function SmsPage() {
|
||||
onSuccess: () => {
|
||||
toast.success('متن پیامک تأیید شد');
|
||||
qc.invalidateQueries({ queryKey: ['sms-post-visit-review'] });
|
||||
qc.invalidateQueries({ queryKey: ['sms-post-visit-approved'] });
|
||||
},
|
||||
onError: (err: Error) => toast.error(err.message),
|
||||
});
|
||||
@@ -234,12 +243,14 @@ export default function SmsPage() {
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
const postVisitPendingCount = (postVisitReviewQuery.data?.data as any)?.data?.length ?? 0;
|
||||
const postVisitPending = (postVisitReviewQuery.data?.data as any)?.data ?? [];
|
||||
const postVisitApproved = (postVisitApprovedQuery.data?.data as any)?.data ?? [];
|
||||
const pendingBadge = pendingCount + postVisitPending.length;
|
||||
|
||||
const TABS: { key: Tab; label: string; badge?: number }[] = [
|
||||
{ key: 'samples', label: 'قالبهای نمونه' },
|
||||
{ key: 'pending', label: 'در انتظار تأیید', badge: pendingCount },
|
||||
{ key: 'post-visit-review', label: 'متن پیامک ویزیت', badge: postVisitPendingCount },
|
||||
{ key: 'pending', label: 'در انتظار تأیید', badge: pendingBadge },
|
||||
{ key: 'post-visit-approved', label: 'پیامکهای تأیید شده' },
|
||||
{ key: 'logs', label: 'لاگهای ارسال' },
|
||||
{ key: 'messages', label: 'متن پیامکها' },
|
||||
];
|
||||
@@ -330,11 +341,14 @@ export default function SmsPage() {
|
||||
|
||||
{activeTab === 'pending' && (
|
||||
<>
|
||||
{pendingCount > 0 && (
|
||||
<div style={{ fontSize: 12.5, fontWeight: 600, color: 'var(--text-2)', marginBottom: 8 }}>قالبهای نمونه</div>
|
||||
)}
|
||||
<DataTable<SmsTemplate>
|
||||
columns={pendingColumns}
|
||||
data={pendingTemplatesQuery.data?.data ?? []}
|
||||
loading={pendingTemplatesQuery.isLoading}
|
||||
emptyMessage="هیچ قالبی در انتظار تأیید نیست"
|
||||
emptyMessage="قالب نمونهای در انتظار تأیید نیست"
|
||||
actions={(t) => (
|
||||
<>
|
||||
<button onClick={() => setApproveTarget(t)} className="mini-btn" title="تأیید">
|
||||
@@ -352,24 +366,24 @@ export default function SmsPage() {
|
||||
limit={limit}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{activeTab === 'post-visit-review' && (
|
||||
<div style={{ padding: '16px' }}>
|
||||
<div style={{ fontSize: 12.5, fontWeight: 600, color: 'var(--text-2)', margin: '20px 0 8px' }}>متن پیامک ویزیت</div>
|
||||
{postVisitReviewQuery.isLoading ? (
|
||||
<div className="muted" style={{ fontSize: 13 }}>در حال بارگذاری...</div>
|
||||
) : ((postVisitReviewQuery.data?.data as any)?.data ?? []).length === 0 ? (
|
||||
<div style={{ textAlign: 'center', padding: '32px 16px', color: 'var(--text-3)', fontSize: 13 }}>
|
||||
متنی برای بررسی وجود ندارد
|
||||
) : postVisitPending.length === 0 ? (
|
||||
<div style={{ textAlign: 'center', padding: '24px 16px', color: 'var(--text-3)', fontSize: 13 }}>
|
||||
متن ویزیتی در انتظار تأیید نیست
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
{((postVisitReviewQuery.data?.data as any)?.data ?? []).map((item: any) => (
|
||||
{postVisitPending.map((item: PostVisitItem) => (
|
||||
<div key={item.id} className="card card-pad">
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 10 }}>
|
||||
<div>
|
||||
<span className="badge gray" style={{ fontSize: 11 }}>{item.entity_type} #{item.entity_id}</span>
|
||||
<span className="badge gray" style={{ fontSize: 11 }}>
|
||||
{item.entity_type === 'doctor' ? 'پزشک' : item.entity_type === 'clinic' ? 'کلینیک' : item.entity_type}
|
||||
{item.entity_name ? `: ${item.entity_name}` : ` #${item.entity_id}`}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
<button
|
||||
@@ -394,7 +408,36 @@ export default function SmsPage() {
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{activeTab === 'post-visit-approved' && (
|
||||
<>
|
||||
{postVisitApprovedQuery.isLoading ? (
|
||||
<div className="muted" style={{ fontSize: 13 }}>در حال بارگذاری...</div>
|
||||
) : postVisitApproved.length === 0 ? (
|
||||
<div style={{ textAlign: 'center', padding: '24px 16px', color: 'var(--text-3)', fontSize: 13 }}>
|
||||
متن تأییدشدهای وجود ندارد
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
{postVisitApproved.map((item: PostVisitItem) => (
|
||||
<div key={item.id} className="card card-pad">
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 10 }}>
|
||||
<span className="badge gray" style={{ fontSize: 11 }}>
|
||||
{item.entity_type === 'doctor' ? 'پزشک' : item.entity_type === 'clinic' ? 'کلینیک' : item.entity_type}
|
||||
{item.entity_name ? `: ${item.entity_name}` : ` #${item.entity_id}`}
|
||||
</span>
|
||||
<span className="badge green" style={{ fontSize: 11 }}><span className="bdot" />تأیید شده</span>
|
||||
</div>
|
||||
<div style={{ fontSize: 13, lineHeight: 1.8, padding: '10px 14px', background: 'var(--surface)', borderRadius: 8, border: '1px solid var(--border)', direction: 'rtl' }}>
|
||||
{item.post_visit_text}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{activeTab === 'logs' && (
|
||||
|
||||
@@ -25,6 +25,15 @@ type ChargeForm = z.infer<typeof chargeSchema>;
|
||||
|
||||
const EMPTY_LOGS: SmsWalletLog[] = [];
|
||||
|
||||
const REMINDER_HOUR_OPTIONS = [1, 2, 3, 4, 6, 12, 24, 48];
|
||||
|
||||
const POST_VISIT_VARS: { key: string; label: string }[] = [
|
||||
{ key: 'patient_name', label: 'نام بیمار' },
|
||||
{ key: 'doctor', label: 'نام پزشک' },
|
||||
{ key: 'clinic', label: 'نام کلینیک' },
|
||||
{ key: 'date', label: 'تاریخ ویزیت' },
|
||||
];
|
||||
|
||||
function SmsWalletPageInner() {
|
||||
const qc = useQueryClient();
|
||||
const [chargeOpen, setChargeOpen] = useState(false);
|
||||
@@ -211,14 +220,16 @@ function SmsWalletPageInner() {
|
||||
{currentSettings.reminder_enabled && (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }}>
|
||||
<label style={{ fontSize: 13, color: 'var(--text-2)', whiteSpace: 'nowrap' }}>ارسال</label>
|
||||
<input
|
||||
type="number" min={1} max={72}
|
||||
<select
|
||||
className="cp-select"
|
||||
value={currentSettings.reminder_hours_before}
|
||||
onChange={(e) => setLocalSettings({ ...currentSettings, reminder_hours_before: +e.target.value })}
|
||||
dir="ltr"
|
||||
style={{ width: 72, textAlign: 'center' }}
|
||||
/>
|
||||
<label style={{ fontSize: 13, color: 'var(--text-2)', whiteSpace: 'nowrap' }}>ساعت قبل</label>
|
||||
style={{ width: 130, height: 36 }}
|
||||
>
|
||||
{REMINDER_HOUR_OPTIONS.map((h) => (
|
||||
<option key={h} value={h}>{h} ساعت قبل</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -283,7 +294,33 @@ function SmsWalletPageInner() {
|
||||
direction: 'rtl',
|
||||
}}
|
||||
/>
|
||||
<div style={{ fontSize: 11.5, color: 'var(--text-3)', marginTop: 6 }}>
|
||||
<div style={{ marginTop: 10 }}>
|
||||
<div style={{ fontSize: 12, color: 'var(--text-3)', marginBottom: 6 }}>
|
||||
برای افزودن، روی پارامتر کلیک کنید:
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6 }}>
|
||||
{POST_VISIT_VARS.map(({ key, label }) => (
|
||||
<button
|
||||
key={key}
|
||||
type="button"
|
||||
onClick={() => setLocalSettings({
|
||||
...currentSettings,
|
||||
post_visit_text: `${currentSettings.post_visit_text_pending ?? currentSettings.post_visit_text ?? ''}{${key}}`,
|
||||
})}
|
||||
style={{
|
||||
fontSize: 12, fontWeight: 600,
|
||||
padding: '4px 10px', borderRadius: 16, cursor: 'pointer',
|
||||
background: 'var(--primary-subtle)', color: 'var(--primary)',
|
||||
border: '1px solid color-mix(in oklch, var(--primary) 30%, transparent)',
|
||||
}}
|
||||
>
|
||||
{label} <span style={{ direction: 'ltr', opacity: 0.7 }}>{`{${key}}`}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ fontSize: 11.5, color: 'var(--text-3)', marginTop: 8 }}>
|
||||
متن پس از تغییر باید توسط ادمین تأیید شود تا فعال گردد
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+342
-324
@@ -1,438 +1,456 @@
|
||||
export interface User {
|
||||
uuid: string;
|
||||
id: number;
|
||||
mobile_number: string;
|
||||
name?: string | null;
|
||||
first_name?: string | null;
|
||||
last_name?: string | null;
|
||||
email: string | null;
|
||||
roles: string[];
|
||||
is_active: boolean;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
uuid: string;
|
||||
id: number;
|
||||
mobile_number: string;
|
||||
name?: string | null;
|
||||
first_name?: string | null;
|
||||
last_name?: string | null;
|
||||
email: string | null;
|
||||
roles: string[];
|
||||
is_active: boolean;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface UserProfile {
|
||||
uuid: string;
|
||||
blood_group: string | null;
|
||||
weight: number | null;
|
||||
height: number | null;
|
||||
diseases: string | null;
|
||||
medications: string | null;
|
||||
allergies: string | null;
|
||||
insurance_type: string | null;
|
||||
uuid: string;
|
||||
blood_group: string | null;
|
||||
weight: number | null;
|
||||
height: number | null;
|
||||
diseases: string | null;
|
||||
medications: string | null;
|
||||
allergies: string | null;
|
||||
insurance_type: string | null;
|
||||
}
|
||||
|
||||
export interface Doctor {
|
||||
uuid: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
medical_code: string;
|
||||
gender: 'male' | 'female';
|
||||
degree: string;
|
||||
bio: string | null;
|
||||
profile_image: string | null;
|
||||
is_active: boolean;
|
||||
specialties: Specialty[];
|
||||
created_at: string;
|
||||
uuid: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
medical_code: string;
|
||||
gender: "male" | "female";
|
||||
degree: string;
|
||||
bio: string | null;
|
||||
profile_image: string | null;
|
||||
is_active: boolean;
|
||||
specialties: Specialty[];
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Clinic {
|
||||
uuid: string;
|
||||
name: string;
|
||||
phone: string | null;
|
||||
logo: string | null;
|
||||
is_active: boolean;
|
||||
doctors_count: number;
|
||||
created_at: number;
|
||||
owner_mobile: string | null;
|
||||
uuid: string;
|
||||
name: string;
|
||||
phone: string | null;
|
||||
logo: string | null;
|
||||
is_active: boolean;
|
||||
doctors_count: number;
|
||||
created_at: number;
|
||||
owner_mobile: string | null;
|
||||
}
|
||||
|
||||
export interface ClinicDetail {
|
||||
id: string;
|
||||
uuid: string;
|
||||
name: string | null;
|
||||
title: string | null;
|
||||
is_active: boolean;
|
||||
phone: string | null;
|
||||
phone_number: string | null;
|
||||
logo: string | null;
|
||||
clinic_logo: string | null;
|
||||
caption: string | null;
|
||||
images_clinic: { url: string; fid?: number }[];
|
||||
social_media: {
|
||||
instagram: string | null;
|
||||
telegram: string | null;
|
||||
aparat: string | null;
|
||||
youtube: string | null;
|
||||
linkedin: string | null;
|
||||
} | null;
|
||||
specialties: { id: string; uuid: string; name: string }[];
|
||||
services: { id: string; uuid: string; name: string }[];
|
||||
list_bime: { id: string; uuid: string; name: string }[];
|
||||
doctors: number;
|
||||
city: { id: string; name: string }[];
|
||||
state: { id: string; name: string }[];
|
||||
location: string | null;
|
||||
map: { latitude: string | null; longitude: string | null };
|
||||
'24_7': boolean;
|
||||
field_working_days: string | null;
|
||||
id: string;
|
||||
uuid: string;
|
||||
name: string | null;
|
||||
title: string | null;
|
||||
is_active: boolean;
|
||||
phone: string | null;
|
||||
phone_number: string | null;
|
||||
logo: string | null;
|
||||
clinic_logo: string | null;
|
||||
caption: string | null;
|
||||
images_clinic: { url: string; fid?: number }[];
|
||||
social_media: {
|
||||
instagram: string | null;
|
||||
telegram: string | null;
|
||||
aparat: string | null;
|
||||
youtube: string | null;
|
||||
linkedin: string | null;
|
||||
} | null;
|
||||
specialties: { id: string; uuid: string; name: string }[];
|
||||
services: { id: string; uuid: string; name: string }[];
|
||||
list_bime: { id: string; uuid: string; name: string }[];
|
||||
doctors: number;
|
||||
city: { id: string; name: string }[];
|
||||
state: { id: string; name: string }[];
|
||||
location: string | null;
|
||||
map: { latitude: string | null; longitude: string | null };
|
||||
"24_7": boolean;
|
||||
field_working_days: string | null;
|
||||
}
|
||||
|
||||
export type AppointmentStatus =
|
||||
| 'pending'
|
||||
| 'confirmed'
|
||||
| 'completed'
|
||||
| 'cancelled_by_doctor'
|
||||
| 'cancelled_by_user'
|
||||
| 'no_show'
|
||||
| 'expired';
|
||||
| "pending"
|
||||
| "confirmed"
|
||||
| "completed"
|
||||
| "cancelled_by_doctor"
|
||||
| "cancelled_by_user"
|
||||
| "no_show"
|
||||
| "expired";
|
||||
|
||||
export interface Appointment {
|
||||
uuid: string;
|
||||
patient_name: string;
|
||||
patient_mobile: string;
|
||||
doctor_uuid: string;
|
||||
doctor_name: string;
|
||||
slot_start: number;
|
||||
slot_end: number;
|
||||
appointment_date: string;
|
||||
appointment_time: string;
|
||||
end_time: string;
|
||||
status: AppointmentStatus;
|
||||
version: number;
|
||||
created_at: string;
|
||||
uuid: string;
|
||||
patient_name: string;
|
||||
patient_mobile: string;
|
||||
doctor_uuid: string;
|
||||
doctor_name: string;
|
||||
slot_start: number;
|
||||
slot_end: number;
|
||||
appointment_date: string;
|
||||
appointment_time: string;
|
||||
end_time: string;
|
||||
status: AppointmentStatus;
|
||||
version: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export type PaymentStatus = 'pending' | 'success' | 'failed' | 'canceled' | 'refunded';
|
||||
export type PaymentGateway = 'mellat' | 'sep';
|
||||
export type PaymentStatus =
|
||||
| "pending"
|
||||
| "success"
|
||||
| "failed"
|
||||
| "canceled"
|
||||
| "refunded";
|
||||
export type PaymentGateway = "mellat" | "sep";
|
||||
|
||||
export interface Payment {
|
||||
uuid: string;
|
||||
amount: number;
|
||||
status: PaymentStatus;
|
||||
gateway: PaymentGateway;
|
||||
ref_id: string | null;
|
||||
patient_mobile: string;
|
||||
appointment_uuid: string | null;
|
||||
paid_at: string | null;
|
||||
created_at: string;
|
||||
uuid: string;
|
||||
amount: number;
|
||||
status: PaymentStatus;
|
||||
gateway: PaymentGateway;
|
||||
ref_id: string | null;
|
||||
patient_mobile: string;
|
||||
appointment_uuid: string | null;
|
||||
paid_at: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export type SettlementStatus = 'pending' | 'approved' | 'rejected';
|
||||
export type SettlementStatus = "pending" | "approved" | "rejected";
|
||||
|
||||
export interface Settlement {
|
||||
uuid: string;
|
||||
representation_name: string;
|
||||
amount: number;
|
||||
status: SettlementStatus;
|
||||
bank_card: string | null;
|
||||
bank_name: string | null;
|
||||
reject_reason: string | null;
|
||||
requested_at: string;
|
||||
processed_at: string | null;
|
||||
uuid: string;
|
||||
representation_name: string;
|
||||
amount: number;
|
||||
status: SettlementStatus;
|
||||
bank_card: string | null;
|
||||
bank_name: string | null;
|
||||
reject_reason: string | null;
|
||||
requested_at: string;
|
||||
processed_at: string | null;
|
||||
}
|
||||
|
||||
export interface Representation {
|
||||
id: number;
|
||||
uuid: string;
|
||||
full_name: string;
|
||||
domain?: string;
|
||||
mobile_number: string | null;
|
||||
city_id: number | null;
|
||||
city: string | null;
|
||||
commission_percent: number;
|
||||
bank_account: { card?: string; bank_name?: string; iban?: string } | null;
|
||||
wallet_balance?: number;
|
||||
active?: boolean;
|
||||
is_active?: boolean;
|
||||
created_at: string;
|
||||
id: number;
|
||||
uuid: string;
|
||||
full_name: string;
|
||||
domain?: string;
|
||||
mobile_number: string | null;
|
||||
city_id: number | null;
|
||||
city: string | null;
|
||||
commission_percent: number;
|
||||
bank_account: { card?: string; bank_name?: string; iban?: string } | null;
|
||||
wallet_balance?: number;
|
||||
active?: boolean;
|
||||
is_active?: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Comment {
|
||||
uuid: string;
|
||||
patient_name: string;
|
||||
doctor_name: string;
|
||||
title: string;
|
||||
body: string;
|
||||
is_approved: boolean;
|
||||
created_at: string;
|
||||
uuid: string;
|
||||
patient_name: string;
|
||||
doctor_name: string;
|
||||
title: string;
|
||||
body: string;
|
||||
is_approved: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Rating {
|
||||
uuid: string;
|
||||
patient_name: string;
|
||||
doctor_name: string;
|
||||
diagnosis_accuracy: number;
|
||||
skill: number;
|
||||
behavior: number;
|
||||
cleanliness: number;
|
||||
waiting_time: number;
|
||||
overall: number;
|
||||
created_at: string;
|
||||
uuid: string;
|
||||
patient_name: string;
|
||||
doctor_name: string;
|
||||
diagnosis_accuracy: number;
|
||||
skill: number;
|
||||
behavior: number;
|
||||
cleanliness: number;
|
||||
waiting_time: number;
|
||||
overall: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export type SmsTemplateStatus = 'draft' | 'pending' | 'approved' | 'rejected';
|
||||
export type SmsTemplateStatus = "draft" | "pending" | "approved" | "rejected";
|
||||
|
||||
export interface SmsTemplate {
|
||||
uuid: string;
|
||||
name: string;
|
||||
body: string;
|
||||
provider_code: string | null;
|
||||
status: SmsTemplateStatus;
|
||||
admin_note: string | null;
|
||||
created_at: string;
|
||||
uuid: string;
|
||||
name: string;
|
||||
body: string;
|
||||
provider_code: string | null;
|
||||
status: SmsTemplateStatus;
|
||||
admin_note: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface SmsLog {
|
||||
uuid: string;
|
||||
recipient: string;
|
||||
message: string;
|
||||
status: 'queued' | 'sent' | 'failed';
|
||||
provider: string;
|
||||
tag: string;
|
||||
sent_at: string | null;
|
||||
created_at: string;
|
||||
uuid: string;
|
||||
recipient: string;
|
||||
message: string;
|
||||
status: "queued" | "sent" | "failed";
|
||||
provider: string;
|
||||
tag: string;
|
||||
sent_at: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface SmsMessageText {
|
||||
tag: string;
|
||||
title: string;
|
||||
body: string;
|
||||
variables: string[];
|
||||
updated_at: number | null;
|
||||
tag: string;
|
||||
title: string;
|
||||
body: string;
|
||||
variables: string[];
|
||||
updated_at: number | null;
|
||||
}
|
||||
|
||||
export interface Province {
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
status: number;
|
||||
weight: number;
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
status: number;
|
||||
weight: number;
|
||||
}
|
||||
|
||||
export interface City {
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
status: number;
|
||||
weight: number;
|
||||
province_id: number | null;
|
||||
representation_id?: number | null;
|
||||
contact_phone?: string | null;
|
||||
email?: string | null;
|
||||
description?: string | null;
|
||||
slogan?: string | null;
|
||||
domain?: string | null;
|
||||
keywords?: string | null;
|
||||
footer_description?: string | null;
|
||||
social_media?: Record<string, string> | null;
|
||||
logo_url?: string | null;
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
status: number;
|
||||
weight: number;
|
||||
province_id: number | null;
|
||||
representation_id?: number | null;
|
||||
contact_phone?: string | null;
|
||||
email?: string | null;
|
||||
description?: string | null;
|
||||
slogan?: string | null;
|
||||
domain?: string | null;
|
||||
keywords?: string | null;
|
||||
footer_description?: string | null;
|
||||
social_media?: Record<string, string> | null;
|
||||
logo_url?: string | null;
|
||||
}
|
||||
|
||||
export interface SpecialtyFull {
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
status: number;
|
||||
weight: number;
|
||||
parent_id: number | null;
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
status: number;
|
||||
weight: number;
|
||||
parent_id: number | null;
|
||||
}
|
||||
|
||||
export interface DoctorService {
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
status: number;
|
||||
weight: number;
|
||||
specialty_id: number | null;
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
status: number;
|
||||
weight: number;
|
||||
specialty_id: number | null;
|
||||
}
|
||||
|
||||
export interface Insurance {
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: 'basic' | 'supplementary';
|
||||
logo_url: string | null;
|
||||
status: number;
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: "basic" | "supplementary";
|
||||
logo_url: string | null;
|
||||
status: number;
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
status: number;
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
status: number;
|
||||
}
|
||||
|
||||
export interface Blog {
|
||||
uuid: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
summary: string | null;
|
||||
body: string;
|
||||
image_url: string | null;
|
||||
status: 'draft' | 'published';
|
||||
author?: { uuid: string; name: string } | null;
|
||||
tags: string[];
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
uuid: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
summary: string | null;
|
||||
body: string;
|
||||
image_url: string | null;
|
||||
status: "draft" | "published";
|
||||
author?: { uuid: string; name: string } | null;
|
||||
tags: string[];
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface Secretary {
|
||||
uuid: string;
|
||||
user_name: string;
|
||||
mobile_number: string;
|
||||
doctor_name: string;
|
||||
doctor_uuid: string;
|
||||
is_active: boolean;
|
||||
permissions: SecretaryPermissions;
|
||||
created_at: string;
|
||||
uuid: string;
|
||||
user_name: string;
|
||||
mobile_number: string;
|
||||
doctor_name: string;
|
||||
doctor_uuid: string;
|
||||
is_active: boolean;
|
||||
permissions: SecretaryPermissions;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface SecretaryPermissions {
|
||||
appointments: {
|
||||
view: boolean;
|
||||
create: boolean;
|
||||
cancel: boolean;
|
||||
update_status: boolean;
|
||||
};
|
||||
addresses: {
|
||||
view: boolean;
|
||||
create: boolean;
|
||||
update: boolean;
|
||||
delete: boolean;
|
||||
};
|
||||
clinic_info: {
|
||||
view: boolean;
|
||||
update: boolean;
|
||||
};
|
||||
insurances: {
|
||||
view: boolean;
|
||||
create: boolean;
|
||||
update: boolean;
|
||||
delete: boolean;
|
||||
};
|
||||
appointments: {
|
||||
view: boolean;
|
||||
create: boolean;
|
||||
cancel: boolean;
|
||||
update_status: boolean;
|
||||
};
|
||||
addresses: {
|
||||
view: boolean;
|
||||
create: boolean;
|
||||
update: boolean;
|
||||
delete: boolean;
|
||||
};
|
||||
clinic_info: {
|
||||
view: boolean;
|
||||
update: boolean;
|
||||
};
|
||||
insurances: {
|
||||
view: boolean;
|
||||
create: boolean;
|
||||
update: boolean;
|
||||
delete: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface Specialty {
|
||||
id?: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
slug?: string;
|
||||
id?: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
slug?: string;
|
||||
}
|
||||
|
||||
export interface ClinicStaff {
|
||||
uuid: string;
|
||||
full_name: string;
|
||||
phone: string | null;
|
||||
job_title: string | null;
|
||||
address: string | null;
|
||||
national_code: string | null;
|
||||
active: boolean;
|
||||
created_at: number;
|
||||
uuid: string;
|
||||
full_name: string;
|
||||
phone: string | null;
|
||||
job_title: string | null;
|
||||
address: string | null;
|
||||
national_code: string | null;
|
||||
active: boolean;
|
||||
created_at: number;
|
||||
}
|
||||
|
||||
export interface SubscriptionPlan {
|
||||
uuid: string;
|
||||
name: string;
|
||||
level: number;
|
||||
max_secretaries: number;
|
||||
features: Record<string, boolean>;
|
||||
periods: SubscriptionPeriod[];
|
||||
uuid: string;
|
||||
name: string;
|
||||
level: number;
|
||||
max_secretaries: number;
|
||||
features: Record<string, boolean>;
|
||||
periods: SubscriptionPeriod[];
|
||||
}
|
||||
|
||||
export interface SubscriptionPeriod {
|
||||
uuid: string;
|
||||
label: string;
|
||||
duration_months: number;
|
||||
price_rials: number;
|
||||
is_trial: boolean;
|
||||
uuid: string;
|
||||
label: string;
|
||||
duration_months: number;
|
||||
price_rials: number;
|
||||
is_trial: boolean;
|
||||
}
|
||||
|
||||
export interface MySubscriptionData {
|
||||
subscription: {
|
||||
plan: { name: string; level: number; max_secretaries: number; features: Record<string, boolean> };
|
||||
subscription: {
|
||||
plan: {
|
||||
name: string;
|
||||
level: number;
|
||||
max_secretaries: number;
|
||||
features: Record<string, boolean>;
|
||||
};
|
||||
period?: { label: string; duration_months: number };
|
||||
is_trial: boolean;
|
||||
starts_at?: number;
|
||||
expires_at?: number | null;
|
||||
days_remaining?: number;
|
||||
} | null;
|
||||
used_trial: boolean;
|
||||
}
|
||||
/** @deprecated use MySubscriptionData */
|
||||
export interface MySubscription {
|
||||
plan: { name: string; level: number; features: Record<string, boolean> };
|
||||
period?: { label: string; duration_months: number };
|
||||
is_trial: boolean;
|
||||
starts_at?: number;
|
||||
expires_at?: number | null;
|
||||
used_trial: boolean;
|
||||
days_remaining?: number;
|
||||
} | null;
|
||||
used_trial: boolean;
|
||||
}
|
||||
/** @deprecated use MySubscriptionData */
|
||||
export interface MySubscription {
|
||||
plan: { name: string; level: number; features: Record<string, boolean> };
|
||||
period?: { label: string; duration_months: number };
|
||||
is_trial: boolean;
|
||||
starts_at?: number;
|
||||
expires_at?: number | null;
|
||||
used_trial: boolean;
|
||||
days_remaining?: number;
|
||||
}
|
||||
|
||||
export interface ServiceSection {
|
||||
uuid: string;
|
||||
name: string;
|
||||
active: boolean;
|
||||
uuid: string;
|
||||
name: string;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
export interface ServiceItem {
|
||||
uuid: string;
|
||||
name: string;
|
||||
price_rials: number;
|
||||
staff: { uuid: string; full_name: string } | null;
|
||||
active: boolean;
|
||||
uuid: string;
|
||||
name: string;
|
||||
price_rials: number;
|
||||
staff: { uuid: string; full_name: string } | null;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
export interface SmsWalletBalance {
|
||||
balance_rials: number;
|
||||
sms_price_rials: number;
|
||||
estimated_sms_count: number;
|
||||
balance_rials: number;
|
||||
sms_price_rials: number;
|
||||
estimated_sms_count: number;
|
||||
}
|
||||
|
||||
export interface SmsWalletLog {
|
||||
uuid: string;
|
||||
type: 'credit' | 'debit';
|
||||
amount_rials: number;
|
||||
description: string;
|
||||
created_at: number;
|
||||
uuid: string;
|
||||
type: "credit" | "debit";
|
||||
amount_rials: number;
|
||||
description: string;
|
||||
created_at: number;
|
||||
}
|
||||
|
||||
export interface SmsSettings {
|
||||
reminder_enabled: boolean;
|
||||
reminder_hours_before: number;
|
||||
post_visit_enabled: boolean;
|
||||
post_visit_text: string | null;
|
||||
post_visit_text_pending?: string | null;
|
||||
post_visit_text_status?: 'none' | 'pending' | 'approved' | 'rejected';
|
||||
post_visit_text_reject_reason?: string | null;
|
||||
reminder_enabled: boolean;
|
||||
reminder_hours_before: number;
|
||||
post_visit_enabled: boolean;
|
||||
post_visit_text: string | null;
|
||||
post_visit_text_pending?: string | null;
|
||||
post_visit_text_status?: "none" | "pending" | "approved" | "rejected";
|
||||
post_visit_text_reject_reason?: string | null;
|
||||
}
|
||||
|
||||
export interface PatientRecord {
|
||||
uuid: string;
|
||||
entity_type: string;
|
||||
entity_id: number;
|
||||
user: { uuid: string; fullName: string; phone: string };
|
||||
created_at: number;
|
||||
uuid: string;
|
||||
entity_type: string;
|
||||
entity_id: number;
|
||||
user?: {
|
||||
uuid?: string;
|
||||
fullName?: string;
|
||||
name?: string;
|
||||
phone?: string;
|
||||
} | null;
|
||||
user_uuid?: string;
|
||||
user_name?: string | null;
|
||||
user_mobile?: string | null;
|
||||
created_at: number;
|
||||
}
|
||||
|
||||
export interface PatientSession {
|
||||
uuid: string;
|
||||
record_uuid: string;
|
||||
appointment_uuid: string | null;
|
||||
insurance_base_id: number | null;
|
||||
insurance_supplementary_id: number | null;
|
||||
visit_price_rials: number;
|
||||
base_insurance_discount_percent: string;
|
||||
supplementary_discount_percent: string;
|
||||
services_total_rials: number;
|
||||
final_price_rials: number;
|
||||
payment_method: string;
|
||||
notes: string | null;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
uuid: string;
|
||||
record_uuid: string;
|
||||
appointment_uuid: string | null;
|
||||
insurance_base_id: number | null;
|
||||
insurance_supplementary_id: number | null;
|
||||
visit_price_rials: number;
|
||||
base_insurance_discount_percent: string;
|
||||
supplementary_discount_percent: string;
|
||||
services_total_rials: number;
|
||||
final_price_rials: number;
|
||||
payment_method: string;
|
||||
notes: string | null;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
+10
-1
@@ -421,7 +421,15 @@ Updated template with `status: "rejected"`.
|
||||
|
||||
### GET /api/v1/admin/sms/settings/review
|
||||
|
||||
**Permission:** `ROLE_ADMIN` — لیست همه تنظیمات SMS با وضعیت `pending`
|
||||
**Permission:** `ROLE_ADMIN` — لیست تنظیمات SMS بر اساس وضعیت متن ویزیت.
|
||||
|
||||
**Query params:**
|
||||
|
||||
| پارامتر | مقدار | پیشفرض | توضیح |
|
||||
|---|---|---|---|
|
||||
| `status` | `pending` \| `approved` | `pending` | فیلتر بر اساس `post_visit_text_status`. مقدار نامعتبر → `pending`. |
|
||||
|
||||
برای تب «در انتظار تأیید» با `status=pending` و برای تب «پیامکهای تأییدشده» با `status=approved` فراخوانی میشود.
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -432,6 +440,7 @@ Updated template with `status: "rejected"`.
|
||||
"id": 3,
|
||||
"entity_type": "doctor",
|
||||
"entity_id": 7,
|
||||
"entity_name": "دکتر محمد محمدی",
|
||||
"post_visit_text_pending": "متن در انتظار تأیید",
|
||||
"post_visit_text_status": "pending",
|
||||
...
|
||||
|
||||
@@ -194,15 +194,26 @@ class SmsWalletController extends BaseController
|
||||
|
||||
#[Route('/api/v1/admin/sms/settings/review', methods: ['GET'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function adminReviewList(): JsonResponse
|
||||
public function adminReviewList(Request $request): JsonResponse
|
||||
{
|
||||
$status = $request->query->get('status', SmsSettings::TEXT_STATUS_PENDING);
|
||||
if (!in_array($status, [SmsSettings::TEXT_STATUS_PENDING, SmsSettings::TEXT_STATUS_APPROVED], true)) {
|
||||
$status = SmsSettings::TEXT_STATUS_PENDING;
|
||||
}
|
||||
|
||||
$pending = $this->settingsRepo->createQueryBuilder('s')
|
||||
->where('s.postVisitTextStatus = :status')
|
||||
->setParameter('status', SmsSettings::TEXT_STATUS_PENDING)
|
||||
->setParameter('status', $status)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
return $this->success(['data' => array_map(fn(SmsSettings $s) => $s->toArray(), $pending)]);
|
||||
$data = array_map(function (SmsSettings $s) {
|
||||
$row = $s->toArray();
|
||||
$row['entity_name'] = $this->resolveEntityName($s->getEntityType(), $s->getEntityId());
|
||||
return $row;
|
||||
}, $pending);
|
||||
|
||||
return $this->success(['data' => $data]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/admin/sms/settings/{id}/approve', methods: ['POST'])]
|
||||
@@ -241,6 +252,17 @@ class SmsWalletController extends BaseController
|
||||
return $this->success($settings->toArray());
|
||||
}
|
||||
|
||||
private function resolveEntityName(string $type, int $id): ?string
|
||||
{
|
||||
if ($type === 'doctor') {
|
||||
return $this->doctorRepo->find($id)?->getName();
|
||||
}
|
||||
if ($type === 'clinic') {
|
||||
return $this->clinicRepo->find($id)?->getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
#[Route('/api/v1/admin/sms/wallet-report', methods: ['GET'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function adminReport(Request $request): JsonResponse
|
||||
|
||||
@@ -105,6 +105,7 @@ class SmsSettings
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'entity_type' => $this->entityType,
|
||||
'entity_id' => $this->entityId,
|
||||
'reminder_enabled' => $this->reminderEnabled,
|
||||
|
||||
Reference in New Issue
Block a user