feat: response in mobile and accouting
This commit is contained in:
@@ -6,6 +6,7 @@ import { promotionsApi } from '@/lib/api/promotions';
|
||||
import PromotionList from '@/components/admin/promotions/PromotionList';
|
||||
import PromotionForm from '@/components/admin/promotions/PromotionForm';
|
||||
import PageHeader from '@/components/admin/PageHeader';
|
||||
import ConfirmDialog from '@/components/admin/ConfirmDialog';
|
||||
import { showToast } from '@/components/Toast';
|
||||
import { Promotion, CreatePromotionData, UpdatePromotionData } from '@/types/promotion';
|
||||
import { PlusIcon } from '@heroicons/react/24/outline';
|
||||
@@ -17,6 +18,7 @@ export default function PromotionsPage() {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isFormVisible, setIsFormVisible] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [deleteTarget, setDeleteTarget] = useState<Promotion | null>(null);
|
||||
|
||||
const initialLoadRef = useRef(false);
|
||||
|
||||
@@ -50,10 +52,13 @@ export default function PromotionsPage() {
|
||||
setIsFormVisible(true);
|
||||
};
|
||||
|
||||
const handleDelete = async (promotion: Promotion) => {
|
||||
if (!confirm(`آیا از حذف تبلیغ "${promotion.title || 'بدون عنوان'}" اطمینان دارید؟`)) {
|
||||
return;
|
||||
}
|
||||
const handleDelete = (promotion: Promotion) => {
|
||||
setDeleteTarget(promotion);
|
||||
};
|
||||
|
||||
const confirmDelete = async () => {
|
||||
if (!deleteTarget) return;
|
||||
const promotion = deleteTarget;
|
||||
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
@@ -66,6 +71,7 @@ export default function PromotionsPage() {
|
||||
setError(err instanceof Error ? err.message : 'خطا در حذف تبلیغ');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
setDeleteTarget(null);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -159,6 +165,16 @@ export default function PromotionsPage() {
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
)}
|
||||
|
||||
<ConfirmDialog
|
||||
open={!!deleteTarget}
|
||||
title="حذف تبلیغ"
|
||||
message={`آیا از حذف تبلیغ «${deleteTarget?.title || 'بدون عنوان'}» اطمینان دارید؟`}
|
||||
confirmLabel="حذف"
|
||||
isLoading={isLoading}
|
||||
onConfirm={confirmDelete}
|
||||
onCancel={() => setDeleteTarget(null)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user