first commit

This commit is contained in:
Samandar Turgunboyev
2025-10-13 14:14:32 +05:00
parent 4309981b29
commit 1f1aae0ab7
76 changed files with 10746 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
const BASE_URL = process.env.NEXT_PUBLIC_API_URL;
const GET_BOXES = '/qr';
export { BASE_URL, GET_BOXES };

View 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;

View 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;
},
};

View 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;
}

View 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 };

View File

@@ -0,0 +1,6 @@
{
"HomePage": {
"title": "Salom dunyo! (Kiril)",
"about": "Go to the about page"
}
}

View File

@@ -0,0 +1,6 @@
{
"HomePage": {
"title": "Hello world!",
"about": "Go to the about page"
}
}

View 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;

View File

@@ -0,0 +1,6 @@
{
"HomePage": {
"title": "Salom dunyo!",
"about": "Go to the about page"
}
}

View 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);

View 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,
};
});

View 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,
});

View File

@@ -0,0 +1,5 @@
export enum LanguageRoutes {
UZ = 'uz', // o'zbekcha
RU = 'ru', // ruscha
KI = 'ki', // kirilcha
}

View 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;

View 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>;
}