mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
feat: add gift subscription toggle to admin branding settings
Add CABINET_GIFT_ENABLED toggle in Admin Settings > Branding > Interface Options, alongside existing fullscreen and email auth toggles. Includes updateGiftEnabled API method and i18n keys for all 4 locales (ru/en/zh/fa).
This commit is contained in:
@@ -265,6 +265,14 @@ export const brandingApi = {
|
||||
}
|
||||
},
|
||||
|
||||
// Update gift enabled (admin only)
|
||||
updateGiftEnabled: async (enabled: boolean): Promise<GiftEnabled> => {
|
||||
const response = await apiClient.patch<GiftEnabled>('/cabinet/branding/gift-enabled', {
|
||||
enabled,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Get analytics counters (public, no auth required)
|
||||
getAnalyticsCounters: async (): Promise<AnalyticsCounters> => {
|
||||
try {
|
||||
|
||||
@@ -35,6 +35,11 @@ export function BrandingTab({ accentColor = '#3b82f6' }: BrandingTabProps) {
|
||||
queryFn: brandingApi.getEmailAuthEnabled,
|
||||
});
|
||||
|
||||
const { data: giftSettings } = useQuery({
|
||||
queryKey: ['gift-enabled'],
|
||||
queryFn: brandingApi.getGiftEnabled,
|
||||
});
|
||||
|
||||
// Mutations
|
||||
const updateBrandingMutation = useMutation({
|
||||
mutationFn: brandingApi.updateName,
|
||||
@@ -76,6 +81,13 @@ export function BrandingTab({ accentColor = '#3b82f6' }: BrandingTabProps) {
|
||||
},
|
||||
});
|
||||
|
||||
const updateGiftMutation = useMutation({
|
||||
mutationFn: (enabled: boolean) => brandingApi.updateGiftEnabled(enabled),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['gift-enabled'] });
|
||||
},
|
||||
});
|
||||
|
||||
const handleLogoUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (file) {
|
||||
@@ -225,6 +237,18 @@ export function BrandingTab({ accentColor = '#3b82f6' }: BrandingTabProps) {
|
||||
disabled={updateEmailAuthMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between rounded-xl bg-dark-700/30 p-4">
|
||||
<div>
|
||||
<span className="font-medium text-dark-100">{t('admin.settings.giftEnabled')}</span>
|
||||
<p className="text-sm text-dark-400">{t('admin.settings.giftEnabledDesc')}</p>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={giftSettings?.enabled ?? false}
|
||||
onChange={() => updateGiftMutation.mutate(!(giftSettings?.enabled ?? false))}
|
||||
disabled={updateGiftMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1696,6 +1696,8 @@
|
||||
"darkTheme": "Dark theme",
|
||||
"emailAuth": "Email auth",
|
||||
"emailAuthDesc": "Allow login via email",
|
||||
"giftEnabled": "Gift subscription",
|
||||
"giftEnabledDesc": "Allow users to gift a subscription to another user",
|
||||
"favoritesEmpty": "No favorites yet",
|
||||
"favoritesHint": "Star settings to add them here",
|
||||
"interfaceOptions": "Interface options",
|
||||
|
||||
@@ -1367,6 +1367,8 @@
|
||||
"darkTheme": "پوسته تیره",
|
||||
"emailAuth": "احراز هویت ایمیل",
|
||||
"emailAuthDesc": "اجازه ورود با ایمیل",
|
||||
"giftEnabled": "اشتراک هدیه",
|
||||
"giftEnabledDesc": "امکان ارسال اشتراک به عنوان هدیه به کاربر دیگر",
|
||||
"favoritesEmpty": "هنوز علاقهمندی ندارید",
|
||||
"favoritesHint": "ستاره بزنید تا تنظیمات اینجا اضافه شوند",
|
||||
"interfaceOptions": "گزینههای رابط کاربری",
|
||||
|
||||
@@ -1706,6 +1706,8 @@
|
||||
"autoFullscreenDesc": "В Telegram WebApp",
|
||||
"emailAuth": "Email авторизация",
|
||||
"emailAuthDesc": "Регистрация и вход через email",
|
||||
"giftEnabled": "Подписка в подарок",
|
||||
"giftEnabledDesc": "Возможность отправить подписку в подарок другому пользователю",
|
||||
"availableThemes": "Доступные темы",
|
||||
"darkTheme": "Тёмная",
|
||||
"lightTheme": "Светлая",
|
||||
|
||||
@@ -1405,6 +1405,8 @@
|
||||
"darkTheme": "暗色主题",
|
||||
"emailAuth": "邮箱认证",
|
||||
"emailAuthDesc": "允许通过邮箱登录",
|
||||
"giftEnabled": "赠送订阅",
|
||||
"giftEnabledDesc": "允许用户将订阅作为礼物赠送给其他用户",
|
||||
"favoritesEmpty": "暂无收藏",
|
||||
"favoritesHint": "点击星标将设置添加到这里",
|
||||
"interfaceOptions": "界面选项",
|
||||
|
||||
Reference in New Issue
Block a user