feat: response in mobile and accouting

This commit is contained in:
2026-08-17 07:44:00 +03:30
parent e3071b8692
commit 90a66031bd
20 changed files with 556 additions and 114 deletions
+21 -4
View File
@@ -5,6 +5,7 @@ import { useAuth } from '@/contexts/AuthContext';
import { referralApi } from '@/lib/api/referral';
import ReferralList from '@/components/admin/referral/ReferralList';
import PageHeader from '@/components/admin/PageHeader';
import ConfirmDialog from '@/components/admin/ConfirmDialog';
import { showToast } from '@/components/Toast';
import { ReferralRewardUser } from '@/types/referral';
import { ArrowPathIcon } from '@heroicons/react/24/outline';
@@ -16,6 +17,7 @@ export default function ReferralRewardsPage() {
const [isLoading, setIsLoading] = useState(false);
const [fulfillingId, setFulfillingId] = useState<number | null>(null);
const [error, setError] = useState<string | null>(null);
const [fulfillTarget, setFulfillTarget] = useState<ReferralRewardUser | null>(null);
const initialLoadRef = useRef(false);
@@ -40,10 +42,13 @@ export default function ReferralRewardsPage() {
}
};
const handleFulfill = async (user: ReferralRewardUser) => {
if (!confirm(`آیا از اعطای یک ماه اشتراک رایگان به «${user.name || user.mobile || user.email}» اطمینان دارید؟`)) {
return;
}
const handleFulfill = (user: ReferralRewardUser) => {
setFulfillTarget(user);
};
const confirmFulfill = async () => {
if (!fulfillTarget) return;
const user = fulfillTarget;
setFulfillingId(user.id);
setIsLoading(true);
@@ -58,6 +63,7 @@ export default function ReferralRewardsPage() {
} finally {
setFulfillingId(null);
setIsLoading(false);
setFulfillTarget(null);
}
};
@@ -104,6 +110,17 @@ export default function ReferralRewardsPage() {
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>
);