mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
feat: show affected subscriptions count on tariff deletion
Update delete mutation to use affected_subscriptions from API response. Show contextual success notification with subscription count. Add deleteSuccessWithSubscriptions translation key in all 4 locales.
This commit is contained in:
@@ -208,7 +208,9 @@ export const tariffsApi = {
|
||||
},
|
||||
|
||||
// Delete tariff
|
||||
deleteTariff: async (tariffId: number): Promise<{ message: string }> => {
|
||||
deleteTariff: async (
|
||||
tariffId: number,
|
||||
): Promise<{ message: string; affected_subscriptions: number }> => {
|
||||
const response = await apiClient.delete(`/cabinet/admin/tariffs/${tariffId}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -1370,6 +1370,7 @@
|
||||
"confirmDeleteText": "This action cannot be undone. The tariff will be permanently deleted.",
|
||||
"confirmDeleteWithSubscriptions": "This tariff has {{count}} active subscriptions. After deletion, users will need to select a new tariff when renewing.",
|
||||
"deleteSuccess": "Tariff deleted successfully",
|
||||
"deleteSuccessWithSubscriptions": "Tariff deleted. {{count}} subscriptions reset — users will choose a new tariff on renewal.",
|
||||
"saveOrder": "Save order",
|
||||
"orderSaved": "Order saved",
|
||||
"dragToReorder": "Drag to reorder",
|
||||
|
||||
@@ -1076,6 +1076,7 @@
|
||||
"confirmDeleteText": "این عمل قابل بازگشت نیست. تعرفه برای همیشه حذف میشود.",
|
||||
"confirmDeleteWithSubscriptions": "این تعرفه {{count}} اشتراک فعال دارد. پس از حذف، کاربران هنگام تمدید باید تعرفه جدید انتخاب کنند.",
|
||||
"deleteSuccess": "تعرفه با موفقیت حذف شد",
|
||||
"deleteSuccessWithSubscriptions": "تعرفه حذف شد. تعرفه {{count}} اشتراک بازنشانی شد — کاربران هنگام تمدید تعرفه جدید انتخاب میکنند.",
|
||||
"saveOrder": "ذخیره ترتیب",
|
||||
"orderSaved": "ترتیب ذخیره شد",
|
||||
"dragToReorder": "برای تغییر ترتیب بکشید",
|
||||
|
||||
@@ -1888,6 +1888,7 @@
|
||||
"confirmDeleteText": "Это действие нельзя отменить. Тариф будет удалён навсегда.",
|
||||
"confirmDeleteWithSubscriptions": "У этого тарифа {{count}} активных подписок. При удалении пользователям потребуется выбрать новый тариф при продлении.",
|
||||
"deleteSuccess": "Тариф успешно удален",
|
||||
"deleteSuccessWithSubscriptions": "Тариф удален. У {{count}} подписок сброшен тариф — при продлении пользователи выберут новый.",
|
||||
"saveOrder": "Сохранить порядок",
|
||||
"orderSaved": "Порядок сохранён",
|
||||
"dragToReorder": "Перетащите для изменения порядка",
|
||||
|
||||
@@ -1114,6 +1114,7 @@
|
||||
"confirmDeleteText": "此操作不可撤销。套餐将被永久删除。",
|
||||
"confirmDeleteWithSubscriptions": "此套餐有 {{count}} 个活跃订阅。删除后,用户续订时需要选择新套餐。",
|
||||
"deleteSuccess": "套餐删除成功",
|
||||
"deleteSuccessWithSubscriptions": "套餐已删除。{{count}} 个订阅已重置 — 用户续订时将选择新套餐。",
|
||||
"saveOrder": "保存排序",
|
||||
"orderSaved": "排序已保存",
|
||||
"dragToReorder": "拖动以重新排序",
|
||||
|
||||
@@ -282,9 +282,15 @@ export default function AdminTariffs() {
|
||||
// Mutations
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: tariffsApi.deleteTariff,
|
||||
onSuccess: () => {
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['admin-tariffs'] });
|
||||
notify.success(t('admin.tariffs.deleteSuccess'));
|
||||
if (data.affected_subscriptions > 0) {
|
||||
notify.success(
|
||||
t('admin.tariffs.deleteSuccessWithSubscriptions', { count: data.affected_subscriptions }),
|
||||
);
|
||||
} else {
|
||||
notify.success(t('admin.tariffs.deleteSuccess'));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user