first commit
This commit is contained in:
5
src/shared/config/api/URLs.ts
Normal file
5
src/shared/config/api/URLs.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
const BASE_URL = process.env.NEXT_PUBLIC_API_URL;
|
||||
|
||||
const GET_BOXES = '/qr';
|
||||
|
||||
export { BASE_URL, GET_BOXES };
|
||||
42
src/shared/config/api/httpClient.ts
Normal file
42
src/shared/config/api/httpClient.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
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) => {
|
||||
// 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;
|
||||
13
src/shared/config/api/testApi.ts
Normal file
13
src/shared/config/api/testApi.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { TestApiType } from '@/shared/types/testApi';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from './httpClient';
|
||||
import { GET_BOXES } from './URLs';
|
||||
|
||||
export const getBoxes = {
|
||||
async boxesDetail({ id }: { id: number }) {
|
||||
const res = await httpClient.get<AxiosResponse<TestApiType>>(
|
||||
`${GET_BOXES}/${id}/details`,
|
||||
);
|
||||
return res;
|
||||
},
|
||||
};
|
||||
20
src/shared/config/api/types.ts
Normal file
20
src/shared/config/api/types.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
9
src/shared/config/fonts.ts
Normal file
9
src/shared/config/fonts.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Golos_Text } from 'next/font/google';
|
||||
|
||||
const golosText = Golos_Text({
|
||||
weight: ['400', '500', '600', '700', '800'],
|
||||
variable: '--font-golos-text',
|
||||
subsets: ['latin', 'cyrillic'],
|
||||
});
|
||||
|
||||
export { golosText };
|
||||
6
src/shared/config/i18n/messages/ki.json
Normal file
6
src/shared/config/i18n/messages/ki.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"HomePage": {
|
||||
"title": "Salom dunyo! (Kiril)",
|
||||
"about": "Go to the about page"
|
||||
}
|
||||
}
|
||||
6
src/shared/config/i18n/messages/ru.json
Normal file
6
src/shared/config/i18n/messages/ru.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"HomePage": {
|
||||
"title": "Hello world!",
|
||||
"about": "Go to the about page"
|
||||
}
|
||||
}
|
||||
10
src/shared/config/i18n/messages/uz.d.json.ts
Normal file
10
src/shared/config/i18n/messages/uz.d.json.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// This file is auto-generated by next-intl, do not edit directly.
|
||||
// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments
|
||||
|
||||
declare const messages: {
|
||||
"HomePage": {
|
||||
"title": "Salom dunyo!",
|
||||
"about": "Go to the about page"
|
||||
}
|
||||
};
|
||||
export default messages;
|
||||
6
src/shared/config/i18n/messages/uz.json
Normal file
6
src/shared/config/i18n/messages/uz.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"HomePage": {
|
||||
"title": "Salom dunyo!",
|
||||
"about": "Go to the about page"
|
||||
}
|
||||
}
|
||||
7
src/shared/config/i18n/navigation.ts
Normal file
7
src/shared/config/i18n/navigation.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { createNavigation } from 'next-intl/navigation';
|
||||
import { routing } from './routing';
|
||||
|
||||
// Lightweight wrappers around Next.js' navigation
|
||||
// APIs that consider the routing configuration
|
||||
export const { Link, redirect, usePathname, useRouter, getPathname } =
|
||||
createNavigation(routing);
|
||||
16
src/shared/config/i18n/request.ts
Normal file
16
src/shared/config/i18n/request.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { getRequestConfig } from 'next-intl/server';
|
||||
import { hasLocale } from 'next-intl';
|
||||
import { routing } from './routing';
|
||||
|
||||
export default getRequestConfig(async ({ requestLocale }) => {
|
||||
// Typically corresponds to the `[locale]` segment
|
||||
const requested = await requestLocale;
|
||||
const locale = hasLocale(routing.locales, requested)
|
||||
? requested
|
||||
: routing.defaultLocale;
|
||||
|
||||
return {
|
||||
locale,
|
||||
messages: (await import(`./messages/${locale}.json`)).default,
|
||||
};
|
||||
});
|
||||
11
src/shared/config/i18n/routing.ts
Normal file
11
src/shared/config/i18n/routing.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { defineRouting } from 'next-intl/routing';
|
||||
import { LanguageRoutes } from './types';
|
||||
|
||||
export const routing = defineRouting({
|
||||
// A list of all locales that are supported
|
||||
locales: [LanguageRoutes.UZ, LanguageRoutes.RU, LanguageRoutes.KI],
|
||||
|
||||
// Used when no locale matches
|
||||
defaultLocale: LanguageRoutes.UZ,
|
||||
localeDetection: false,
|
||||
});
|
||||
5
src/shared/config/i18n/types.ts
Normal file
5
src/shared/config/i18n/types.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum LanguageRoutes {
|
||||
UZ = 'uz', // o'zbekcha
|
||||
RU = 'ru', // ruscha
|
||||
KI = 'ki', // kirilcha
|
||||
}
|
||||
27
src/shared/config/react-query/QueryProvider.tsx
Normal file
27
src/shared/config/react-query/QueryProvider.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
'use client';
|
||||
|
||||
import { ReactNode, useState } from 'react';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
|
||||
const QueryProvider = ({ children }: { children: ReactNode }) => {
|
||||
const [queryClient] = useState(
|
||||
() =>
|
||||
new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
refetchOnWindowFocus: false,
|
||||
retry: 1,
|
||||
staleTime: 1000 * 60 * 5,
|
||||
refetchOnReconnect: false,
|
||||
refetchOnMount: false,
|
||||
refetchInterval: 1000 * 60 * 5,
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default QueryProvider;
|
||||
11
src/shared/config/theme-provider.tsx
Normal file
11
src/shared/config/theme-provider.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { ThemeProvider as NextThemesProvider } from 'next-themes';
|
||||
|
||||
export function ThemeProvider({
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof NextThemesProvider>) {
|
||||
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
|
||||
}
|
||||
Reference in New Issue
Block a user