feat: response in mobile and accouting
This commit is contained in:
+248
-75
@@ -1,6 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState, useEffect, useCallback } from 'react';
|
import { useState, useEffect, useCallback } from 'react';
|
||||||
|
import type { ComponentType } from 'react';
|
||||||
import { useAuth } from '@/contexts/AuthContext';
|
import { useAuth } from '@/contexts/AuthContext';
|
||||||
import { purchasesApi } from '@/lib/api/purchases';
|
import { purchasesApi } from '@/lib/api/purchases';
|
||||||
import { packagesApi } from '@/lib/api/packages';
|
import { packagesApi } from '@/lib/api/packages';
|
||||||
@@ -25,6 +26,51 @@ import {
|
|||||||
// بنابراین هر دو وضعیت باید بهعنوان فروش محسوب شوند.
|
// بنابراین هر دو وضعیت باید بهعنوان فروش محسوب شوند.
|
||||||
const PAID_STATUSES = [2, 3];
|
const PAID_STATUSES = [2, 3];
|
||||||
|
|
||||||
|
// Local-time Gregorian helpers. The "YYYY-MM-DD" format matches what
|
||||||
|
// PersianDatePicker exchanges and what the created_at comparison expects.
|
||||||
|
const toGregorianValue = (date: Date): string => {
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(date.getDate()).padStart(2, '0');
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const addDays = (date: Date, days: number): Date => {
|
||||||
|
const copy = new Date(date);
|
||||||
|
copy.setDate(copy.getDate() + days);
|
||||||
|
return copy;
|
||||||
|
};
|
||||||
|
|
||||||
|
const todayValue = (): string => toGregorianValue(new Date());
|
||||||
|
|
||||||
|
type DatePreset = 'today' | 'yesterday' | 'last7' | 'thisMonth';
|
||||||
|
|
||||||
|
const presetRange = (preset: DatePreset): { from: string; to: string } => {
|
||||||
|
const now = new Date();
|
||||||
|
switch (preset) {
|
||||||
|
case 'today':
|
||||||
|
return { from: toGregorianValue(now), to: toGregorianValue(now) };
|
||||||
|
case 'yesterday': {
|
||||||
|
const yesterday = addDays(now, -1);
|
||||||
|
return { from: toGregorianValue(yesterday), to: toGregorianValue(yesterday) };
|
||||||
|
}
|
||||||
|
case 'last7':
|
||||||
|
return { from: toGregorianValue(addDays(now, -6)), to: toGregorianValue(now) };
|
||||||
|
case 'thisMonth':
|
||||||
|
return {
|
||||||
|
from: toGregorianValue(new Date(now.getFullYear(), now.getMonth(), 1)),
|
||||||
|
to: toGregorianValue(now),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const PRESET_LABELS: { key: DatePreset; label: string }[] = [
|
||||||
|
{ key: 'today', label: 'امروز' },
|
||||||
|
{ key: 'yesterday', label: 'دیروز' },
|
||||||
|
{ key: 'last7', label: '۷ روز اخیر' },
|
||||||
|
{ key: 'thisMonth', label: 'این ماه' },
|
||||||
|
];
|
||||||
|
|
||||||
interface StoreSummary {
|
interface StoreSummary {
|
||||||
count: number;
|
count: number;
|
||||||
gross: number;
|
gross: number;
|
||||||
@@ -166,9 +212,10 @@ export default function AccountingPage() {
|
|||||||
const [products, setProducts] = useState<Product[]>([]);
|
const [products, setProducts] = useState<Product[]>([]);
|
||||||
const [selectedProductId, setSelectedProductId] = useState<string>('');
|
const [selectedProductId, setSelectedProductId] = useState<string>('');
|
||||||
|
|
||||||
// Date range
|
// Date range — defaults to today so the daily account is the first thing shown
|
||||||
const [dateFrom, setDateFrom] = useState<string>('');
|
const [dateFrom, setDateFrom] = useState<string>(todayValue);
|
||||||
const [dateTo, setDateTo] = useState<string>('');
|
const [dateTo, setDateTo] = useState<string>(todayValue);
|
||||||
|
const [preset, setPreset] = useState<DatePreset | null>('today');
|
||||||
|
|
||||||
// Time range
|
// Time range
|
||||||
const [timeFrom, setTimeFrom] = useState<string>('');
|
const [timeFrom, setTimeFrom] = useState<string>('');
|
||||||
@@ -187,20 +234,20 @@ export default function AccountingPage() {
|
|||||||
const [result, setResult] = useState<AccountingResult | null>(null);
|
const [result, setResult] = useState<AccountingResult | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
// Bumped by the «تحلیل» button / «بارگذاری مجدد» to force a refetch
|
||||||
|
const [refreshTick, setRefreshTick] = useState(0);
|
||||||
|
|
||||||
const inputClass =
|
const inputClass =
|
||||||
'block w-full px-3 py-2.5 text-gray-900 dark:text-gray-100 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm focus:ring-2 focus:ring-indigo-500 focus:border-transparent sm:text-sm dark:bg-gray-800/80 transition-colors';
|
'block w-full px-3 py-2.5 text-gray-900 dark:text-gray-100 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm focus:ring-2 focus:ring-indigo-500 focus:border-transparent sm:text-sm dark:bg-gray-800/80 transition-colors';
|
||||||
const labelClass = 'block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5';
|
const labelClass = 'block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5';
|
||||||
|
|
||||||
// Load packages once on mount
|
// Load packages once on mount — "همه پکیجها" stays selected by default so
|
||||||
|
// the initial view covers the whole business.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!token) return;
|
if (!token) return;
|
||||||
packagesApi
|
packagesApi
|
||||||
.getAllPackages(token)
|
.getAllPackages(token)
|
||||||
.then((data) => {
|
.then(setPackages)
|
||||||
setPackages(data);
|
|
||||||
if (data.length > 0) setSelectedPackageName(data[0].name || '');
|
|
||||||
})
|
|
||||||
.catch(() => setError('خطا در دریافت لیست پکیجها'));
|
.catch(() => setError('خطا در دریافت لیست پکیجها'));
|
||||||
}, [token]);
|
}, [token]);
|
||||||
|
|
||||||
@@ -218,28 +265,61 @@ export default function AccountingPage() {
|
|||||||
.catch(() => setProducts([]));
|
.catch(() => setProducts([]));
|
||||||
}, [selectedPackageName, token]);
|
}, [selectedPackageName, token]);
|
||||||
|
|
||||||
const handleAnalyze = useCallback(async () => {
|
// The server-side query window. Fetching only the selected window keeps the
|
||||||
|
// payload small; the backend filters created_at by these dates. Runs
|
||||||
|
// automatically on mount (today's account) and whenever the window,
|
||||||
|
// package or product selection changes.
|
||||||
|
const windowKey = [dateFrom, dateTo, timeFrom, timeTo, selectedPackageName, selectedProductId].join('|');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
if (!token) return;
|
if (!token) return;
|
||||||
|
let cancelled = false;
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
try {
|
|
||||||
// Fetch all purchases once, then filter/aggregate in-memory.
|
purchasesApi
|
||||||
const purchases = await purchasesApi.getAllPurchases({ per_page: 500 }, token);
|
.getAllPurchases(
|
||||||
setAllPurchases(purchases);
|
{
|
||||||
setResult(
|
per_page: 500,
|
||||||
computeAccounting(
|
...(dateFrom && { date_from: dateFrom }),
|
||||||
purchases,
|
...(dateTo && { date_to: dateTo }),
|
||||||
parseStoreRate(myketRate),
|
...(timeFrom && { time_from: timeFrom }),
|
||||||
parseStoreRate(cafeRate),
|
...(timeTo && { time_to: timeTo }),
|
||||||
parseFee(transactionFee)
|
...(selectedPackageName && { package_name: selectedPackageName }),
|
||||||
)
|
...(selectedProductId && { product_id: Number(selectedProductId) }),
|
||||||
);
|
},
|
||||||
} catch (err) {
|
token
|
||||||
setError(err instanceof Error ? err.message : 'خطا در دریافت دادهها');
|
)
|
||||||
} finally {
|
.then((purchases) => {
|
||||||
setIsLoading(false);
|
if (cancelled) return;
|
||||||
}
|
setAllPurchases(purchases);
|
||||||
}, [token, myketRate, cafeRate, transactionFee]);
|
setResult(
|
||||||
|
computeAccounting(
|
||||||
|
purchases,
|
||||||
|
parseStoreRate(myketRate),
|
||||||
|
parseStoreRate(cafeRate),
|
||||||
|
parseFee(transactionFee)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
if (!cancelled) {
|
||||||
|
setError(err instanceof Error ? err.message : 'خطا در دریافت دادهها');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (!cancelled) setIsLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
};
|
||||||
|
// Commission rates are read at fetch time only; changing them recomputes
|
||||||
|
// locally (see runAnalysis) without refetching.
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [token, windowKey, refreshTick]);
|
||||||
|
|
||||||
|
const handleAnalyze = () => setRefreshTick((t) => t + 1);
|
||||||
|
|
||||||
// Recompute whenever filters or commission rates change (uses cached data)
|
// Recompute whenever filters or commission rates change (uses cached data)
|
||||||
const runAnalysis = useCallback(() => {
|
const runAnalysis = useCallback(() => {
|
||||||
@@ -291,13 +371,29 @@ export default function AccountingPage() {
|
|||||||
if (allPurchases) runAnalysis();
|
if (allPurchases) runAnalysis();
|
||||||
}, [runAnalysis, allPurchases]);
|
}, [runAnalysis, allPurchases]);
|
||||||
|
|
||||||
const handleReset = () => {
|
const applyPreset = (key: DatePreset) => {
|
||||||
setSelectedPackageName(packages[0]?.name || '');
|
const range = presetRange(key);
|
||||||
setSelectedProductId('');
|
setPreset(key);
|
||||||
setDateFrom('');
|
setDateFrom(range.from);
|
||||||
setDateTo('');
|
setDateTo(range.to);
|
||||||
setTimeFrom('');
|
setTimeFrom('');
|
||||||
setTimeTo('');
|
setTimeTo('');
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDateFromChange = (value: string) => {
|
||||||
|
setPreset(null);
|
||||||
|
setDateFrom(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDateToChange = (value: string) => {
|
||||||
|
setPreset(null);
|
||||||
|
setDateTo(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
setSelectedPackageName('');
|
||||||
|
setSelectedProductId('');
|
||||||
|
applyPreset('today');
|
||||||
setStatuses([...PAID_STATUSES]);
|
setStatuses([...PAID_STATUSES]);
|
||||||
setMyketRate('85');
|
setMyketRate('85');
|
||||||
setCafeRate('85');
|
setCafeRate('85');
|
||||||
@@ -310,11 +406,6 @@ export default function AccountingPage() {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const statCardClass =
|
|
||||||
'rounded-2xl bg-white dark:bg-gray-900 ring-1 ring-gray-200 dark:ring-gray-800 p-5 shadow-sm';
|
|
||||||
const statIconClass = 'h-5 w-5';
|
|
||||||
const statValueClass = 'text-2xl font-bold text-gray-900 dark:text-gray-100 mt-1.5';
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-4 sm:p-8">
|
<div className="p-4 sm:p-8">
|
||||||
<div className="max-w-7xl mx-auto">
|
<div className="max-w-7xl mx-auto">
|
||||||
@@ -384,7 +475,7 @@ export default function AccountingPage() {
|
|||||||
label="از تاریخ"
|
label="از تاریخ"
|
||||||
placeholder="انتخاب تاریخ شروع"
|
placeholder="انتخاب تاریخ شروع"
|
||||||
value={dateFrom}
|
value={dateFrom}
|
||||||
onChange={setDateFrom}
|
onChange={handleDateFromChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -406,7 +497,7 @@ export default function AccountingPage() {
|
|||||||
label="تا تاریخ"
|
label="تا تاریخ"
|
||||||
placeholder="انتخاب تاریخ پایان"
|
placeholder="انتخاب تاریخ پایان"
|
||||||
value={dateTo}
|
value={dateTo}
|
||||||
onChange={setDateTo}
|
onChange={handleDateToChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -423,6 +514,30 @@ export default function AccountingPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Quick date-range presets */}
|
||||||
|
<div className="mt-4">
|
||||||
|
<label className={labelClass}>بازه زمانی</label>
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
{PRESET_LABELS.map(({ key, label }) => {
|
||||||
|
const active = preset === key;
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={key}
|
||||||
|
type="button"
|
||||||
|
onClick={() => applyPreset(key)}
|
||||||
|
className={`px-3.5 py-1.5 rounded-xl text-sm font-medium transition-colors ${
|
||||||
|
active
|
||||||
|
? 'bg-indigo-600 text-white shadow-sm shadow-indigo-500/20'
|
||||||
|
: 'bg-gray-50 dark:bg-gray-800 text-gray-600 dark:text-gray-300 ring-1 ring-gray-200 dark:ring-gray-700 hover:bg-gray-100 dark:hover:bg-gray-700'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Status checkboxes */}
|
{/* Status checkboxes */}
|
||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<label className={labelClass}>وضعیت</label>
|
<label className={labelClass}>وضعیت</label>
|
||||||
@@ -495,7 +610,7 @@ export default function AccountingPage() {
|
|||||||
کافهبازار ۸۵٪ (فروش زیر ۱۰ میلیارد ریال) و ۷۰٪ (بالای آن) است.
|
کافهبازار ۸۵٪ (فروش زیر ۱۰ میلیارد ریال) و ۷۰٪ (بالای آن) است.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="flex items-center gap-3 mt-5">
|
<div className="flex flex-wrap items-center gap-3 mt-5">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
@@ -537,38 +652,10 @@ export default function AccountingPage() {
|
|||||||
<>
|
<>
|
||||||
{/* Summary stat cards */}
|
{/* Summary stat cards */}
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
|
||||||
<div className={statCardClass}>
|
<StatCard label="تعداد فروش" value={formatPrice(result.totals.count)} Icon={WalletIcon} tone="indigo" />
|
||||||
<div className="flex items-center gap-2 text-sm font-medium text-gray-500 dark:text-gray-400">
|
<StatCard label="فروش ناخالص" value={formatPrice(result.totals.gross)} unit="تومان" Icon={BanknotesIcon} tone="sky" />
|
||||||
<WalletIcon className={statIconClass} />
|
<StatCard label="کارمزد فروشگاهها" value={formatPrice(result.totals.commission)} unit="تومان" Icon={ChartPieIcon} tone="amber" />
|
||||||
تعداد فروش
|
<StatCard label="سود خالص" value={formatPrice(result.totals.net)} unit="تومان" Icon={CalculatorIcon} tone="emerald" />
|
||||||
</div>
|
|
||||||
<div className={statValueClass}>{formatPrice(result.totals.count)}</div>
|
|
||||||
</div>
|
|
||||||
<div className={statCardClass}>
|
|
||||||
<div className="flex items-center gap-2 text-sm font-medium text-gray-500 dark:text-gray-400">
|
|
||||||
<BanknotesIcon className={statIconClass} />
|
|
||||||
فروش ناخالص
|
|
||||||
</div>
|
|
||||||
<div className={statValueClass}>{formatPrice(result.totals.gross)} <span className="text-sm font-normal text-gray-400">تومان</span></div>
|
|
||||||
</div>
|
|
||||||
<div className={statCardClass}>
|
|
||||||
<div className="flex items-center gap-2 text-sm font-medium text-gray-500 dark:text-gray-400">
|
|
||||||
<ChartPieIcon className={statIconClass} />
|
|
||||||
کارمزد فروشگاهها
|
|
||||||
</div>
|
|
||||||
<div className={`${statValueClass} text-amber-600 dark:text-amber-400`}>
|
|
||||||
{formatPrice(result.totals.commission)} <span className="text-sm font-normal text-gray-400">تومان</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className={statCardClass}>
|
|
||||||
<div className="flex items-center gap-2 text-sm font-medium text-gray-500 dark:text-gray-400">
|
|
||||||
<CalculatorIcon className={statIconClass} />
|
|
||||||
سود خالص
|
|
||||||
</div>
|
|
||||||
<div className={`${statValueClass} text-emerald-600 dark:text-emerald-400`}>
|
|
||||||
{formatPrice(result.totals.net)} <span className="text-sm font-normal text-gray-400">تومان</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Per-store breakdown */}
|
{/* Per-store breakdown */}
|
||||||
@@ -593,8 +680,51 @@ export default function AccountingPage() {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="overflow-x-auto">
|
<>
|
||||||
<table className="min-w-full divide-y divide-gray-200 dark:divide-gray-800">
|
{/* Mobile: stacked cards */}
|
||||||
|
<ul className="divide-y divide-gray-200 dark:divide-gray-800 md:hidden">
|
||||||
|
{result.rows.map((row) => (
|
||||||
|
<li key={row.productId} className="px-5 py-4">
|
||||||
|
<div className="flex items-start justify-between gap-3">
|
||||||
|
<div className="min-w-0">
|
||||||
|
<p className="text-sm font-semibold text-gray-900 dark:text-gray-100 truncate">
|
||||||
|
{row.title}
|
||||||
|
</p>
|
||||||
|
<p className="text-xs text-gray-500 dark:text-gray-400 mt-0.5 truncate">
|
||||||
|
{row.packageName}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<span className="flex-shrink-0 px-2.5 py-1 text-xs font-semibold rounded-lg bg-indigo-50 text-indigo-700 dark:bg-indigo-500/10 dark:text-indigo-400">
|
||||||
|
{formatPrice(row.count)} فروش
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-3 gap-2 mt-3 pt-3 border-t border-gray-100 dark:border-gray-800/60">
|
||||||
|
<div>
|
||||||
|
<p className="text-[11px] text-gray-400 dark:text-gray-500">فروش ناخالص</p>
|
||||||
|
<p className="text-xs font-bold text-gray-900 dark:text-gray-100 mt-0.5">
|
||||||
|
{formatPrice(row.gross)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="text-[11px] text-gray-400 dark:text-gray-500">کارمزد</p>
|
||||||
|
<p className="text-xs font-bold text-amber-600 dark:text-amber-400 mt-0.5">
|
||||||
|
{formatPrice(row.commission)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="text-[11px] text-gray-400 dark:text-gray-500">سود خالص</p>
|
||||||
|
<p className="text-xs font-bold text-emerald-600 dark:text-emerald-400 mt-0.5">
|
||||||
|
{formatPrice(row.net)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{/* Desktop: table */}
|
||||||
|
<div className="hidden md:block overflow-x-auto">
|
||||||
|
<table className="min-w-full divide-y divide-gray-200 dark:divide-gray-800">
|
||||||
<thead className="bg-gray-50 dark:bg-gray-800/60">
|
<thead className="bg-gray-50 dark:bg-gray-800/60">
|
||||||
<tr className="text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
<tr className="text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
||||||
<th className="px-4 py-3">محصول</th>
|
<th className="px-4 py-3">محصول</th>
|
||||||
@@ -630,7 +760,8 @@ export default function AccountingPage() {
|
|||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@@ -651,6 +782,48 @@ export default function AccountingPage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const STAT_TONES = {
|
||||||
|
indigo: 'bg-indigo-50 text-indigo-600 dark:bg-indigo-500/10 dark:text-indigo-400',
|
||||||
|
sky: 'bg-sky-50 text-sky-600 dark:bg-sky-500/10 dark:text-sky-400',
|
||||||
|
amber: 'bg-amber-50 text-amber-600 dark:bg-amber-500/10 dark:text-amber-400',
|
||||||
|
emerald: 'bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
function StatCard({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
unit,
|
||||||
|
Icon,
|
||||||
|
tone,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
unit?: string;
|
||||||
|
Icon: ComponentType<{ className?: string }>;
|
||||||
|
tone: keyof typeof STAT_TONES;
|
||||||
|
}) {
|
||||||
|
const valueColor =
|
||||||
|
tone === 'amber'
|
||||||
|
? 'text-amber-600 dark:text-amber-400'
|
||||||
|
: tone === 'emerald'
|
||||||
|
? 'text-emerald-600 dark:text-emerald-400'
|
||||||
|
: 'text-gray-900 dark:text-gray-100';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="rounded-2xl bg-white dark:bg-gray-900 ring-1 ring-gray-200 dark:ring-gray-800 p-5 shadow-sm">
|
||||||
|
<div className="flex items-center gap-2.5">
|
||||||
|
<span className={`h-9 w-9 rounded-xl flex items-center justify-center flex-shrink-0 ${STAT_TONES[tone]}`}>
|
||||||
|
<Icon className="h-5 w-5" />
|
||||||
|
</span>
|
||||||
|
<span className="text-sm font-medium text-gray-500 dark:text-gray-400">{label}</span>
|
||||||
|
</div>
|
||||||
|
<div className={`text-2xl font-bold mt-2.5 ${valueColor}`}>
|
||||||
|
{value} {unit && <span className="text-sm font-normal text-gray-400">{unit}</span>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function StoreCard({ title, summary }: { title: string; summary: StoreSummary }) {
|
function StoreCard({ title, summary }: { title: string; summary: StoreSummary }) {
|
||||||
return (
|
return (
|
||||||
<div className="bg-white dark:bg-gray-900 ring-1 ring-gray-200 dark:ring-gray-800 rounded-2xl p-5 shadow-sm">
|
<div className="bg-white dark:bg-gray-900 ring-1 ring-gray-200 dark:ring-gray-800 rounded-2xl p-5 shadow-sm">
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export default function Dashboard() {
|
|||||||
<p className="text-sm text-gray-500 dark:text-gray-400 mt-1.5 leading-relaxed">
|
<p className="text-sm text-gray-500 dark:text-gray-400 mt-1.5 leading-relaxed">
|
||||||
{desc}
|
{desc}
|
||||||
</p>
|
</p>
|
||||||
<div className="mt-4 flex items-center text-xs font-medium text-indigo-600 dark:text-indigo-400 opacity-0 group-hover:opacity-100 transition-opacity">
|
<div className="mt-4 flex items-center text-xs font-medium text-indigo-600 dark:text-indigo-400 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity">
|
||||||
ورود به بخش
|
ورود به بخش
|
||||||
<svg className="h-4 w-4 mr-1 rotate-180" fill="none" viewBox="0 0 24 24" strokeWidth={2} stroke="currentColor">
|
<svg className="h-4 w-4 mr-1 rotate-180" fill="none" viewBox="0 0 24 24" strokeWidth={2} stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" d="M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3" />
|
<path strokeLinecap="round" strokeLinejoin="round" d="M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3" />
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ export default function AdminLayout({
|
|||||||
) : (
|
) : (
|
||||||
<AuthGuard>
|
<AuthGuard>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<main className="lg:pr-64 min-h-screen">
|
{/* Extra top padding on mobile so content clears the
|
||||||
|
fixed hamburger button; the desktop sidebar needs none. */}
|
||||||
|
<main className="lg:pr-64 min-h-screen pt-16 lg:pt-0">
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
</AuthGuard>
|
</AuthGuard>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { packagesApi } from '@/lib/api/packages';
|
|||||||
import PackageList from '@/components/admin/packages/PackageList';
|
import PackageList from '@/components/admin/packages/PackageList';
|
||||||
import PackageForm from '@/components/admin/packages/PackageForm';
|
import PackageForm from '@/components/admin/packages/PackageForm';
|
||||||
import PageHeader from '@/components/admin/PageHeader';
|
import PageHeader from '@/components/admin/PageHeader';
|
||||||
|
import ConfirmDialog from '@/components/admin/ConfirmDialog';
|
||||||
import { showToast } from '@/components/Toast';
|
import { showToast } from '@/components/Toast';
|
||||||
import { PackageName, CreatePackageData, UpdatePackageData } from '@/types/package';
|
import { PackageName, CreatePackageData, UpdatePackageData } from '@/types/package';
|
||||||
import { PlusIcon } from '@heroicons/react/24/outline';
|
import { PlusIcon } from '@heroicons/react/24/outline';
|
||||||
@@ -17,6 +18,7 @@ export default function PackagesPage() {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isFormVisible, setIsFormVisible] = useState(false);
|
const [isFormVisible, setIsFormVisible] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [deleteTarget, setDeleteTarget] = useState<PackageName | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (token) {
|
if (token) {
|
||||||
@@ -47,10 +49,13 @@ export default function PackagesPage() {
|
|||||||
setIsFormVisible(true);
|
setIsFormVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async (pkg: PackageName) => {
|
const handleDelete = (pkg: PackageName) => {
|
||||||
if (!confirm(`آیا از حذف پکیج "${pkg.title}" اطمینان دارید؟`)) {
|
setDeleteTarget(pkg);
|
||||||
return;
|
};
|
||||||
}
|
|
||||||
|
const confirmDelete = async () => {
|
||||||
|
if (!deleteTarget) return;
|
||||||
|
const pkg = deleteTarget;
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -63,6 +68,7 @@ export default function PackagesPage() {
|
|||||||
setError(err instanceof Error ? err.message : 'خطا در حذف پکیج');
|
setError(err instanceof Error ? err.message : 'خطا در حذف پکیج');
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setDeleteTarget(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,6 +145,16 @@ export default function PackagesPage() {
|
|||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
open={!!deleteTarget}
|
||||||
|
title="حذف پکیج"
|
||||||
|
message={`آیا از حذف پکیج «${deleteTarget?.title || deleteTarget?.name || ''}» اطمینان دارید؟`}
|
||||||
|
confirmLabel="حذف"
|
||||||
|
isLoading={isLoading}
|
||||||
|
onConfirm={confirmDelete}
|
||||||
|
onCancel={() => setDeleteTarget(null)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { productsApi } from '@/lib/api/products';
|
|||||||
import ProductList from '@/components/admin/products/ProductList';
|
import ProductList from '@/components/admin/products/ProductList';
|
||||||
import ProductForm from '@/components/admin/products/ProductForm';
|
import ProductForm from '@/components/admin/products/ProductForm';
|
||||||
import PageHeader from '@/components/admin/PageHeader';
|
import PageHeader from '@/components/admin/PageHeader';
|
||||||
|
import ConfirmDialog from '@/components/admin/ConfirmDialog';
|
||||||
import { showToast } from '@/components/Toast';
|
import { showToast } from '@/components/Toast';
|
||||||
import { PackageName } from '@/types/package';
|
import { PackageName } from '@/types/package';
|
||||||
import { Product, CreateProductData, UpdateProductData } from '@/types/product';
|
import { Product, CreateProductData, UpdateProductData } from '@/types/product';
|
||||||
@@ -22,6 +23,7 @@ export default function ProductsPage() {
|
|||||||
const [isLoadingPackages, setIsLoadingPackages] = useState(false);
|
const [isLoadingPackages, setIsLoadingPackages] = useState(false);
|
||||||
const [isFormVisible, setIsFormVisible] = useState(false);
|
const [isFormVisible, setIsFormVisible] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [deleteTarget, setDeleteTarget] = useState<Product | null>(null);
|
||||||
|
|
||||||
const initialLoadRef = useRef(false);
|
const initialLoadRef = useRef(false);
|
||||||
const prevPackageRef = useRef<string | null>(null);
|
const prevPackageRef = useRef<string | null>(null);
|
||||||
@@ -94,11 +96,13 @@ export default function ProductsPage() {
|
|||||||
setIsFormVisible(true);
|
setIsFormVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async (product: Product) => {
|
const handleDelete = (product: Product) => {
|
||||||
if (!selectedPackage) return;
|
setDeleteTarget(product);
|
||||||
if (!confirm(`آیا از حذف محصول "${product.title}" اطمینان دارید؟`)) {
|
};
|
||||||
return;
|
|
||||||
}
|
const confirmDelete = async () => {
|
||||||
|
if (!selectedPackage || !deleteTarget) return;
|
||||||
|
const product = deleteTarget;
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -114,6 +118,7 @@ export default function ProductsPage() {
|
|||||||
setError(err instanceof Error ? err.message : 'خطا در حذف محصول');
|
setError(err instanceof Error ? err.message : 'خطا در حذف محصول');
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setDeleteTarget(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -226,6 +231,16 @@ export default function ProductsPage() {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
open={!!deleteTarget}
|
||||||
|
title="حذف محصول"
|
||||||
|
message={`آیا از حذف محصول «${deleteTarget?.title || ''}» اطمینان دارید؟`}
|
||||||
|
confirmLabel="حذف"
|
||||||
|
isLoading={isLoading}
|
||||||
|
onConfirm={confirmDelete}
|
||||||
|
onCancel={() => setDeleteTarget(null)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { promotionsApi } from '@/lib/api/promotions';
|
|||||||
import PromotionList from '@/components/admin/promotions/PromotionList';
|
import PromotionList from '@/components/admin/promotions/PromotionList';
|
||||||
import PromotionForm from '@/components/admin/promotions/PromotionForm';
|
import PromotionForm from '@/components/admin/promotions/PromotionForm';
|
||||||
import PageHeader from '@/components/admin/PageHeader';
|
import PageHeader from '@/components/admin/PageHeader';
|
||||||
|
import ConfirmDialog from '@/components/admin/ConfirmDialog';
|
||||||
import { showToast } from '@/components/Toast';
|
import { showToast } from '@/components/Toast';
|
||||||
import { Promotion, CreatePromotionData, UpdatePromotionData } from '@/types/promotion';
|
import { Promotion, CreatePromotionData, UpdatePromotionData } from '@/types/promotion';
|
||||||
import { PlusIcon } from '@heroicons/react/24/outline';
|
import { PlusIcon } from '@heroicons/react/24/outline';
|
||||||
@@ -17,6 +18,7 @@ export default function PromotionsPage() {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isFormVisible, setIsFormVisible] = useState(false);
|
const [isFormVisible, setIsFormVisible] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [deleteTarget, setDeleteTarget] = useState<Promotion | null>(null);
|
||||||
|
|
||||||
const initialLoadRef = useRef(false);
|
const initialLoadRef = useRef(false);
|
||||||
|
|
||||||
@@ -50,10 +52,13 @@ export default function PromotionsPage() {
|
|||||||
setIsFormVisible(true);
|
setIsFormVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async (promotion: Promotion) => {
|
const handleDelete = (promotion: Promotion) => {
|
||||||
if (!confirm(`آیا از حذف تبلیغ "${promotion.title || 'بدون عنوان'}" اطمینان دارید؟`)) {
|
setDeleteTarget(promotion);
|
||||||
return;
|
};
|
||||||
}
|
|
||||||
|
const confirmDelete = async () => {
|
||||||
|
if (!deleteTarget) return;
|
||||||
|
const promotion = deleteTarget;
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -66,6 +71,7 @@ export default function PromotionsPage() {
|
|||||||
setError(err instanceof Error ? err.message : 'خطا در حذف تبلیغ');
|
setError(err instanceof Error ? err.message : 'خطا در حذف تبلیغ');
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setDeleteTarget(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -159,6 +165,16 @@ export default function PromotionsPage() {
|
|||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
open={!!deleteTarget}
|
||||||
|
title="حذف تبلیغ"
|
||||||
|
message={`آیا از حذف تبلیغ «${deleteTarget?.title || 'بدون عنوان'}» اطمینان دارید؟`}
|
||||||
|
confirmLabel="حذف"
|
||||||
|
isLoading={isLoading}
|
||||||
|
onConfirm={confirmDelete}
|
||||||
|
onCancel={() => setDeleteTarget(null)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ export default function PurchasesPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-3 mt-5">
|
<div className="flex flex-wrap items-center gap-3 mt-5">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
@@ -202,7 +202,55 @@ export default function PurchasesPage() {
|
|||||||
<p className="text-gray-500 dark:text-gray-400 text-sm">هیچ خریدی با این فیلترها یافت نشد</p>
|
<p className="text-gray-500 dark:text-gray-400 text-sm">هیچ خریدی با این فیلترها یافت نشد</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="overflow-x-auto">
|
<>
|
||||||
|
{/* Mobile: stacked cards */}
|
||||||
|
<ul className="divide-y divide-gray-200 dark:divide-gray-800 md:hidden">
|
||||||
|
{result.data.map((purchase) => (
|
||||||
|
<li key={purchase.id} className="px-5 py-4 space-y-2.5">
|
||||||
|
<div className="flex items-start justify-between gap-3">
|
||||||
|
<div className="min-w-0">
|
||||||
|
<p className="text-sm font-semibold text-gray-900 dark:text-gray-100 truncate">
|
||||||
|
{purchase.product?.title || '—'}
|
||||||
|
</p>
|
||||||
|
<p className="text-xs text-gray-500 dark:text-gray-400 mt-0.5 truncate">
|
||||||
|
{purchase.product?.package_name?.title || purchase.product?.package_name?.name || '—'}
|
||||||
|
{purchase.product ? ` • ${getProductTypeLabel(purchase.product.type)}` : ''}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<span className={`flex-shrink-0 px-2.5 py-1 inline-flex text-xs leading-5 font-semibold rounded-lg ${statusBadgeClass(purchase.status)}`}>
|
||||||
|
{getPurchaseStatusLabel(purchase.status)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="text-xs text-gray-500 dark:text-gray-400 space-y-0.5">
|
||||||
|
<p className="font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
{purchase.user?.full_name?.trim() || 'بدون نام'}
|
||||||
|
</p>
|
||||||
|
{purchase.user?.email && (
|
||||||
|
<p dir="ltr" className="text-right truncate">{purchase.user.email}</p>
|
||||||
|
)}
|
||||||
|
{purchase.user?.mobile && (
|
||||||
|
<p dir="ltr" className="text-right truncate">{purchase.user.mobile}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center justify-between gap-3 pt-2.5 border-t border-gray-100 dark:border-gray-800/60">
|
||||||
|
<span className="text-sm font-bold text-gray-900 dark:text-gray-100">
|
||||||
|
{formatPrice(getPurchaseFinalPrice(purchase))} تومان
|
||||||
|
</span>
|
||||||
|
<div className="flex flex-col items-end gap-1">
|
||||||
|
<span className="px-2 py-0.5 text-[11px] font-medium rounded-md bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300">
|
||||||
|
{getGatewayLabel(purchase.gateway)}
|
||||||
|
</span>
|
||||||
|
<span className="text-[11px] text-gray-400 dark:text-gray-500">
|
||||||
|
{formatDate(purchase.created_at)} {formatTime(purchase.created_at)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{/* Desktop: table */}
|
||||||
|
<div className="hidden md:block overflow-x-auto">
|
||||||
<table className="min-w-full divide-y divide-gray-200 dark:divide-gray-800">
|
<table className="min-w-full divide-y divide-gray-200 dark:divide-gray-800">
|
||||||
<thead className="bg-gray-50 dark:bg-gray-800/60">
|
<thead className="bg-gray-50 dark:bg-gray-800/60">
|
||||||
<tr className="text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
<tr className="text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
||||||
@@ -260,7 +308,8 @@ export default function PurchasesPage() {
|
|||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Pagination */}
|
{/* Pagination */}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useAuth } from '@/contexts/AuthContext';
|
|||||||
import { referralApi } from '@/lib/api/referral';
|
import { referralApi } from '@/lib/api/referral';
|
||||||
import ReferralList from '@/components/admin/referral/ReferralList';
|
import ReferralList from '@/components/admin/referral/ReferralList';
|
||||||
import PageHeader from '@/components/admin/PageHeader';
|
import PageHeader from '@/components/admin/PageHeader';
|
||||||
|
import ConfirmDialog from '@/components/admin/ConfirmDialog';
|
||||||
import { showToast } from '@/components/Toast';
|
import { showToast } from '@/components/Toast';
|
||||||
import { ReferralRewardUser } from '@/types/referral';
|
import { ReferralRewardUser } from '@/types/referral';
|
||||||
import { ArrowPathIcon } from '@heroicons/react/24/outline';
|
import { ArrowPathIcon } from '@heroicons/react/24/outline';
|
||||||
@@ -16,6 +17,7 @@ export default function ReferralRewardsPage() {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [fulfillingId, setFulfillingId] = useState<number | null>(null);
|
const [fulfillingId, setFulfillingId] = useState<number | null>(null);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [fulfillTarget, setFulfillTarget] = useState<ReferralRewardUser | null>(null);
|
||||||
|
|
||||||
const initialLoadRef = useRef(false);
|
const initialLoadRef = useRef(false);
|
||||||
|
|
||||||
@@ -40,10 +42,13 @@ export default function ReferralRewardsPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFulfill = async (user: ReferralRewardUser) => {
|
const handleFulfill = (user: ReferralRewardUser) => {
|
||||||
if (!confirm(`آیا از اعطای یک ماه اشتراک رایگان به «${user.name || user.mobile || user.email}» اطمینان دارید؟`)) {
|
setFulfillTarget(user);
|
||||||
return;
|
};
|
||||||
}
|
|
||||||
|
const confirmFulfill = async () => {
|
||||||
|
if (!fulfillTarget) return;
|
||||||
|
const user = fulfillTarget;
|
||||||
|
|
||||||
setFulfillingId(user.id);
|
setFulfillingId(user.id);
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@@ -58,6 +63,7 @@ export default function ReferralRewardsPage() {
|
|||||||
} finally {
|
} finally {
|
||||||
setFulfillingId(null);
|
setFulfillingId(null);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setFulfillTarget(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -104,6 +110,17 @@ export default function ReferralRewardsPage() {
|
|||||||
fulfillingId={fulfillingId}
|
fulfillingId={fulfillingId}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
open={!!fulfillTarget}
|
||||||
|
title="اعطای پاداش معرفی"
|
||||||
|
message={`آیا از اعطای یک ماه اشتراک رایگان به «${fulfillTarget?.name || fulfillTarget?.mobile || fulfillTarget?.email || ''}» اطمینان دارید؟`}
|
||||||
|
confirmLabel="اعطای اشتراک"
|
||||||
|
tone="primary"
|
||||||
|
isLoading={isLoading}
|
||||||
|
onConfirm={confirmFulfill}
|
||||||
|
onCancel={() => setFulfillTarget(null)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { remindersApi } from '@/lib/api/reminders';
|
|||||||
import ReminderList from '@/components/admin/reminders/ReminderList';
|
import ReminderList from '@/components/admin/reminders/ReminderList';
|
||||||
import ReminderForm from '@/components/admin/reminders/ReminderForm';
|
import ReminderForm from '@/components/admin/reminders/ReminderForm';
|
||||||
import PageHeader from '@/components/admin/PageHeader';
|
import PageHeader from '@/components/admin/PageHeader';
|
||||||
|
import ConfirmDialog from '@/components/admin/ConfirmDialog';
|
||||||
import { showToast } from '@/components/Toast';
|
import { showToast } from '@/components/Toast';
|
||||||
import { PackageName } from '@/types/package';
|
import { PackageName } from '@/types/package';
|
||||||
import { Reminder, CreateReminderData, UpdateReminderData } from '@/types/reminder';
|
import { Reminder, CreateReminderData, UpdateReminderData } from '@/types/reminder';
|
||||||
@@ -22,6 +23,7 @@ export default function RemindersPage() {
|
|||||||
const [isLoadingPackages, setIsLoadingPackages] = useState(false);
|
const [isLoadingPackages, setIsLoadingPackages] = useState(false);
|
||||||
const [isFormVisible, setIsFormVisible] = useState(false);
|
const [isFormVisible, setIsFormVisible] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [deleteTarget, setDeleteTarget] = useState<Reminder | null>(null);
|
||||||
|
|
||||||
const initialLoadRef = useRef(false);
|
const initialLoadRef = useRef(false);
|
||||||
const prevPackageRef = useRef<string | null>(null);
|
const prevPackageRef = useRef<string | null>(null);
|
||||||
@@ -94,11 +96,13 @@ export default function RemindersPage() {
|
|||||||
setIsFormVisible(true);
|
setIsFormVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async (reminder: Reminder) => {
|
const handleDelete = (reminder: Reminder) => {
|
||||||
if (!selectedPackage) return;
|
setDeleteTarget(reminder);
|
||||||
if (!confirm(`آیا از حذف یادآوری "${reminder.title}" اطمینان دارید؟`)) {
|
};
|
||||||
return;
|
|
||||||
}
|
const confirmDelete = async () => {
|
||||||
|
if (!selectedPackage || !deleteTarget) return;
|
||||||
|
const reminder = deleteTarget;
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -114,6 +118,7 @@ export default function RemindersPage() {
|
|||||||
setError(err instanceof Error ? err.message : 'خطا در حذف یادآوری');
|
setError(err instanceof Error ? err.message : 'خطا در حذف یادآوری');
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setDeleteTarget(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -226,6 +231,16 @@ export default function RemindersPage() {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
open={!!deleteTarget}
|
||||||
|
title="حذف یادآوری"
|
||||||
|
message={`آیا از حذف یادآوری «${deleteTarget?.title || ''}» اطمینان دارید؟`}
|
||||||
|
confirmLabel="حذف"
|
||||||
|
isLoading={isLoading}
|
||||||
|
onConfirm={confirmDelete}
|
||||||
|
onCancel={() => setDeleteTarget(null)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import UserEditForm from '@/components/admin/users/UserEditForm';
|
|||||||
import PackageSelector from '@/components/admin/users/PackageSelector';
|
import PackageSelector from '@/components/admin/users/PackageSelector';
|
||||||
import PageHeader from '@/components/admin/PageHeader';
|
import PageHeader from '@/components/admin/PageHeader';
|
||||||
import StepIndicator from '@/components/admin/StepIndicator';
|
import StepIndicator from '@/components/admin/StepIndicator';
|
||||||
|
import ConfirmDialog from '@/components/admin/ConfirmDialog';
|
||||||
import { showToast } from '@/components/Toast';
|
import { showToast } from '@/components/Toast';
|
||||||
import { User, Product, UpdateUserProfileData } from '@/types/user';
|
import { User, Product, UpdateUserProfileData } from '@/types/user';
|
||||||
import { PackageName } from '@/types/package';
|
import { PackageName } from '@/types/package';
|
||||||
@@ -159,7 +160,9 @@ export default function UsersPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteUser = async () => {
|
const [isDeleteConfirmOpen, setIsDeleteConfirmOpen] = useState(false);
|
||||||
|
|
||||||
|
const handleDeleteUser = () => {
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
const identifier = user.email || user.mobile;
|
const identifier = user.email || user.mobile;
|
||||||
if (!identifier) {
|
if (!identifier) {
|
||||||
@@ -167,9 +170,13 @@ export default function UsersPage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!confirm('آیا از حذف این کاربر اطمینان دارید؟ این عملیات قابل بازگشت نیست.')) {
|
setIsDeleteConfirmOpen(true);
|
||||||
return;
|
};
|
||||||
}
|
|
||||||
|
const confirmDeleteUser = async () => {
|
||||||
|
if (!user) return;
|
||||||
|
const identifier = user.email || user.mobile;
|
||||||
|
if (!identifier) return;
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -178,6 +185,7 @@ export default function UsersPage() {
|
|||||||
await usersApi.deleteUser(identifier, token!);
|
await usersApi.deleteUser(identifier, token!);
|
||||||
showToast('success', 'کاربر با موفقیت حذف شد');
|
showToast('success', 'کاربر با موفقیت حذف شد');
|
||||||
setUser(null);
|
setUser(null);
|
||||||
|
setIsDeleteConfirmOpen(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'خطا در حذف کاربر');
|
setError(err instanceof Error ? err.message : 'خطا در حذف کاربر');
|
||||||
} finally {
|
} finally {
|
||||||
@@ -324,6 +332,16 @@ export default function UsersPage() {
|
|||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
open={isDeleteConfirmOpen && !!user}
|
||||||
|
title="حذف کاربر"
|
||||||
|
message="آیا از حذف این کاربر اطمینان دارید؟ این عملیات قابل بازگشت نیست."
|
||||||
|
confirmLabel="حذف کاربر"
|
||||||
|
isLoading={isLoading}
|
||||||
|
onConfirm={confirmDeleteUser}
|
||||||
|
onCancel={() => setIsDeleteConfirmOpen(false)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-2
@@ -35,8 +35,7 @@ export default function RootLayout({
|
|||||||
/>
|
/>
|
||||||
{/* Favicon */}
|
{/* Favicon */}
|
||||||
<link rel="icon" href="/favicon.ico" sizes="any" />
|
<link rel="icon" href="/favicon.ico" sizes="any" />
|
||||||
<link rel="icon" href="/icon?<generated>" type="image/<generated>" sizes="<generated>" />
|
<link rel="icon" href="/favicon.png" type="image/png" sizes="512x512" />
|
||||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
||||||
|
|
||||||
{/* Preload critical resources */}
|
{/* Preload critical resources */}
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
|||||||
+2
-2
@@ -7,8 +7,8 @@ export default function Home() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
router.push('/admin/login');
|
router.replace('/admin/login');
|
||||||
}, [router]);
|
}, [router]);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ export default function ToastContainer() {
|
|||||||
if (toasts.length === 0) return null;
|
if (toasts.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed top-4 left-1/2 -translate-x-1/2 z-[100] flex flex-col gap-2 w-full max-w-md pointer-events-none">
|
<div className="fixed top-4 left-1/2 -translate-x-1/2 z-[100] flex flex-col gap-2 w-full max-w-md px-4 pointer-events-none">
|
||||||
{toasts.map((toast) => (
|
{toasts.map((toast) => (
|
||||||
<div
|
<div
|
||||||
key={toast.id}
|
key={toast.id}
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import { ExclamationTriangleIcon } from '@heroicons/react/24/outline';
|
||||||
|
|
||||||
|
interface ConfirmDialogProps {
|
||||||
|
open: boolean;
|
||||||
|
title: string;
|
||||||
|
message: string;
|
||||||
|
confirmLabel?: string;
|
||||||
|
cancelLabel?: string;
|
||||||
|
tone?: 'danger' | 'primary';
|
||||||
|
isLoading?: boolean;
|
||||||
|
onConfirm: () => void;
|
||||||
|
onCancel: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Styled replacement for the native confirm() dialog so destructive actions
|
||||||
|
// match the rest of the panel.
|
||||||
|
export default function ConfirmDialog({
|
||||||
|
open,
|
||||||
|
title,
|
||||||
|
message,
|
||||||
|
confirmLabel = 'تأیید',
|
||||||
|
cancelLabel = 'انصراف',
|
||||||
|
tone = 'danger',
|
||||||
|
isLoading = false,
|
||||||
|
onConfirm,
|
||||||
|
onCancel,
|
||||||
|
}: ConfirmDialogProps) {
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return;
|
||||||
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === 'Escape' && !isLoading) onCancel();
|
||||||
|
};
|
||||||
|
document.addEventListener('keydown', handleKeyDown);
|
||||||
|
return () => document.removeEventListener('keydown', handleKeyDown);
|
||||||
|
}, [open, isLoading, onCancel]);
|
||||||
|
|
||||||
|
if (!open) return null;
|
||||||
|
|
||||||
|
const confirmClass =
|
||||||
|
tone === 'danger'
|
||||||
|
? 'bg-red-600 hover:bg-red-700 focus:ring-red-500/30 shadow-red-500/20'
|
||||||
|
: 'bg-indigo-600 hover:bg-indigo-700 focus:ring-indigo-500/30 shadow-indigo-500/20';
|
||||||
|
const iconWrapClass =
|
||||||
|
tone === 'danger'
|
||||||
|
? 'bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400'
|
||||||
|
: 'bg-indigo-50 text-indigo-600 dark:bg-indigo-500/10 dark:text-indigo-400';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 dark:bg-black/60 p-4"
|
||||||
|
onClick={() => {
|
||||||
|
if (!isLoading) onCancel();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="bg-white dark:bg-gray-900 rounded-2xl shadow-xl ring-1 ring-gray-200 dark:ring-gray-800 w-full max-w-md"
|
||||||
|
dir="rtl"
|
||||||
|
onClick={(event) => event.stopPropagation()}
|
||||||
|
role="alertdialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label={title}
|
||||||
|
>
|
||||||
|
<div className="px-6 py-5 flex items-start gap-4">
|
||||||
|
<div className={`flex-shrink-0 h-11 w-11 rounded-xl flex items-center justify-center ${iconWrapClass}`}>
|
||||||
|
<ExclamationTriangleIcon className="h-6 w-6" />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<h3 className="text-base font-semibold text-gray-900 dark:text-gray-100">{title}</h3>
|
||||||
|
<p className="mt-1.5 text-sm text-gray-500 dark:text-gray-400 leading-6">{message}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-end gap-3 px-6 py-4 border-t border-gray-100 dark:border-gray-800">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onCancel}
|
||||||
|
disabled={isLoading}
|
||||||
|
className="px-5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-700 text-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 transition-colors"
|
||||||
|
>
|
||||||
|
{cancelLabel}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onConfirm}
|
||||||
|
disabled={isLoading}
|
||||||
|
className={`inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-white text-sm font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-900 disabled:opacity-50 transition-colors shadow-sm ${confirmClass}`}
|
||||||
|
>
|
||||||
|
{isLoading && (
|
||||||
|
<span className="h-4 w-4 border-2 border-white/40 border-t-white rounded-full animate-spin" />
|
||||||
|
)}
|
||||||
|
{isLoading ? 'در حال انجام...' : confirmLabel}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -139,7 +139,7 @@ export default function PersianDatePicker({
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
{open && (
|
{open && (
|
||||||
<div className="absolute right-0 z-50 mt-2 bg-white dark:bg-gray-900 ring-1 ring-gray-200 dark:ring-gray-800 rounded-2xl shadow-xl p-2">
|
<div className="absolute right-0 z-50 mt-2 bg-white dark:bg-gray-900 ring-1 ring-gray-200 dark:ring-gray-800 rounded-2xl shadow-xl p-2 max-w-[calc(100vw-3rem)] overflow-x-auto">
|
||||||
<DayPicker
|
<DayPicker
|
||||||
mode="single"
|
mode="single"
|
||||||
selected={selectedDate ?? undefined}
|
selected={selectedDate ?? undefined}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export default function StepIndicator({ steps }: StepIndicatorProps) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span
|
<span
|
||||||
className={`mt-1.5 text-xs font-medium whitespace-nowrap ${
|
className={`mt-1.5 text-[10px] sm:text-xs font-medium whitespace-nowrap ${
|
||||||
step.isCurrent
|
step.isCurrent
|
||||||
? 'text-indigo-700 dark:text-indigo-400'
|
? 'text-indigo-700 dark:text-indigo-400'
|
||||||
: step.isCompleted
|
: step.isCompleted
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ class ApiClient {
|
|||||||
|
|
||||||
// Check if there's already a pending request with the same key
|
// Check if there's already a pending request with the same key
|
||||||
if (pendingRequests.has(requestKey)) {
|
if (pendingRequests.has(requestKey)) {
|
||||||
console.log('Deduplicating request:', endpoint);
|
|
||||||
return pendingRequests.get(requestKey);
|
return pendingRequests.get(requestKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ const buildPurchaseQuery = (filters: PurchaseFilters): string => {
|
|||||||
if (filters.product_id !== undefined && filters.product_id !== null) {
|
if (filters.product_id !== undefined && filters.product_id !== null) {
|
||||||
params.append('product_id', String(filters.product_id));
|
params.append('product_id', String(filters.product_id));
|
||||||
}
|
}
|
||||||
|
if (filters.date_from) params.append('date_from', filters.date_from);
|
||||||
|
if (filters.date_to) params.append('date_to', filters.date_to);
|
||||||
|
if (filters.time_from) params.append('time_from', filters.time_from);
|
||||||
|
if (filters.time_to) params.append('time_to', filters.time_to);
|
||||||
if (filters.per_page) params.append('per_page', String(filters.per_page));
|
if (filters.per_page) params.append('per_page', String(filters.per_page));
|
||||||
if (filters.page) params.append('page', String(filters.page));
|
if (filters.page) params.append('page', String(filters.page));
|
||||||
|
|
||||||
|
|||||||
Generated
+13
@@ -74,6 +74,7 @@
|
|||||||
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
|
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.27.1",
|
"@babel/code-frame": "^7.27.1",
|
||||||
"@babel/generator": "^7.28.5",
|
"@babel/generator": "^7.28.5",
|
||||||
@@ -1610,6 +1611,7 @@
|
|||||||
"integrity": "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA==",
|
"integrity": "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csstype": "^3.0.2"
|
"csstype": "^3.0.2"
|
||||||
}
|
}
|
||||||
@@ -1670,6 +1672,7 @@
|
|||||||
"integrity": "sha512-6m1I5RmHBGTnUGS113G04DMu3CpSdxCAU/UvtjNWL4Nuf3MW9tQhiJqRlHzChIkhy6kZSAQmc+I1bcGjE3yNKg==",
|
"integrity": "sha512-6m1I5RmHBGTnUGS113G04DMu3CpSdxCAU/UvtjNWL4Nuf3MW9tQhiJqRlHzChIkhy6kZSAQmc+I1bcGjE3yNKg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "8.46.3",
|
"@typescript-eslint/scope-manager": "8.46.3",
|
||||||
"@typescript-eslint/types": "8.46.3",
|
"@typescript-eslint/types": "8.46.3",
|
||||||
@@ -2200,6 +2203,7 @@
|
|||||||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@@ -2578,6 +2582,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"baseline-browser-mapping": "^2.9.0",
|
"baseline-browser-mapping": "^2.9.0",
|
||||||
"caniuse-lite": "^1.0.30001759",
|
"caniuse-lite": "^1.0.30001759",
|
||||||
@@ -3161,6 +3166,7 @@
|
|||||||
"integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==",
|
"integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/eslint-utils": "^4.8.0",
|
"@eslint-community/eslint-utils": "^4.8.0",
|
||||||
"@eslint-community/regexpp": "^4.12.1",
|
"@eslint-community/regexpp": "^4.12.1",
|
||||||
@@ -3346,6 +3352,7 @@
|
|||||||
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
|
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rtsao/scc": "^1.1.0",
|
"@rtsao/scc": "^1.1.0",
|
||||||
"array-includes": "^3.1.9",
|
"array-includes": "^3.1.9",
|
||||||
@@ -5522,6 +5529,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nanoid": "^3.3.11",
|
"nanoid": "^3.3.11",
|
||||||
"picocolors": "^1.1.1",
|
"picocolors": "^1.1.1",
|
||||||
@@ -5596,6 +5604,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-19.2.0.tgz",
|
||||||
"integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==",
|
"integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
@@ -5631,6 +5640,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.0.tgz",
|
||||||
"integrity": "sha512-UlbRu4cAiGaIewkPyiRGJk0imDN2T3JjieT6spoL2UeSf5od4n5LB/mQ4ejmxhCFT1tYe8IvaFulzynWovsEFQ==",
|
"integrity": "sha512-UlbRu4cAiGaIewkPyiRGJk0imDN2T3JjieT6spoL2UeSf5od4n5LB/mQ4ejmxhCFT1tYe8IvaFulzynWovsEFQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"scheduler": "^0.27.0"
|
"scheduler": "^0.27.0"
|
||||||
},
|
},
|
||||||
@@ -6317,6 +6327,7 @@
|
|||||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
@@ -6479,6 +6490,7 @@
|
|||||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
@@ -6754,6 +6766,7 @@
|
|||||||
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
|
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/colinhacks"
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ export interface PurchaseFilters {
|
|||||||
gateway?: string; // gateway name key (e.g. "zarinpal")
|
gateway?: string; // gateway name key (e.g. "zarinpal")
|
||||||
status?: number;
|
status?: number;
|
||||||
product_id?: number; // filter by a specific product
|
product_id?: number; // filter by a specific product
|
||||||
|
// Date/time window on created_at (Y-m-d dates, H:i(:s) times, Tehran-local —
|
||||||
|
// same values the accounting filters use). Times only apply with their date.
|
||||||
|
date_from?: string;
|
||||||
|
date_to?: string;
|
||||||
|
time_from?: string;
|
||||||
|
time_to?: string;
|
||||||
per_page?: number;
|
per_page?: number;
|
||||||
page?: number;
|
page?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user