From ee31b639b2448351cffc87c96b5f0d73ab752a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Fri, 19 Dec 2025 20:41:46 +0300 Subject: [PATCH] make my shit work --- next.config.ts | 6 ++-- src/hooks/useApiClient.ts | 62 +++++++++++++++++++-------------------- src/lib/utils.ts | 22 +++++++++----- 3 files changed, 48 insertions(+), 42 deletions(-) diff --git a/next.config.ts b/next.config.ts index 1df80fa..4eed48d 100644 --- a/next.config.ts +++ b/next.config.ts @@ -4,9 +4,9 @@ const nextConfig: NextConfig = { images: { remotePatterns: [ { - protocol: "http", - hostname: "89.169.188.2", - pathname: '/**' + protocol: "https", + hostname: "api.travelmarine.ru", + pathname: "/**", }, ], unoptimized: true, diff --git a/src/hooks/useApiClient.ts b/src/hooks/useApiClient.ts index d35171e..6c66892 100644 --- a/src/hooks/useApiClient.ts +++ b/src/hooks/useApiClient.ts @@ -3,43 +3,43 @@ import useAuthStore from "@/stores/useAuthStore"; import useAuthPopup from "@/stores/useAuthPopup"; const useApiClient = () => { - const { getToken } = useAuthStore(); - const authPopup = useAuthPopup(); + const { getToken } = useAuthStore(); + const authPopup = useAuthPopup(); - const apiClient = axios.create({ - baseURL: "http://89.169.188.2/api", - headers: { - "Content-Type": "application/json", - }, - }); + const apiClient = axios.create({ + baseURL: "https://api.travelmarine.ru", + headers: { + "Content-Type": "application/json", + }, + }); - apiClient.interceptors.request.use( - (config) => { - const token = getToken(); + apiClient.interceptors.request.use( + (config) => { + const token = getToken(); - if (token) { - config.headers.Authorization = `Token ${token}`; - } + if (token) { + config.headers.Authorization = `Token ${token}`; + } - return config; - }, - (error) => { - return Promise.reject(error); - } - ); + return config; + }, + (error) => { + return Promise.reject(error); + } + ); - apiClient.interceptors.response.use( - (response) => response, - (error) => { - if (error.response?.status === 401) { - console.error("Authentication error:", error); - authPopup.open(); - } - return Promise.reject(error); - } - ); + apiClient.interceptors.response.use( + (response) => response, + (error) => { + if (error.response?.status === 401) { + console.error("Authentication error:", error); + authPopup.open(); + } + return Promise.reject(error); + } + ); - return apiClient; + return apiClient; }; export default useApiClient; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index adab797..97aa66b 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,21 +1,26 @@ -import { clsx, type ClassValue } from "clsx" -import { twMerge } from "tailwind-merge" +import { clsx, type ClassValue } from "clsx"; +import { twMerge } from "tailwind-merge"; import { differenceInHours, parseISO } from "date-fns"; export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)) + return twMerge(clsx(inputs)); } -const API_BASE_URL = "http://89.169.188.2"; +const API_BASE_URL = "https://api.travelmarine.ru"; export const getImageUrl = (relativePath: string): string => { if (!relativePath) return ""; // Если путь уже абсолютный, возвращаем как есть - if (relativePath.startsWith("http://") || relativePath.startsWith("https://")) { + if ( + relativePath.startsWith("http://") || + relativePath.startsWith("https://") + ) { return relativePath; } // Убираем начальный слеш, если есть, и формируем абсолютный URL - const cleanPath = relativePath.startsWith("/") ? relativePath.slice(1) : relativePath; + const cleanPath = relativePath.startsWith("/") + ? relativePath.slice(1) + : relativePath; return `${API_BASE_URL}/${cleanPath}`; }; @@ -67,7 +72,8 @@ export const calculateTotalPrice = ( // Добавляем разницу в минутах const minutesDiff = - (arrivalDateTime.getMinutes() - departureDateTime.getMinutes()) / 60; + (arrivalDateTime.getMinutes() - departureDateTime.getMinutes()) / + 60; hoursDiff += minutesDiff; // Округляем до ближайших 0.5 часа @@ -81,4 +87,4 @@ export const calculateTotalPrice = ( console.error("Error calculating price:", error); return { totalHours: 0, totalPrice: 0 }; } -}; \ No newline at end of file +};