+
+
+
{userName ? (
-
-
-
-
-
-
- {userName}
-
-
+
+
+
{userName}
+
) : (
Вход
diff --git a/src/components/SettingsContent.tsx b/src/components/SettingsContent.tsx
index ba47d17..93deaba 100644
--- a/src/components/SettingsContent.tsx
+++ b/src/components/SettingsContent.tsx
@@ -1,108 +1,50 @@
"use client";
+import { useState, useEffect } from 'react';
import { useSettings } from '@/hooks/useSettings';
-import styled from 'styled-components';
-import { useRouter } from 'next/navigation';
-
-const Container = styled.div`
- width: 100%;
- max-width: 800px;
- padding: 0 1rem;
-`;
-
-const Title = styled.h1`
- font-size: 1.5rem;
- font-weight: bold;
- margin-bottom: 2rem;
- color: white;
-`;
-
-const PlayersList = styled.div`
- display: flex;
- flex-direction: column;
- gap: 1rem;
- width: 100%;
-`;
-
-const PlayerCard = styled.div<{ $isSelected: boolean }>`
- background: rgba(255, 255, 255, 0.1);
- border-radius: 0.5rem;
- padding: 1rem;
- cursor: pointer;
- transition: all 0.2s;
- border: 2px solid ${props => props.$isSelected ? '#2196f3' : 'transparent'};
-
- &:hover {
- background: rgba(255, 255, 255, 0.15);
- }
-`;
-
-const PlayerName = styled.h2`
- font-size: 1.125rem;
- font-weight: 600;
- margin-bottom: 0.5rem;
- color: white;
-`;
-
-const PlayerDescription = styled.p`
- color: rgba(255, 255, 255, 0.7);
- font-size: 0.875rem;
-`;
-
-const SaveButton = styled.button`
- margin-top: 1rem;
- padding: 0.75rem 1.5rem;
- background: #2196f3;
- color: white;
- border: none;
- border-radius: 0.5rem;
- font-weight: 500;
- cursor: pointer;
- transition: background 0.2s;
-
- &:hover {
- background: #1976d2;
- }
-`;
export default function SettingsContent() {
const { settings, updateSettings } = useSettings();
- const router = useRouter();
-
+
const players = [
{
id: 'alloha',
name: 'Alloha',
- description: 'Основной плеер с высоким качеством',
+ description: 'Основной плеер с высоким качеством и быстрой загрузкой.',
},
{
id: 'lumex',
name: 'Lumex',
- description: 'Плеер с возможностью скачивания фильмов',
+ description: 'Альтернативный плеер, может быть полезен при проблемах с основным.',
},
];
const handlePlayerSelect = (playerId: string) => {
updateSettings({ defaultPlayer: playerId as 'alloha' | 'lumex' });
- // Возвращаемся на предыдущую страницу
- window.history.back();
};
return (
-
- Настройки плеера
-
- {players.map((player) => (
- handlePlayerSelect(player.id)}
- >
- {player.name}
- {player.description}
-
- ))}
-
-
+
+
+
Настройки плеера
+
Выберите плеер, который будет использоваться по умолчанию для просмотра.
+
+ {players.map((player) => (
+
handlePlayerSelect(player.id)}
+ className={`rounded-lg p-4 cursor-pointer border-2 transition-all ${
+ settings.defaultPlayer === player.id
+ ? 'border-accent bg-accent/10'
+ : 'border-warm-200 dark:border-warm-700 bg-white dark:bg-warm-800 hover:border-accent/50'
+ }`}
+ >
+
{player.name}
+
{player.description}
+
+ ))}
+
+
+
);
}
diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts
index 3ab6109..dccf6fe 100644
--- a/src/hooks/useAuth.ts
+++ b/src/hooks/useAuth.ts
@@ -21,7 +21,6 @@ export function useAuth() {
localStorage.setItem('token', data.token);
// Extract name/email either from API response or JWT payload
- // Пытаемся достать имя/почту из JWT либо из ответа
let name: string | undefined = undefined;
let email: string | undefined = undefined;
try {
@@ -31,14 +30,12 @@ export function useAuth() {
} catch {
// silent
}
- // fallback к полям ответа
if (!name) name = data.user?.name || data.name || data.userName;
if (!email) email = data.user?.email || data.email;
if (name) localStorage.setItem('userName', name);
if (email) localStorage.setItem('userEmail', email);
- // уведомляем другие компоненты о смене авторизации
if (typeof window !== 'undefined') {
window.dispatchEvent(new Event('auth-changed'));
}
@@ -52,16 +49,34 @@ export function useAuth() {
const register = async (email: string, password: string, name: string) => {
await authAPI.register({ email, password, name });
- await authAPI.resendCode(email);
+ const pendingData = { email, password, name };
+ if (typeof window !== 'undefined') {
+ localStorage.setItem('pendingVerification', JSON.stringify(pendingData));
+ }
setIsVerifying(true);
- setPending({ email, password, name });
+ setPending(pendingData);
};
const verifyCode = async (code: string) => {
- if (!pending) throw new Error('no pending');
- await authAPI.verify(pending.email, code);
- // auto login
- await login(pending.email, pending.password);
+ let pendingData = pending;
+ if (!pendingData && typeof window !== 'undefined') {
+ const storedPending = localStorage.getItem('pendingVerification');
+ if (storedPending) {
+ pendingData = JSON.parse(storedPending);
+ setPending(pendingData);
+ }
+ }
+
+ if (!pendingData) {
+ throw new Error('Сессия подтверждения истекла. Пожалуйста, попробуйте зарегистрироваться снова.');
+ }
+
+ await authAPI.verify(pendingData.email, code);
+ await login(pendingData.email, pendingData.password);
+
+ if (typeof window !== 'undefined') {
+ localStorage.removeItem('pendingVerification');
+ }
setIsVerifying(false);
setPending(null);
};
diff --git a/src/hooks/useMovies.ts b/src/hooks/useMovies.ts
index a969335..e242cb2 100644
--- a/src/hooks/useMovies.ts
+++ b/src/hooks/useMovies.ts
@@ -53,11 +53,6 @@ export function useMovies({ initialPage = 1, category = 'popular' }: UseMoviesPr
fetchMovies(page, category);
}, [page, category, fetchMovies]);
- // Сбрасываем страницу на 1 при смене категории
- useEffect(() => {
- setPage(1);
- }, [category]);
-
const handlePageChange = useCallback((newPage: number) => {
if (newPage < 1 || newPage > totalPages) return;
setPage(newPage);
diff --git a/src/lib/authApi.ts b/src/lib/authApi.ts
index a8ec941..92175e0 100644
--- a/src/lib/authApi.ts
+++ b/src/lib/authApi.ts
@@ -8,7 +8,7 @@ export const authAPI = {
return api.post('/auth/resend-code', { email });
},
verify(email: string, code: string) {
- return api.put('/auth/verify', { email, code });
+ return api.post('/auth/verify', { email, code });
},
login(email: string, password: string) {
return api.post('/auth/login', { email, password });
diff --git a/src/lib/favoritesApi.ts b/src/lib/favoritesApi.ts
index 369cecc..791ed5d 100644
--- a/src/lib/favoritesApi.ts
+++ b/src/lib/favoritesApi.ts
@@ -9,7 +9,8 @@ export const favoritesAPI = {
// Добавить в избранное
addFavorite(data: { mediaId: string; mediaType: 'movie' | 'tv', title: string, posterPath: string }) {
- return api.post(`/favorites`, data);
+ const { mediaId, mediaType, title, posterPath } = data;
+ return api.post(`/favorites/${mediaId}?mediaType=${mediaType}`, { title, posterPath });
},
// Удалить из избранного