locker buttons if user doesnt have required membership
This commit is contained in:
@@ -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<Route[]>([])
|
||||
const [error, setError] = useState<string | null>(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 (
|
||||
<div className="flex justify-between gap-2">
|
||||
<Link
|
||||
href="/payments"
|
||||
className="flex items-center justify-center rounded-md border border-gray-300 bg-white/50 px-4 py-2 text-center text-sm font-medium text-gray-500 shadow-sm hover:bg-gray-50 focus:outline-none"
|
||||
title="Доступно в тарифе Standart"
|
||||
>
|
||||
<span className="flex items-center gap-1">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
strokeWidth={1.5}
|
||||
stroke="currentColor"
|
||||
className="h-5 w-5"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z"
|
||||
/>
|
||||
</svg>
|
||||
Поднять в выдаче
|
||||
</span>
|
||||
</Link>
|
||||
<Link
|
||||
href="/payments"
|
||||
className="flex items-center justify-center rounded-md border border-gray-300 bg-white/50 px-4 py-2 text-center text-sm font-medium text-gray-500 shadow-sm hover:bg-gray-50 focus:outline-none"
|
||||
title="Доступно в тарифе Standart"
|
||||
>
|
||||
<span className="flex items-center gap-1">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
strokeWidth={1.5}
|
||||
stroke="currentColor"
|
||||
className="h-5 w-5"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z"
|
||||
/>
|
||||
</svg>
|
||||
Выделить
|
||||
</span>
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex justify-between gap-2">
|
||||
<Button
|
||||
text="Поднять объявление"
|
||||
className="border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-100 focus:outline-none"
|
||||
onClick={() => handleUpper(route)}
|
||||
/>
|
||||
<Button
|
||||
text={route.is_highlighted ? 'Уже выделено!' : 'Выделить рамкой'}
|
||||
className="border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-100 focus:outline-none"
|
||||
onClick={() => handleHighlight(route)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return <Loader />
|
||||
}
|
||||
@@ -197,18 +271,7 @@ export default function UserRoutes() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex justify-between">
|
||||
<Button
|
||||
text="Поднять объявление"
|
||||
className="border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-100 focus:outline-none"
|
||||
onClick={() => handleUpper(route)}
|
||||
/>
|
||||
<Button
|
||||
text="Выделить рамкой"
|
||||
className="border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-100 focus:outline-none"
|
||||
onClick={() => handleHighlight(route)}
|
||||
/>
|
||||
</div>
|
||||
{renderActionButtons(route)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user