From e30eb10d7da4e38d9d4c9740018e78ff9ef589b9 Mon Sep 17 00:00:00 2001 From: Timofey Date: Thu, 29 May 2025 13:34:47 +0300 Subject: [PATCH] locker buttons if user doesnt have required membership --- frontend/app/(urls)/account/routes/page.tsx | 89 ++++++++++++++++++--- frontend/app/providers/AuthProvider.tsx | 1 - frontend/app/types/index.ts | 3 +- frontend/components/AccountSidebar.tsx | 36 +++------ 4 files changed, 90 insertions(+), 39 deletions(-) diff --git a/frontend/app/(urls)/account/routes/page.tsx b/frontend/app/(urls)/account/routes/page.tsx index c3471e7..6b1a01b 100644 --- a/frontend/app/(urls)/account/routes/page.tsx +++ b/frontend/app/(urls)/account/routes/page.tsx @@ -5,11 +5,14 @@ import { Route } from '@/app/types' import Button from '@/components/ui/Button' import showToast from '@/components/ui/Toast' import Loader from '@/components/ui/Loader' +import Link from 'next/link' +import useUserStore from '@/app/store/userStore' export default function UserRoutes() { const [routes, setRoutes] = useState([]) const [error, setError] = useState(null) const [loading, setLoading] = useState(true) + const { user } = useUserStore() const fetchRoutes = async () => { try { @@ -26,7 +29,6 @@ export default function UserRoutes() { } const data = await response.json() - console.log(data) setRoutes(data || []) } catch (error) { @@ -105,6 +107,78 @@ export default function UserRoutes() { } } + const isLiteAccount = user?.account_type === 'lite' + + const renderActionButtons = (route: Route) => { + if (isLiteAccount) { + return ( +
+ + + + + + Поднять в выдаче + + + + + + + + Выделить + + +
+ ) + } + + return ( +
+
+ ) + } + if (loading) { return } @@ -197,18 +271,7 @@ export default function UserRoutes() { )} -
-
+ {renderActionButtons(route)} ))} diff --git a/frontend/app/providers/AuthProvider.tsx b/frontend/app/providers/AuthProvider.tsx index 3da6b49..60a1e47 100644 --- a/frontend/app/providers/AuthProvider.tsx +++ b/frontend/app/providers/AuthProvider.tsx @@ -44,7 +44,6 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => { image: userData.image, country: userData.country, city: userData.city, - plan: userData.plan, account_type: userData.account_type, }) setAuthenticated(true) diff --git a/frontend/app/types/index.ts b/frontend/app/types/index.ts index 0ffcce5..d2929d0 100644 --- a/frontend/app/types/index.ts +++ b/frontend/app/types/index.ts @@ -113,8 +113,7 @@ export interface User { email: string country?: string city?: string - plan: MembershipPlans - account_type?: string // user или manager + account_type: string } export interface UserState { diff --git a/frontend/components/AccountSidebar.tsx b/frontend/components/AccountSidebar.tsx index 3da6c9c..d7c79b4 100644 --- a/frontend/components/AccountSidebar.tsx +++ b/frontend/components/AccountSidebar.tsx @@ -8,10 +8,7 @@ import { AccountSidebarProps } from '@/app/types' import Logout from './Logout' import noPhoto from '../public/images/noPhoto.png' -const AccountSidebar: React.FC = ({ - user, - navigation, -}) => { +const AccountSidebar: React.FC = ({ user, navigation }) => { const pathname = usePathname() if (!user) { @@ -34,7 +31,7 @@ const AccountSidebar: React.FC = ({ return (
-
+
{user.image ? ( = ({ alt="Profile" height={84} width={84} - className="rounded-2xl w-full md:w-[84px] aspect-square object-cover" + className="aspect-square w-full rounded-2xl object-cover md:w-[84px]" priority /> ) : ( @@ -52,47 +49,40 @@ const AccountSidebar: React.FC = ({ height={84} width={84} priority - className="rounded-2xl w-full md:w-[84px] aspect-square object-cover" + className="aspect-square w-full rounded-2xl object-cover md:w-[84px]" /> )}

{user.name || 'Пользователь'}

-

- ID: {user.uuid || 'Not available'} -

+

ID: {user.uuid || 'Not available'}

{user.account_type && ( - {user.account_type.charAt(0).toUpperCase() + - user.account_type.slice(1)} + {user.account_type.charAt(0).toUpperCase() + user.account_type.slice(1)} )}
-
+
-
+