new features
This commit is contained in:
@@ -8,16 +8,25 @@ import { Badge } from "@/components/ui/badge"
|
||||
import { Spinner } from "@/components/ui/spinner"
|
||||
import { fetchMyPositions } from "@/actions/positions"
|
||||
|
||||
const positionsCache: Record<string, Position[]> = {}
|
||||
|
||||
export default function Positions() {
|
||||
const t = useTranslations("MePage.items.positions")
|
||||
const locale = useLocale()
|
||||
|
||||
const [positions, setPositions] = useState<Position[] | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [positions, setPositions] = useState<Position[] | null>(
|
||||
() => positionsCache[locale] ?? null
|
||||
)
|
||||
const [loading, setLoading] = useState(!positionsCache[locale])
|
||||
|
||||
useEffect(() => {
|
||||
if (positionsCache[locale]) return
|
||||
|
||||
setLoading(true)
|
||||
fetchMyPositions(locale)
|
||||
.then(setPositions)
|
||||
.then((data) => {
|
||||
positionsCache[locale] = data
|
||||
setPositions(data)
|
||||
})
|
||||
.finally(() => setLoading(false))
|
||||
}, [locale])
|
||||
|
||||
@@ -45,8 +54,8 @@ export default function Positions() {
|
||||
{position.permissions.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1 mt-2">
|
||||
{position.permissions.map((perm) => (
|
||||
<Badge key={perm.code} variant="secondary" className="text-xs font-mono">
|
||||
{perm.code}
|
||||
<Badge key={perm.code} variant="secondary" className="text-xs">
|
||||
{perm.description}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user