first commit

This commit is contained in:
@jcarymuhammedow
2026-05-02 18:54:39 +05:00
commit f1f65138ea
45 changed files with 10608 additions and 0 deletions

40
src/lib/api/client.ts Normal file
View File

@@ -0,0 +1,40 @@
import axios from 'axios'
const API_BASE_URL = import.meta.env.VITE_API_URL ?? '/api'
export const apiClient = axios.create({
baseURL: API_BASE_URL,
headers: {
'Content-Type': 'application/json',
},
timeout: 15_000,
})
// Request interceptor — attach token
apiClient.interceptors.request.use((config) => {
const raw = localStorage.getItem('tbbank-auth')
if (raw) {
try {
const parsed = JSON.parse(raw) as { state?: { token?: string } }
const token = parsed?.state?.token
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
} catch {
// ignore parse errors
}
}
return config
})
// Response interceptor — handle 401
apiClient.interceptors.response.use(
(response) => response,
(error: unknown) => {
if (axios.isAxiosError(error) && error.response?.status === 401) {
localStorage.removeItem('tbbank-auth')
window.location.replace('/login')
}
return Promise.reject(error)
},
)

28
src/lib/i18n/index.ts Normal file
View File

@@ -0,0 +1,28 @@
import i18n from 'i18next'
import { initReactI18next } from 'react-i18next'
import en from './locales/en.json'
import ru from './locales/ru.json'
import tk from './locales/tk.json'
export const SUPPORTED_LANGUAGES = ['en', 'ru', 'tk'] as const
export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number]
const savedLang = localStorage.getItem('tbbank-lang') as SupportedLanguage | null
const defaultLang: SupportedLanguage =
SUPPORTED_LANGUAGES.includes(savedLang as SupportedLanguage) ? (savedLang as SupportedLanguage) : 'en'
i18n.use(initReactI18next).init({
resources: {
en: { translation: en },
ru: { translation: ru },
tk: { translation: tk },
},
lng: defaultLang,
fallbackLng: 'en',
interpolation: {
escapeValue: false,
},
})
export default i18n

View File

@@ -0,0 +1,55 @@
{
"common": {
"loading": "Loading...",
"error": "An error occurred",
"save": "Save",
"cancel": "Cancel",
"confirm": "Confirm",
"delete": "Delete",
"edit": "Edit",
"close": "Close",
"back": "Back",
"next": "Next",
"search": "Search",
"noData": "No data available"
},
"auth": {
"signIn": "Sign In",
"signOut": "Sign Out",
"email": "Email",
"password": "Password",
"emailPlaceholder": "admin@tbbank.tm",
"passwordPlaceholder": "Enter your password",
"forgotPassword": "Forgot password?",
"signingIn": "Signing in...",
"welcomeBack": "Welcome back",
"signInSubtitle": "Sign in to your admin account",
"invalidCredentials": "Invalid email or password",
"emailRequired": "Email is required",
"passwordRequired": "Password is required",
"emailInvalid": "Please enter a valid email"
},
"nav": {
"dashboard": "Dashboard",
"accounts": "Accounts",
"transactions": "Transactions",
"customers": "Customers",
"loans": "Loans",
"reports": "Reports",
"settings": "Settings"
},
"theme": {
"light": "Light",
"dark": "Dark",
"system": "System"
},
"lang": {
"en": "English",
"ru": "Русский",
"tk": "Türkmen"
},
"dashboard": {
"title": "Dashboard",
"subtitle": "Welcome to TBBank Admin Panel"
}
}

View File

@@ -0,0 +1,55 @@
{
"common": {
"loading": "Загрузка...",
"error": "Произошла ошибка",
"save": "Сохранить",
"cancel": "Отмена",
"confirm": "Подтвердить",
"delete": "Удалить",
"edit": "Редактировать",
"close": "Закрыть",
"back": "Назад",
"next": "Далее",
"search": "Поиск",
"noData": "Нет данных"
},
"auth": {
"signIn": "Войти",
"signOut": "Выйти",
"email": "Эл. почта",
"password": "Пароль",
"emailPlaceholder": "admin@tbbank.tm",
"passwordPlaceholder": "Введите пароль",
"forgotPassword": "Забыли пароль?",
"signingIn": "Вход...",
"welcomeBack": "Добро пожаловать",
"signInSubtitle": "Войдите в панель администратора",
"invalidCredentials": "Неверный email или пароль",
"emailRequired": "Введите email",
"passwordRequired": "Введите пароль",
"emailInvalid": "Введите корректный email"
},
"nav": {
"dashboard": "Панель управления",
"accounts": "Счета",
"transactions": "Транзакции",
"customers": "Клиенты",
"loans": "Кредиты",
"reports": "Отчёты",
"settings": "Настройки"
},
"theme": {
"light": "Светлая",
"dark": "Тёмная",
"system": "Системная"
},
"lang": {
"en": "English",
"ru": "Русский",
"tk": "Türkmen"
},
"dashboard": {
"title": "Панель управления",
"subtitle": "Добро пожаловать в TBBank Admin"
}
}

View File

@@ -0,0 +1,55 @@
{
"common": {
"loading": "Ýüklenýär...",
"error": "Ýalňyşlyk ýüze çykdy",
"save": "Ýatda sakla",
"cancel": "Ýatyr",
"confirm": "Tassykla",
"delete": "Poz",
"edit": "Düzelt",
"close": "Ýap",
"back": "Yza",
"next": "Öňe",
"search": "Gözle",
"noData": "Maglumat ýok"
},
"auth": {
"signIn": "Giriş",
"signOut": "Çykyş",
"email": "E-poçta",
"password": "Açar söz",
"emailPlaceholder": "admin@tbbank.tm",
"passwordPlaceholder": "Açar sözüňizi giriziň",
"forgotPassword": "Açar sözi unutdyňyzmy?",
"signingIn": "Girýär...",
"welcomeBack": "Hoş geldiňiz",
"signInSubtitle": "Admin paneline giriş",
"invalidCredentials": "E-poçta ýa-da açar söz ýalňyş",
"emailRequired": "E-poçta hökmanydyr",
"passwordRequired": "Açar söz hökmanydyr",
"emailInvalid": "Dogry e-poçta girizin"
},
"nav": {
"dashboard": "Dolandyryş paneli",
"accounts": "Hasaplar",
"transactions": "Geçirimler",
"customers": "Müşderiler",
"loans": "Karzlar",
"reports": "Hasabatlar",
"settings": "Sazlamalar"
},
"theme": {
"light": "Açyk",
"dark": "Garaňky",
"system": "Ulgam"
},
"lang": {
"en": "English",
"ru": "Русский",
"tk": "Türkmen"
},
"dashboard": {
"title": "Dolandyryş paneli",
"subtitle": "TBBank Admin paneliňize hoş geldiňiz"
}
}

6
src/lib/utils.ts Normal file
View File

@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}