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 {
|
export interface BeforeInstallPromptEvent extends Event {
|
||||||
prompt(): Promise<void>;
|
prompt(): Promise<void>;
|
||||||
userChoice: Promise<{ outcome: 'accepted' | 'dismissed' }>;
|
userChoice: Promise<{ outcome: "accepted" | "dismissed" }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DISMISSED_KEY = 'pwa-dismissed';
|
const DISMISSED_KEY = "pwa-dismissed";
|
||||||
|
|
||||||
export function usePwaInstall() {
|
export function usePwaInstall() {
|
||||||
const [promptEvent, setPromptEvent] = useState<BeforeInstallPromptEvent | null>(null);
|
const [promptEvent, setPromptEvent] =
|
||||||
const [isInstalled, setIsInstalled] = useState(false);
|
useState<BeforeInstallPromptEvent | null>(null);
|
||||||
const [isDismissed, setIsDismissed] = useState(() => !!localStorage.getItem(DISMISSED_KEY));
|
const [isInstalled, setIsInstalled] = useState(false);
|
||||||
|
const [isDismissed, setIsDismissed] = useState(
|
||||||
|
() => !!localStorage.getItem(DISMISSED_KEY),
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (window.matchMedia('(display-mode: standalone)').matches) {
|
if (window.matchMedia("(display-mode: standalone)").matches) {
|
||||||
setIsInstalled(true);
|
setIsInstalled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handler = (e: Event) => {
|
const handleBeforeInstallPrompt = (e: Event) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setPromptEvent(e as BeforeInstallPromptEvent);
|
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);
|
const dismiss = () => {
|
||||||
return () => window.removeEventListener('beforeinstallprompt', handler);
|
localStorage.setItem(DISMISSED_KEY, "1");
|
||||||
}, []);
|
setIsDismissed(true);
|
||||||
|
};
|
||||||
|
|
||||||
const install = async (): Promise<boolean> => {
|
return { promptEvent, isInstalled, isDismissed, install, dismiss };
|
||||||
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 };
|
|
||||||
}
|
}
|
||||||
|
|||||||
+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 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 }> = {
|
const STATUS_LOG_META: Record<string, { label: string; cls: string }> = {
|
||||||
sent: { label: 'ارسال شده', cls: 'green' },
|
sent: { label: 'ارسال شده', cls: 'green' },
|
||||||
@@ -167,10 +167,18 @@ export default function SmsPage() {
|
|||||||
onError: (err: Error) => toast.error(err.message),
|
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'],
|
queryKey: ['sms-post-visit-review'],
|
||||||
queryFn: () => api.get('/api/v1/admin/sms/settings/review'),
|
queryFn: () => api.get('/api/v1/admin/sms/settings/review?status=pending'),
|
||||||
enabled: activeTab === 'post-visit-review',
|
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({
|
const postVisitApproveMutation = useMutation({
|
||||||
@@ -178,6 +186,7 @@ export default function SmsPage() {
|
|||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success('متن پیامک تأیید شد');
|
toast.success('متن پیامک تأیید شد');
|
||||||
qc.invalidateQueries({ queryKey: ['sms-post-visit-review'] });
|
qc.invalidateQueries({ queryKey: ['sms-post-visit-review'] });
|
||||||
|
qc.invalidateQueries({ queryKey: ['sms-post-visit-approved'] });
|
||||||
},
|
},
|
||||||
onError: (err: Error) => toast.error(err.message),
|
onError: (err: Error) => toast.error(err.message),
|
||||||
});
|
});
|
||||||
@@ -234,12 +243,14 @@ export default function SmsPage() {
|
|||||||
setPage(1);
|
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 }[] = [
|
const TABS: { key: Tab; label: string; badge?: number }[] = [
|
||||||
{ key: 'samples', label: 'قالبهای نمونه' },
|
{ key: 'samples', label: 'قالبهای نمونه' },
|
||||||
{ key: 'pending', label: 'در انتظار تأیید', badge: pendingCount },
|
{ key: 'pending', label: 'در انتظار تأیید', badge: pendingBadge },
|
||||||
{ key: 'post-visit-review', label: 'متن پیامک ویزیت', badge: postVisitPendingCount },
|
{ key: 'post-visit-approved', label: 'پیامکهای تأیید شده' },
|
||||||
{ key: 'logs', label: 'لاگهای ارسال' },
|
{ key: 'logs', label: 'لاگهای ارسال' },
|
||||||
{ key: 'messages', label: 'متن پیامکها' },
|
{ key: 'messages', label: 'متن پیامکها' },
|
||||||
];
|
];
|
||||||
@@ -330,11 +341,14 @@ export default function SmsPage() {
|
|||||||
|
|
||||||
{activeTab === 'pending' && (
|
{activeTab === 'pending' && (
|
||||||
<>
|
<>
|
||||||
|
{pendingCount > 0 && (
|
||||||
|
<div style={{ fontSize: 12.5, fontWeight: 600, color: 'var(--text-2)', marginBottom: 8 }}>قالبهای نمونه</div>
|
||||||
|
)}
|
||||||
<DataTable<SmsTemplate>
|
<DataTable<SmsTemplate>
|
||||||
columns={pendingColumns}
|
columns={pendingColumns}
|
||||||
data={pendingTemplatesQuery.data?.data ?? []}
|
data={pendingTemplatesQuery.data?.data ?? []}
|
||||||
loading={pendingTemplatesQuery.isLoading}
|
loading={pendingTemplatesQuery.isLoading}
|
||||||
emptyMessage="هیچ قالبی در انتظار تأیید نیست"
|
emptyMessage="قالب نمونهای در انتظار تأیید نیست"
|
||||||
actions={(t) => (
|
actions={(t) => (
|
||||||
<>
|
<>
|
||||||
<button onClick={() => setApproveTarget(t)} className="mini-btn" title="تأیید">
|
<button onClick={() => setApproveTarget(t)} className="mini-btn" title="تأیید">
|
||||||
@@ -352,24 +366,24 @@ export default function SmsPage() {
|
|||||||
limit={limit}
|
limit={limit}
|
||||||
onPageChange={setPage}
|
onPageChange={setPage}
|
||||||
/>
|
/>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{activeTab === 'post-visit-review' && (
|
<div style={{ fontSize: 12.5, fontWeight: 600, color: 'var(--text-2)', margin: '20px 0 8px' }}>متن پیامک ویزیت</div>
|
||||||
<div style={{ padding: '16px' }}>
|
|
||||||
{postVisitReviewQuery.isLoading ? (
|
{postVisitReviewQuery.isLoading ? (
|
||||||
<div className="muted" style={{ fontSize: 13 }}>در حال بارگذاری...</div>
|
<div className="muted" style={{ fontSize: 13 }}>در حال بارگذاری...</div>
|
||||||
) : ((postVisitReviewQuery.data?.data as any)?.data ?? []).length === 0 ? (
|
) : postVisitPending.length === 0 ? (
|
||||||
<div style={{ textAlign: 'center', padding: '32px 16px', color: 'var(--text-3)', fontSize: 13 }}>
|
<div style={{ textAlign: 'center', padding: '24px 16px', color: 'var(--text-3)', fontSize: 13 }}>
|
||||||
متنی برای بررسی وجود ندارد
|
متن ویزیتی در انتظار تأیید نیست
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
<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 key={item.id} className="card card-pad">
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 10 }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 10 }}>
|
||||||
<div>
|
<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>
|
||||||
<div style={{ display: 'flex', gap: 8 }}>
|
<div style={{ display: 'flex', gap: 8 }}>
|
||||||
<button
|
<button
|
||||||
@@ -394,7 +408,36 @@ export default function SmsPage() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</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' && (
|
{activeTab === 'logs' && (
|
||||||
|
|||||||
@@ -25,6 +25,15 @@ type ChargeForm = z.infer<typeof chargeSchema>;
|
|||||||
|
|
||||||
const EMPTY_LOGS: SmsWalletLog[] = [];
|
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() {
|
function SmsWalletPageInner() {
|
||||||
const qc = useQueryClient();
|
const qc = useQueryClient();
|
||||||
const [chargeOpen, setChargeOpen] = useState(false);
|
const [chargeOpen, setChargeOpen] = useState(false);
|
||||||
@@ -211,14 +220,16 @@ function SmsWalletPageInner() {
|
|||||||
{currentSettings.reminder_enabled && (
|
{currentSettings.reminder_enabled && (
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }}>
|
||||||
<label style={{ fontSize: 13, color: 'var(--text-2)', whiteSpace: 'nowrap' }}>ارسال</label>
|
<label style={{ fontSize: 13, color: 'var(--text-2)', whiteSpace: 'nowrap' }}>ارسال</label>
|
||||||
<input
|
<select
|
||||||
type="number" min={1} max={72}
|
className="cp-select"
|
||||||
value={currentSettings.reminder_hours_before}
|
value={currentSettings.reminder_hours_before}
|
||||||
onChange={(e) => setLocalSettings({ ...currentSettings, reminder_hours_before: +e.target.value })}
|
onChange={(e) => setLocalSettings({ ...currentSettings, reminder_hours_before: +e.target.value })}
|
||||||
dir="ltr"
|
style={{ width: 130, height: 36 }}
|
||||||
style={{ width: 72, textAlign: 'center' }}
|
>
|
||||||
/>
|
{REMINDER_HOUR_OPTIONS.map((h) => (
|
||||||
<label style={{ fontSize: 13, color: 'var(--text-2)', whiteSpace: 'nowrap' }}>ساعت قبل</label>
|
<option key={h} value={h}>{h} ساعت قبل</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -283,7 +294,33 @@ function SmsWalletPageInner() {
|
|||||||
direction: 'rtl',
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+342
-324
@@ -1,438 +1,456 @@
|
|||||||
export interface User {
|
export interface User {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
id: number;
|
id: number;
|
||||||
mobile_number: string;
|
mobile_number: string;
|
||||||
name?: string | null;
|
name?: string | null;
|
||||||
first_name?: string | null;
|
first_name?: string | null;
|
||||||
last_name?: string | null;
|
last_name?: string | null;
|
||||||
email: string | null;
|
email: string | null;
|
||||||
roles: string[];
|
roles: string[];
|
||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at?: string;
|
updated_at?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserProfile {
|
export interface UserProfile {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
blood_group: string | null;
|
blood_group: string | null;
|
||||||
weight: number | null;
|
weight: number | null;
|
||||||
height: number | null;
|
height: number | null;
|
||||||
diseases: string | null;
|
diseases: string | null;
|
||||||
medications: string | null;
|
medications: string | null;
|
||||||
allergies: string | null;
|
allergies: string | null;
|
||||||
insurance_type: string | null;
|
insurance_type: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Doctor {
|
export interface Doctor {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
first_name: string;
|
first_name: string;
|
||||||
last_name: string;
|
last_name: string;
|
||||||
medical_code: string;
|
medical_code: string;
|
||||||
gender: 'male' | 'female';
|
gender: "male" | "female";
|
||||||
degree: string;
|
degree: string;
|
||||||
bio: string | null;
|
bio: string | null;
|
||||||
profile_image: string | null;
|
profile_image: string | null;
|
||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
specialties: Specialty[];
|
specialties: Specialty[];
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Clinic {
|
export interface Clinic {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
phone: string | null;
|
phone: string | null;
|
||||||
logo: string | null;
|
logo: string | null;
|
||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
doctors_count: number;
|
doctors_count: number;
|
||||||
created_at: number;
|
created_at: number;
|
||||||
owner_mobile: string | null;
|
owner_mobile: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ClinicDetail {
|
export interface ClinicDetail {
|
||||||
id: string;
|
id: string;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
title: string | null;
|
title: string | null;
|
||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
phone: string | null;
|
phone: string | null;
|
||||||
phone_number: string | null;
|
phone_number: string | null;
|
||||||
logo: string | null;
|
logo: string | null;
|
||||||
clinic_logo: string | null;
|
clinic_logo: string | null;
|
||||||
caption: string | null;
|
caption: string | null;
|
||||||
images_clinic: { url: string; fid?: number }[];
|
images_clinic: { url: string; fid?: number }[];
|
||||||
social_media: {
|
social_media: {
|
||||||
instagram: string | null;
|
instagram: string | null;
|
||||||
telegram: string | null;
|
telegram: string | null;
|
||||||
aparat: string | null;
|
aparat: string | null;
|
||||||
youtube: string | null;
|
youtube: string | null;
|
||||||
linkedin: string | null;
|
linkedin: string | null;
|
||||||
} | null;
|
} | null;
|
||||||
specialties: { id: string; uuid: string; name: string }[];
|
specialties: { id: string; uuid: string; name: string }[];
|
||||||
services: { id: string; uuid: string; name: string }[];
|
services: { id: string; uuid: string; name: string }[];
|
||||||
list_bime: { id: string; uuid: string; name: string }[];
|
list_bime: { id: string; uuid: string; name: string }[];
|
||||||
doctors: number;
|
doctors: number;
|
||||||
city: { id: string; name: string }[];
|
city: { id: string; name: string }[];
|
||||||
state: { id: string; name: string }[];
|
state: { id: string; name: string }[];
|
||||||
location: string | null;
|
location: string | null;
|
||||||
map: { latitude: string | null; longitude: string | null };
|
map: { latitude: string | null; longitude: string | null };
|
||||||
'24_7': boolean;
|
"24_7": boolean;
|
||||||
field_working_days: string | null;
|
field_working_days: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AppointmentStatus =
|
export type AppointmentStatus =
|
||||||
| 'pending'
|
| "pending"
|
||||||
| 'confirmed'
|
| "confirmed"
|
||||||
| 'completed'
|
| "completed"
|
||||||
| 'cancelled_by_doctor'
|
| "cancelled_by_doctor"
|
||||||
| 'cancelled_by_user'
|
| "cancelled_by_user"
|
||||||
| 'no_show'
|
| "no_show"
|
||||||
| 'expired';
|
| "expired";
|
||||||
|
|
||||||
export interface Appointment {
|
export interface Appointment {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
patient_name: string;
|
patient_name: string;
|
||||||
patient_mobile: string;
|
patient_mobile: string;
|
||||||
doctor_uuid: string;
|
doctor_uuid: string;
|
||||||
doctor_name: string;
|
doctor_name: string;
|
||||||
slot_start: number;
|
slot_start: number;
|
||||||
slot_end: number;
|
slot_end: number;
|
||||||
appointment_date: string;
|
appointment_date: string;
|
||||||
appointment_time: string;
|
appointment_time: string;
|
||||||
end_time: string;
|
end_time: string;
|
||||||
status: AppointmentStatus;
|
status: AppointmentStatus;
|
||||||
version: number;
|
version: number;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PaymentStatus = 'pending' | 'success' | 'failed' | 'canceled' | 'refunded';
|
export type PaymentStatus =
|
||||||
export type PaymentGateway = 'mellat' | 'sep';
|
| "pending"
|
||||||
|
| "success"
|
||||||
|
| "failed"
|
||||||
|
| "canceled"
|
||||||
|
| "refunded";
|
||||||
|
export type PaymentGateway = "mellat" | "sep";
|
||||||
|
|
||||||
export interface Payment {
|
export interface Payment {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
status: PaymentStatus;
|
status: PaymentStatus;
|
||||||
gateway: PaymentGateway;
|
gateway: PaymentGateway;
|
||||||
ref_id: string | null;
|
ref_id: string | null;
|
||||||
patient_mobile: string;
|
patient_mobile: string;
|
||||||
appointment_uuid: string | null;
|
appointment_uuid: string | null;
|
||||||
paid_at: string | null;
|
paid_at: string | null;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SettlementStatus = 'pending' | 'approved' | 'rejected';
|
export type SettlementStatus = "pending" | "approved" | "rejected";
|
||||||
|
|
||||||
export interface Settlement {
|
export interface Settlement {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
representation_name: string;
|
representation_name: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
status: SettlementStatus;
|
status: SettlementStatus;
|
||||||
bank_card: string | null;
|
bank_card: string | null;
|
||||||
bank_name: string | null;
|
bank_name: string | null;
|
||||||
reject_reason: string | null;
|
reject_reason: string | null;
|
||||||
requested_at: string;
|
requested_at: string;
|
||||||
processed_at: string | null;
|
processed_at: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Representation {
|
export interface Representation {
|
||||||
id: number;
|
id: number;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
full_name: string;
|
full_name: string;
|
||||||
domain?: string;
|
domain?: string;
|
||||||
mobile_number: string | null;
|
mobile_number: string | null;
|
||||||
city_id: number | null;
|
city_id: number | null;
|
||||||
city: string | null;
|
city: string | null;
|
||||||
commission_percent: number;
|
commission_percent: number;
|
||||||
bank_account: { card?: string; bank_name?: string; iban?: string } | null;
|
bank_account: { card?: string; bank_name?: string; iban?: string } | null;
|
||||||
wallet_balance?: number;
|
wallet_balance?: number;
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
is_active?: boolean;
|
is_active?: boolean;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Comment {
|
export interface Comment {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
patient_name: string;
|
patient_name: string;
|
||||||
doctor_name: string;
|
doctor_name: string;
|
||||||
title: string;
|
title: string;
|
||||||
body: string;
|
body: string;
|
||||||
is_approved: boolean;
|
is_approved: boolean;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Rating {
|
export interface Rating {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
patient_name: string;
|
patient_name: string;
|
||||||
doctor_name: string;
|
doctor_name: string;
|
||||||
diagnosis_accuracy: number;
|
diagnosis_accuracy: number;
|
||||||
skill: number;
|
skill: number;
|
||||||
behavior: number;
|
behavior: number;
|
||||||
cleanliness: number;
|
cleanliness: number;
|
||||||
waiting_time: number;
|
waiting_time: number;
|
||||||
overall: number;
|
overall: number;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SmsTemplateStatus = 'draft' | 'pending' | 'approved' | 'rejected';
|
export type SmsTemplateStatus = "draft" | "pending" | "approved" | "rejected";
|
||||||
|
|
||||||
export interface SmsTemplate {
|
export interface SmsTemplate {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
body: string;
|
body: string;
|
||||||
provider_code: string | null;
|
provider_code: string | null;
|
||||||
status: SmsTemplateStatus;
|
status: SmsTemplateStatus;
|
||||||
admin_note: string | null;
|
admin_note: string | null;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SmsLog {
|
export interface SmsLog {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
recipient: string;
|
recipient: string;
|
||||||
message: string;
|
message: string;
|
||||||
status: 'queued' | 'sent' | 'failed';
|
status: "queued" | "sent" | "failed";
|
||||||
provider: string;
|
provider: string;
|
||||||
tag: string;
|
tag: string;
|
||||||
sent_at: string | null;
|
sent_at: string | null;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SmsMessageText {
|
export interface SmsMessageText {
|
||||||
tag: string;
|
tag: string;
|
||||||
title: string;
|
title: string;
|
||||||
body: string;
|
body: string;
|
||||||
variables: string[];
|
variables: string[];
|
||||||
updated_at: number | null;
|
updated_at: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Province {
|
export interface Province {
|
||||||
id: number;
|
id: number;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
status: number;
|
status: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface City {
|
export interface City {
|
||||||
id: number;
|
id: number;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
status: number;
|
status: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
province_id: number | null;
|
province_id: number | null;
|
||||||
representation_id?: number | null;
|
representation_id?: number | null;
|
||||||
contact_phone?: string | null;
|
contact_phone?: string | null;
|
||||||
email?: string | null;
|
email?: string | null;
|
||||||
description?: string | null;
|
description?: string | null;
|
||||||
slogan?: string | null;
|
slogan?: string | null;
|
||||||
domain?: string | null;
|
domain?: string | null;
|
||||||
keywords?: string | null;
|
keywords?: string | null;
|
||||||
footer_description?: string | null;
|
footer_description?: string | null;
|
||||||
social_media?: Record<string, string> | null;
|
social_media?: Record<string, string> | null;
|
||||||
logo_url?: string | null;
|
logo_url?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SpecialtyFull {
|
export interface SpecialtyFull {
|
||||||
id: number;
|
id: number;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
status: number;
|
status: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
parent_id: number | null;
|
parent_id: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DoctorService {
|
export interface DoctorService {
|
||||||
id: number;
|
id: number;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
status: number;
|
status: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
specialty_id: number | null;
|
specialty_id: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Insurance {
|
export interface Insurance {
|
||||||
id: number;
|
id: number;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: 'basic' | 'supplementary';
|
type: "basic" | "supplementary";
|
||||||
logo_url: string | null;
|
logo_url: string | null;
|
||||||
status: number;
|
status: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Tag {
|
export interface Tag {
|
||||||
id: number;
|
id: number;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
status: number;
|
status: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Blog {
|
export interface Blog {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
title: string;
|
title: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
summary: string | null;
|
summary: string | null;
|
||||||
body: string;
|
body: string;
|
||||||
image_url: string | null;
|
image_url: string | null;
|
||||||
status: 'draft' | 'published';
|
status: "draft" | "published";
|
||||||
author?: { uuid: string; name: string } | null;
|
author?: { uuid: string; name: string } | null;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at?: string;
|
updated_at?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Secretary {
|
export interface Secretary {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
user_name: string;
|
user_name: string;
|
||||||
mobile_number: string;
|
mobile_number: string;
|
||||||
doctor_name: string;
|
doctor_name: string;
|
||||||
doctor_uuid: string;
|
doctor_uuid: string;
|
||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
permissions: SecretaryPermissions;
|
permissions: SecretaryPermissions;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SecretaryPermissions {
|
export interface SecretaryPermissions {
|
||||||
appointments: {
|
appointments: {
|
||||||
view: boolean;
|
view: boolean;
|
||||||
create: boolean;
|
create: boolean;
|
||||||
cancel: boolean;
|
cancel: boolean;
|
||||||
update_status: boolean;
|
update_status: boolean;
|
||||||
};
|
};
|
||||||
addresses: {
|
addresses: {
|
||||||
view: boolean;
|
view: boolean;
|
||||||
create: boolean;
|
create: boolean;
|
||||||
update: boolean;
|
update: boolean;
|
||||||
delete: boolean;
|
delete: boolean;
|
||||||
};
|
};
|
||||||
clinic_info: {
|
clinic_info: {
|
||||||
view: boolean;
|
view: boolean;
|
||||||
update: boolean;
|
update: boolean;
|
||||||
};
|
};
|
||||||
insurances: {
|
insurances: {
|
||||||
view: boolean;
|
view: boolean;
|
||||||
create: boolean;
|
create: boolean;
|
||||||
update: boolean;
|
update: boolean;
|
||||||
delete: boolean;
|
delete: boolean;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Specialty {
|
export interface Specialty {
|
||||||
id?: number;
|
id?: number;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
slug?: string;
|
slug?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ClinicStaff {
|
export interface ClinicStaff {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
full_name: string;
|
full_name: string;
|
||||||
phone: string | null;
|
phone: string | null;
|
||||||
job_title: string | null;
|
job_title: string | null;
|
||||||
address: string | null;
|
address: string | null;
|
||||||
national_code: string | null;
|
national_code: string | null;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
created_at: number;
|
created_at: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SubscriptionPlan {
|
export interface SubscriptionPlan {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
level: number;
|
level: number;
|
||||||
max_secretaries: number;
|
max_secretaries: number;
|
||||||
features: Record<string, boolean>;
|
features: Record<string, boolean>;
|
||||||
periods: SubscriptionPeriod[];
|
periods: SubscriptionPeriod[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SubscriptionPeriod {
|
export interface SubscriptionPeriod {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
label: string;
|
label: string;
|
||||||
duration_months: number;
|
duration_months: number;
|
||||||
price_rials: number;
|
price_rials: number;
|
||||||
is_trial: boolean;
|
is_trial: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MySubscriptionData {
|
export interface MySubscriptionData {
|
||||||
subscription: {
|
subscription: {
|
||||||
plan: { name: string; level: number; max_secretaries: number; features: Record<string, boolean> };
|
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 };
|
period?: { label: string; duration_months: number };
|
||||||
is_trial: boolean;
|
is_trial: boolean;
|
||||||
starts_at?: number;
|
starts_at?: number;
|
||||||
expires_at?: number | null;
|
expires_at?: number | null;
|
||||||
|
used_trial: boolean;
|
||||||
days_remaining?: number;
|
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 {
|
export interface ServiceSection {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServiceItem {
|
export interface ServiceItem {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
price_rials: number;
|
price_rials: number;
|
||||||
staff: { uuid: string; full_name: string } | null;
|
staff: { uuid: string; full_name: string } | null;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SmsWalletBalance {
|
export interface SmsWalletBalance {
|
||||||
balance_rials: number;
|
balance_rials: number;
|
||||||
sms_price_rials: number;
|
sms_price_rials: number;
|
||||||
estimated_sms_count: number;
|
estimated_sms_count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SmsWalletLog {
|
export interface SmsWalletLog {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
type: 'credit' | 'debit';
|
type: "credit" | "debit";
|
||||||
amount_rials: number;
|
amount_rials: number;
|
||||||
description: string;
|
description: string;
|
||||||
created_at: number;
|
created_at: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SmsSettings {
|
export interface SmsSettings {
|
||||||
reminder_enabled: boolean;
|
reminder_enabled: boolean;
|
||||||
reminder_hours_before: number;
|
reminder_hours_before: number;
|
||||||
post_visit_enabled: boolean;
|
post_visit_enabled: boolean;
|
||||||
post_visit_text: string | null;
|
post_visit_text: string | null;
|
||||||
post_visit_text_pending?: string | null;
|
post_visit_text_pending?: string | null;
|
||||||
post_visit_text_status?: 'none' | 'pending' | 'approved' | 'rejected';
|
post_visit_text_status?: "none" | "pending" | "approved" | "rejected";
|
||||||
post_visit_text_reject_reason?: string | null;
|
post_visit_text_reject_reason?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PatientRecord {
|
export interface PatientRecord {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
entity_type: string;
|
entity_type: string;
|
||||||
entity_id: number;
|
entity_id: number;
|
||||||
user: { uuid: string; fullName: string; phone: string };
|
user?: {
|
||||||
created_at: number;
|
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 {
|
export interface PatientSession {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
record_uuid: string;
|
record_uuid: string;
|
||||||
appointment_uuid: string | null;
|
appointment_uuid: string | null;
|
||||||
insurance_base_id: number | null;
|
insurance_base_id: number | null;
|
||||||
insurance_supplementary_id: number | null;
|
insurance_supplementary_id: number | null;
|
||||||
visit_price_rials: number;
|
visit_price_rials: number;
|
||||||
base_insurance_discount_percent: string;
|
base_insurance_discount_percent: string;
|
||||||
supplementary_discount_percent: string;
|
supplementary_discount_percent: string;
|
||||||
services_total_rials: number;
|
services_total_rials: number;
|
||||||
final_price_rials: number;
|
final_price_rials: number;
|
||||||
payment_method: string;
|
payment_method: string;
|
||||||
notes: string | null;
|
notes: string | null;
|
||||||
created_at: number;
|
created_at: number;
|
||||||
updated_at: number;
|
updated_at: number;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -421,7 +421,15 @@ Updated template with `status: "rejected"`.
|
|||||||
|
|
||||||
### GET /api/v1/admin/sms/settings/review
|
### 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
|
```json
|
||||||
{
|
{
|
||||||
@@ -432,6 +440,7 @@ Updated template with `status: "rejected"`.
|
|||||||
"id": 3,
|
"id": 3,
|
||||||
"entity_type": "doctor",
|
"entity_type": "doctor",
|
||||||
"entity_id": 7,
|
"entity_id": 7,
|
||||||
|
"entity_name": "دکتر محمد محمدی",
|
||||||
"post_visit_text_pending": "متن در انتظار تأیید",
|
"post_visit_text_pending": "متن در انتظار تأیید",
|
||||||
"post_visit_text_status": "pending",
|
"post_visit_text_status": "pending",
|
||||||
...
|
...
|
||||||
|
|||||||
@@ -194,15 +194,26 @@ class SmsWalletController extends BaseController
|
|||||||
|
|
||||||
#[Route('/api/v1/admin/sms/settings/review', methods: ['GET'])]
|
#[Route('/api/v1/admin/sms/settings/review', methods: ['GET'])]
|
||||||
#[IsGranted('ROLE_ADMIN')]
|
#[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')
|
$pending = $this->settingsRepo->createQueryBuilder('s')
|
||||||
->where('s.postVisitTextStatus = :status')
|
->where('s.postVisitTextStatus = :status')
|
||||||
->setParameter('status', SmsSettings::TEXT_STATUS_PENDING)
|
->setParameter('status', $status)
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getResult();
|
->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'])]
|
#[Route('/api/v1/admin/sms/settings/{id}/approve', methods: ['POST'])]
|
||||||
@@ -241,6 +252,17 @@ class SmsWalletController extends BaseController
|
|||||||
return $this->success($settings->toArray());
|
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'])]
|
#[Route('/api/v1/admin/sms/wallet-report', methods: ['GET'])]
|
||||||
#[IsGranted('ROLE_ADMIN')]
|
#[IsGranted('ROLE_ADMIN')]
|
||||||
public function adminReport(Request $request): JsonResponse
|
public function adminReport(Request $request): JsonResponse
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class SmsSettings
|
|||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
'entity_type' => $this->entityType,
|
'entity_type' => $this->entityType,
|
||||||
'entity_id' => $this->entityId,
|
'entity_id' => $this->entityId,
|
||||||
'reminder_enabled' => $this->reminderEnabled,
|
'reminder_enabled' => $this->reminderEnabled,
|
||||||
|
|||||||
Reference in New Issue
Block a user