Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("prettier").Config} */
module.exports = {
semi: true, // Har satrda nuqta-vergul bo‘lishi
singleQuote: true, // ' ' ishlatilsin, " " emas
singleQuote: false, // ' ' ishlatilsin, " " emas
trailingComma: 'all', // so‘nggi vergullar qo‘yilsin
tabWidth: 2, // Indent 2 bo‘lsin
bracketSpacing: true, // { a: 1 } ichida bo‘sh joy qoldirsin
Expand Down
30 changes: 15 additions & 15 deletions src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { Metadata } from 'next';
import '../globals.css';
import { golosText } from '@/shared/config/fonts';
import { ThemeProvider } from '@/shared/config/theme-provider';
import { PRODUCT_INFO } from '@/shared/constants/data';
import { hasLocale, Locale, NextIntlClientProvider } from 'next-intl';
import { routing } from '@/shared/config/i18n/routing';
import { notFound } from 'next/navigation';
import Footer from '@/widgets/footer/ui';
import Navbar from '@/widgets/navbar/ui';
import { ReactNode } from 'react';
import { setRequestLocale } from 'next-intl/server';
import QueryProvider from '@/shared/config/react-query/QueryProvider';
import Script from 'next/script';
import type { Metadata } from "next";
import "../globals.css";
import { golosText } from "@/shared/config/fonts";
import { ThemeProvider } from "@/shared/config/theme-provider";
import { PRODUCT_INFO } from "@/shared/constants/data";
import { hasLocale, type Locale, NextIntlClientProvider } from "next-intl";
import { routing } from "@/shared/config/i18n/routing";
import { notFound } from "next/navigation";
import Footer from "@/widgets/footer/ui";
import Navbar from "@/widgets/navbar/ui";
import { setRequestLocale } from "next-intl/server";
import QueryProvider from "@/shared/config/react-query/QueryProvider";
import Script from "next/script";
import type { ReactNode } from "react";

export const metadata: Metadata = {
title: PRODUCT_INFO.name,
Expand Down Expand Up @@ -42,7 +42,7 @@ export default async function RootLayout({ children, params }: Props) {
<body className={`${golosText.variable} antialiased`}>
<NextIntlClientProvider locale={locale}>
<ThemeProvider
attribute={'class'}
attribute={"class"}
defaultTheme="light"
enableSystem
disableTransitionOnChange
Expand Down
6 changes: 3 additions & 3 deletions src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getPosts } from '@/shared/config/api/testApi';
import Welcome from '@/widgets/welcome';
import { getPosts } from "@/shared/config/api/testApi";
import Welcome from "@/widgets/welcome";

export default async function Home() {
const res = await getPosts({ _limit: 1 });
console.log('SSR res', res.data);
console.log("SSR res", res.data);

return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from 'react';
import type { ReactNode } from "react";

type Props = {
children: ReactNode;
Expand Down
5 changes: 3 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { redirect } from 'next/navigation';
import { routing } from "@/shared/config/i18n/routing";
import { redirect } from "next/navigation";

// This page only renders when the app is built statically (output: 'export')
export default function RootPage() {
redirect('/uz');
redirect(routing.defaultLocale);
}
6 changes: 3 additions & 3 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import createMiddleware from 'next-intl/middleware';
import { routing } from './shared/config/i18n/routing';
import createMiddleware from "next-intl/middleware";
import { routing } from "./shared/config/i18n/routing";

export default createMiddleware(routing);

export const config = {
// Match all pathnames except for
// - … if they start with `/api`, `/trpc`, `/_next` or `/_vercel`
// - … the ones containing a dot (e.g. `favicon.ico`)
matcher: '/((?!api|trpc|_next|_vercel|.*\\..*).*)',
matcher: "/((?!api|trpc|_next|_vercel|.*\\..*).*)",
};
4 changes: 2 additions & 2 deletions src/shared/config/api/URLs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const BASE_URL =
process.env.NEXT_PUBLIC_API_URL || 'https://jsonplaceholder.typicode.com';
process.env.NEXT_PUBLIC_API_URL || "https://jsonplaceholder.typicode.com";

const ENDP_POSTS = '/posts/';
const ENDP_POSTS = "/posts/";

export { BASE_URL, ENDP_POSTS };
16 changes: 8 additions & 8 deletions src/shared/config/api/httpClient.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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';
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,
Expand All @@ -18,11 +18,11 @@ httpClient.interceptors.request.use(
try {
language = (await getLocale()) as LanguageRoutes;
} catch (e) {
console.log('error', e);
console.log("error", e);
language = getLocaleCS() || LanguageRoutes.UZ;
}

config.headers['Accept-Language'] = language;
config.headers["Accept-Language"] = language;
// const accessToken = localStorage.getItem('accessToken');
// if (accessToken) {
// config.headers['Authorization'] = `Bearer ${accessToken}`;
Expand All @@ -36,7 +36,7 @@ httpClient.interceptors.request.use(
httpClient.interceptors.response.use(
(response) => response,
(error) => {
console.error('API error:', error);
console.error("API error:", error);
return Promise.reject(error);
},
);
Expand Down
10 changes: 5 additions & 5 deletions src/shared/config/api/testApi.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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';
import { ENDP_POSTS } from "@/shared/config/api/URLs";
import { type ReqWithPagination } from "./types";
import { type AxiosResponse } from "axios";
import { type TestApiType } from "@/shared/types/testApi";
import httpClient from "./httpClient";

const getPosts = async (
pagination?: ReqWithPagination,
Expand Down
8 changes: 4 additions & 4 deletions src/shared/config/fonts.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Golos_Text } from 'next/font/google';
import { Golos_Text } from "next/font/google";

const golosText = Golos_Text({
weight: ['400', '500', '600', '700', '800'],
variable: '--font-golos-text',
subsets: ['latin', 'cyrillic'],
weight: ["400", "500", "600", "700", "800"],
variable: "--font-golos-text",
subsets: ["latin", "cyrillic"],
});

export { golosText };
4 changes: 2 additions & 2 deletions src/shared/config/i18n/messages/uz.d.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

declare const messages: {
HomePage: {
title: 'Salom dunyo!';
about: 'Go to the about page';
title: "Salom dunyo!";
about: "Go to the about page";
};
};
export default messages;
4 changes: 2 additions & 2 deletions src/shared/config/i18n/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createNavigation } from 'next-intl/navigation';
import { routing } from './routing';
import { createNavigation } from "next-intl/navigation";
import { routing } from "./routing";

// Lightweight wrappers around Next.js' navigation
// APIs that consider the routing configuration
Expand Down
6 changes: 3 additions & 3 deletions src/shared/config/i18n/request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getRequestConfig } from 'next-intl/server';
import { hasLocale } from 'next-intl';
import { routing } from './routing';
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
Expand Down
4 changes: 2 additions & 2 deletions src/shared/config/i18n/routing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineRouting } from 'next-intl/routing';
import { LanguageRoutes } from './types';
import { defineRouting } from "next-intl/routing";
import { LanguageRoutes } from "./types";

export const routing = defineRouting({
// A list of all locales that are supported
Expand Down
6 changes: 3 additions & 3 deletions src/shared/config/i18n/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum LanguageRoutes {
UZ = 'uz', // o'zbekcha
RU = 'ru', // ruscha
KI = 'ki', // kirilcha
UZ = "uz", // o'zbekcha
RU = "ru", // ruscha
KI = "ki", // kirilcha
}
6 changes: 3 additions & 3 deletions src/shared/config/react-query/QueryProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
"use client";

import { ReactNode, useState } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { type ReactNode, useState } from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const QueryProvider = ({ children }: { children: ReactNode }) => {
const [queryClient] = useState(
Expand Down
6 changes: 3 additions & 3 deletions src/shared/config/theme-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
"use client";

import * as React from 'react';
import { ThemeProvider as NextThemesProvider } from 'next-themes';
import * as React from "react";
import { ThemeProvider as NextThemesProvider } from "next-themes";

export function ThemeProvider({
children,
Expand Down
26 changes: 13 additions & 13 deletions src/shared/constants/data.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const PRODUCT_INFO = {
name: 'FIAS App',
description: 'Generated by create next app',
logo: '/favicon.png',
favicon: '/favicon.svg',
url: 'https://www.shadcnblocks.com',
name: "FIAS App",
description: "Generated by create next app",
logo: "/favicon.png",
favicon: "/favicon.svg",
url: "https://www.shadcnblocks.com",
socials: {
telegram: 'https://t.me/usmanov_dev',
instagram: 'https://t.me/usmanov_dev',
youtube: 'https://t.me/usmanov_dev',
linkedin: 'https://www.linkedin.com/in/usmonov-azizbek/',
telegram: "https://t.me/usmanov_dev",
instagram: "https://t.me/usmanov_dev",
youtube: "https://t.me/usmanov_dev",
linkedin: "https://www.linkedin.com/in/usmonov-azizbek/",
},
contact: {
phone: '+998901234567',
email: 'contact@fias.uz',
phone: "+998901234567",
email: "contact@fias.uz",
},
terms_of_use: '',
creator: 'FIAS App',
terms_of_use: "",
creator: "FIAS App",
};

export { PRODUCT_INFO };
10 changes: 5 additions & 5 deletions src/shared/hooks/use-closer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect } from "react";

/**
* Hook for closing some items when they are unnecessary to the user
Expand Down Expand Up @@ -27,11 +27,11 @@ const useCloser = (
}
}

document.addEventListener('mousedown', handleClickOutside);
document.addEventListener('scroll', handleScroll);
document.addEventListener("mousedown", handleClickOutside);
document.addEventListener("scroll", handleScroll);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
document.removeEventListener('scroll', handleScroll);
document.removeEventListener("mousedown", handleClickOutside);
document.removeEventListener("scroll", handleScroll);
};
}, [ref, closeFunction]);
};
Expand Down
6 changes: 3 additions & 3 deletions src/shared/hooks/use-mobile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import * as React from "react";

const MOBILE_BREAKPOINT = 768;

Expand All @@ -16,9 +16,9 @@ const useIsMobile = () => {
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
};
mql.addEventListener('change', onChange);
mql.addEventListener("change", onChange);
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
return () => mql.removeEventListener('change', onChange);
return () => mql.removeEventListener("change", onChange);
}, []);

return !!isMobile;
Expand Down
6 changes: 3 additions & 3 deletions src/shared/hooks/use-window-size.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useState } from "react";

interface ISize {
width: number | undefined;
Expand All @@ -25,10 +25,10 @@ const useWindowSize = () => {

getScreenSize();

window.addEventListener('resize', getScreenSize);
window.addEventListener("resize", getScreenSize);

return () => {
window.removeEventListener('resize', getScreenSize);
window.removeEventListener("resize", getScreenSize);
};
}, []);

Expand Down
32 changes: 16 additions & 16 deletions src/shared/lib/formatDate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import dayjs from 'dayjs';
import 'dayjs/locale/uz-latn';
import 'dayjs/locale/uz';
import 'dayjs/locale/ru';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import relativeTime from 'dayjs/plugin/relativeTime';
import { getLocale } from 'next-intl/server';
import dayjs from "dayjs";
import "dayjs/locale/uz-latn";
import "dayjs/locale/uz";
import "dayjs/locale/ru";
import localizedFormat from "dayjs/plugin/localizedFormat";
import relativeTime from "dayjs/plugin/relativeTime";
import { getLocale } from "next-intl/server";

// Install Dayjs plugins
dayjs.extend(localizedFormat);
Expand All @@ -14,15 +14,15 @@ dayjs.extend(relativeTime);
const getCurrentLocale = async () => {
const locale = await getLocale();
switch (locale) {
case 'ki':
return 'uz';
case 'uz':
return 'uz-latn';
case 'ru':
return 'ru';
case "ki":
return "uz";
case "uz":
return "uz-latn";
case "ru":
return "ru";

default:
return 'uz-latn';
return "uz-latn";
}
};

Expand Down Expand Up @@ -53,7 +53,7 @@ const formatDate = {
format: (
time: Date | string | number,
format: string,
locale: string = 'uz',
locale: string = "uz",
): string => {
return dayjs(time).locale(locale).format(format);
},
Expand All @@ -80,7 +80,7 @@ const formatDate = {
*/
relativeFormat: (
time: Date | string | number,
locale: string = 'uz',
locale: string = "uz",
): string => {
return dayjs(time).locale(locale).fromNow();
},
Expand Down
Loading