detail page done

This commit is contained in:
nabijonovdavronbek619@gmail.com
2026-03-31 16:47:18 +05:00
parent 0495f16e5e
commit 3fe54b5c3c
40 changed files with 2004 additions and 241 deletions

View File

@@ -1,6 +0,0 @@
const BASE_URL =
process.env.NEXT_PUBLIC_API_URL || 'https://jsonplaceholder.typicode.com';
const ENDP_POSTS = '/posts/';
export { BASE_URL, ENDP_POSTS };

View File

@@ -1,44 +0,0 @@
import getLocaleCS from '@/shared/lib/getLocaleCS';
import axios from 'axios';
import { getLocale } from 'next-intl/server';
import { LanguageRoutes } from '../i18n/types';
import { BASE_URL } from './URLs';
const httpClient = axios.create({
baseURL: BASE_URL,
timeout: 10000,
});
httpClient.interceptors.request.use(
async (config) => {
console.log(`API REQUEST to ${config.url}`, config);
// Language configs
let language = LanguageRoutes.UZ;
try {
language = (await getLocale()) as LanguageRoutes;
} catch (e) {
console.log('error', e);
language = getLocaleCS() || LanguageRoutes.UZ;
}
config.headers['Accept-Language'] = language;
// const accessToken = localStorage.getItem('accessToken');
// if (accessToken) {
// config.headers['Authorization'] = `Bearer ${accessToken}`;
// }
return config;
},
(error) => Promise.reject(error),
);
httpClient.interceptors.response.use(
(response) => response,
(error) => {
console.error('API error:', error);
return Promise.reject(error);
},
);
export default httpClient;

View File

@@ -1,14 +0,0 @@
import { ENDP_POSTS } from '@/shared/config/api/URLs';
import { ReqWithPagination } from './types';
import { AxiosResponse } from 'axios';
import { TestApiType } from '@/shared/types/testApi';
import httpClient from './httpClient';
const getPosts = async (
pagination?: ReqWithPagination,
): Promise<AxiosResponse<TestApiType>> => {
const response = await httpClient.get(ENDP_POSTS, { params: pagination });
return response;
};
export { getPosts };

View File

@@ -1,20 +0,0 @@
export interface ResWithPagination<T> {
success: boolean;
message: string;
links: Links;
total_items: number;
total_pages: number;
page_size: number;
current_page: number;
data: T[];
}
interface Links {
next: number | null;
previous: number | null;
}
export interface ReqWithPagination {
_start?: number;
_limit?: number;
}