From c3dcb9c827df6d80ad1b0b1a7c6155561527b39d Mon Sep 17 00:00:00 2001 From: l3wdfut4pwr Date: Tue, 30 Dec 2025 13:46:39 +0200 Subject: init --- src/lib/consts.ts | 2 ++ src/lib/contexts/Auth.context.tsx | 37 +++++++++++++++++++++++++++++++++++++ src/lib/contexts/Global.context.tsx | 8 ++++++++ src/lib/contexts/index.ts | 2 ++ src/lib/utils.ts | 6 ++++++ 5 files changed, 55 insertions(+) create mode 100644 src/lib/consts.ts create mode 100644 src/lib/contexts/Auth.context.tsx create mode 100644 src/lib/contexts/Global.context.tsx create mode 100644 src/lib/contexts/index.ts create mode 100644 src/lib/utils.ts (limited to 'src/lib') diff --git a/src/lib/consts.ts b/src/lib/consts.ts new file mode 100644 index 0000000..7dea370 --- /dev/null +++ b/src/lib/consts.ts @@ -0,0 +1,2 @@ +export const PUBLISH_DISCLAIMER = + 'Прочитайте правила, прежде чем загружать. После публикации требуется одобрение модератора. Одобрение может занять до 14 дней, не связывайтесь с модерацией по этому поводу. Нажимая "опубликовать", вы подтверждаете, что прочитали наши правила и понимаете, что не можете удалить свою собственную загрузку, если вы не являетесь автором контента.'; diff --git a/src/lib/contexts/Auth.context.tsx b/src/lib/contexts/Auth.context.tsx new file mode 100644 index 0000000..ff2d369 --- /dev/null +++ b/src/lib/contexts/Auth.context.tsx @@ -0,0 +1,37 @@ +'use client'; + +import React, { createContext, use } from 'react'; + +type User = { + id: string; + avatar?: string; + // Чёто там ещё +}; + +interface AuthContext { + user: User | null; +} + +const AuthContext = createContext(null); + +export const AuthContextProvider = ({ children }: React.PropsWithChildren) => { + // TODO: подключить бэк + const user = null; + return ( + {children} + ); +}; + +export const useAuthContext = () => { + const context = use(AuthContext); + + if (!context) { + throw new Error( + 'useAuthContext must be used within AuthContextProvider', + ); + } + + return context; +}; + +export const useUser = () => useAuthContext().user; diff --git a/src/lib/contexts/Global.context.tsx b/src/lib/contexts/Global.context.tsx new file mode 100644 index 0000000..3f8b61b --- /dev/null +++ b/src/lib/contexts/Global.context.tsx @@ -0,0 +1,8 @@ +import React from 'react'; +import { AuthContextProvider } from './Auth.context'; + +export const GlobalContextProvider = ({ + children, +}: React.PropsWithChildren) => { + return {children}; +}; diff --git a/src/lib/contexts/index.ts b/src/lib/contexts/index.ts new file mode 100644 index 0000000..61ebbe8 --- /dev/null +++ b/src/lib/contexts/index.ts @@ -0,0 +1,2 @@ +export * from './Auth.context'; +export * from './Global.context'; diff --git a/src/lib/utils.ts b/src/lib/utils.ts new file mode 100644 index 0000000..bd0c391 --- /dev/null +++ b/src/lib/utils.ts @@ -0,0 +1,6 @@ +import { clsx, type ClassValue } from "clsx" +import { twMerge } from "tailwind-merge" + +export function cn(...inputs: ClassValue[]) { + return twMerge(clsx(inputs)) +} -- cgit v1.3-3-g829e