mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-09-14 00:33:10 +00:00
feat(branding): загрузка видео стартового меню бота
Парная фронтовая часть к /cabinet/branding/bot-start-video (бот: 524960c3). В «Брендинге» появилась карточка: загрузить/заменить/удалить видео, которое бот прикрепляет к сообщению /start вместо картинки-логотипа, и статус текущего состояния. Файл разово уходит в Telegram ради file_id — на нашей стороне не хранится. Видео в рассылках уже работало (кнопка в боте, загрузка в кабинете, доставка send_video) и не затронуто. Локали ru/en/zh/fa.
This commit is contained in:
@@ -15,6 +15,7 @@ export function BrandingTab({ accentColor = '#3b82f6' }: BrandingTabProps) {
|
||||
const { t } = useTranslation();
|
||||
const queryClient = useQueryClient();
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const startVideoInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const [editingName, setEditingName] = useState(false);
|
||||
const [newName, setNewName] = useState('');
|
||||
@@ -25,6 +26,12 @@ export function BrandingTab({ accentColor = '#3b82f6' }: BrandingTabProps) {
|
||||
queryFn: brandingApi.getBranding,
|
||||
});
|
||||
|
||||
// Видео стартового меню бота: хранится как Telegram file_id
|
||||
const { data: startVideo } = useQuery({
|
||||
queryKey: ['bot-start-video'],
|
||||
queryFn: brandingApi.getBotStartVideo,
|
||||
});
|
||||
|
||||
const { data: fullscreenSettings } = useQuery({
|
||||
queryKey: ['fullscreen-enabled'],
|
||||
queryFn: brandingApi.getFullscreenEnabled,
|
||||
@@ -100,6 +107,29 @@ export function BrandingTab({ accentColor = '#3b82f6' }: BrandingTabProps) {
|
||||
},
|
||||
});
|
||||
|
||||
const uploadStartVideoMutation = useMutation({
|
||||
mutationFn: brandingApi.uploadBotStartVideo,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['bot-start-video'] });
|
||||
},
|
||||
});
|
||||
|
||||
const deleteStartVideoMutation = useMutation({
|
||||
mutationFn: brandingApi.deleteBotStartVideo,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['bot-start-video'] });
|
||||
},
|
||||
});
|
||||
|
||||
const handleStartVideoUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (file) {
|
||||
uploadStartVideoMutation.mutate(file);
|
||||
}
|
||||
// Сбрасываем input, чтобы повторный выбор того же файла снова сработал
|
||||
e.target.value = '';
|
||||
};
|
||||
|
||||
const handleLogoUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (file) {
|
||||
@@ -211,6 +241,57 @@ export function BrandingTab({ accentColor = '#3b82f6' }: BrandingTabProps) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Видео стартового меню бота */}
|
||||
<div className="rounded-2xl border border-dark-700/50 bg-dark-800/50 p-6">
|
||||
<h3 className="mb-1 text-lg font-semibold text-dark-100">
|
||||
{t('admin.settings.botStartVideo')}
|
||||
</h3>
|
||||
<p className="mb-4 text-sm text-dark-400">{t('admin.settings.botStartVideoDesc')}</p>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<input
|
||||
ref={startVideoInputRef}
|
||||
type="file"
|
||||
accept="video/*"
|
||||
onChange={handleStartVideoUpload}
|
||||
className="hidden"
|
||||
/>
|
||||
<button
|
||||
onClick={() => startVideoInputRef.current?.click()}
|
||||
disabled={uploadStartVideoMutation.isPending}
|
||||
className="rounded-xl bg-dark-700 px-4 py-2 text-sm text-dark-200 transition-colors hover:bg-dark-600 disabled:opacity-50"
|
||||
>
|
||||
{uploadStartVideoMutation.isPending
|
||||
? t('common.loading')
|
||||
: startVideo?.has_video
|
||||
? t('admin.settings.botStartVideoReplace')
|
||||
: t('admin.settings.botStartVideoUpload')}
|
||||
</button>
|
||||
|
||||
{startVideo?.has_video && (
|
||||
<button
|
||||
onClick={() => deleteStartVideoMutation.mutate()}
|
||||
disabled={deleteStartVideoMutation.isPending}
|
||||
className="rounded-xl bg-dark-700 px-4 py-2 text-sm text-dark-400 transition-colors hover:bg-error-500/20 hover:text-error-400 disabled:opacity-50"
|
||||
>
|
||||
{t('admin.settings.botStartVideoRemove')}
|
||||
</button>
|
||||
)}
|
||||
|
||||
<span className="text-sm text-dark-400">
|
||||
{startVideo?.has_video
|
||||
? t('admin.settings.botStartVideoActive')
|
||||
: t('admin.settings.botStartVideoNone')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{uploadStartVideoMutation.isError && (
|
||||
<div className="mt-3 text-sm text-error-400">
|
||||
{t('admin.settings.botStartVideoError')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Animated Background Editor */}
|
||||
<div className="rounded-2xl border border-dark-700/50 bg-dark-800/50 p-6">
|
||||
<BackgroundEditor />
|
||||
|
||||
Reference in New Issue
Block a user