mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
feat: add reset traffic toggle on tariff switch
- Add reset_traffic parameter to previewTariffSwitch and switchTariff API calls - Add reset_traffic_available/reset_traffic_default fields to TariffSwitchPreview type - Add toggle switch in tariff switch preview modal (shown when backend enables it) - Initialize toggle from server default (reset_traffic_default) - Pass reset_traffic flag on switch execution - Add translations for all 4 locales (ru, en, zh, fa)
This commit is contained in:
@@ -345,6 +345,7 @@ export const subscriptionApi = {
|
||||
// Preview tariff switch cost
|
||||
previewTariffSwitch: async (
|
||||
tariffId: number,
|
||||
resetTraffic?: boolean,
|
||||
): Promise<{
|
||||
can_switch: boolean;
|
||||
current_tariff_id: number | null;
|
||||
@@ -364,10 +365,14 @@ export const subscriptionApi = {
|
||||
base_upgrade_cost_kopeks?: number;
|
||||
discount_percent?: number;
|
||||
discount_kopeks?: number;
|
||||
// Traffic reset on switch
|
||||
reset_traffic_available?: boolean;
|
||||
reset_traffic_default?: boolean;
|
||||
}> => {
|
||||
const response = await apiClient.post('/cabinet/subscription/tariff/switch/preview', {
|
||||
tariff_id: tariffId,
|
||||
period_days: 30, // Default period for switch
|
||||
period_days: 30,
|
||||
...(resetTraffic !== undefined && { reset_traffic: resetTraffic }),
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
@@ -375,6 +380,7 @@ export const subscriptionApi = {
|
||||
// Switch to a different tariff
|
||||
switchTariff: async (
|
||||
tariffId: number,
|
||||
resetTraffic?: boolean,
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
message: string;
|
||||
@@ -389,6 +395,7 @@ export const subscriptionApi = {
|
||||
const response = await apiClient.post('/cabinet/subscription/tariff/switch', {
|
||||
tariff_id: tariffId,
|
||||
period_days: 30,
|
||||
...(resetTraffic !== undefined && { reset_traffic: resetTraffic }),
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user