mirror of https://github.com/sunface/rust-course
update #56, show user tags as moderator role
parent
f5a93bc8bd
commit
4392b8dfbc
@ -0,0 +1,64 @@
|
||||
import {Text, Box, Heading, Image, Center, Button, Flex, VStack, Divider, useToast, Wrap, WrapItem, useColorModeValue, StackDivider } from "@chakra-ui/react"
|
||||
import Card from "components/card"
|
||||
import Nav from "layouts/nav/nav"
|
||||
import PageContainer from "layouts/page-container"
|
||||
import Sidebar from "layouts/sidebar/sidebar"
|
||||
import React, { useEffect, useState } from "react"
|
||||
import {dashboardLinks} from "src/data/links"
|
||||
import { requestApi } from "utils/axios/request"
|
||||
import PageContainer1 from "layouts/page-container1"
|
||||
import Empty from "components/empty"
|
||||
import { IDType } from "src/types/id"
|
||||
import UserCard from "components/users/user-card"
|
||||
import userCustomTheme from "theme/user-custom"
|
||||
import TagCard from "components/tags/tag-card"
|
||||
import SimpleTagCard from "components/tags/simple-tag-card"
|
||||
|
||||
|
||||
const FollowersPage = () => {
|
||||
const [tags, setTags] = useState([])
|
||||
const borderColor = useColorModeValue(userCustomTheme.borderColor.light, userCustomTheme.borderColor.dark)
|
||||
|
||||
const getTags = async () => {
|
||||
const res = await requestApi.get(`/tag/list/byUserModeratorRole`)
|
||||
console.log(res)
|
||||
setTags(res.data)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getTags()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageContainer1>
|
||||
<Box display="flex">
|
||||
<Sidebar routes={dashboardLinks} title="dashboard" />
|
||||
<Card ml="4" p="6" width="100%">
|
||||
<Text fontSize=".95rem" fontWeight="600">You are a moderator of these tags, you can modify the tag and manage the posts.</Text>
|
||||
<Divider my="6" />
|
||||
{
|
||||
tags.length === 0 ?
|
||||
<Empty />
|
||||
:
|
||||
<>
|
||||
<VStack mt="4">
|
||||
{tags.map(tag =>
|
||||
<Box width="100%" key={tag.id}>
|
||||
<SimpleTagCard tag={tag} mt="4" />
|
||||
<Divider mt="5" />
|
||||
</Box>
|
||||
)}
|
||||
</VStack>
|
||||
<Center><Text layerStyle="textSecondary" fontSize="sm" mt="5">没有更多标签了</Text></Center>
|
||||
</>
|
||||
}
|
||||
</Card>
|
||||
</Box>
|
||||
</PageContainer1>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default FollowersPage
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
import React from "react"
|
||||
import {chakra, Heading, Image, Text, HStack,Button, Flex,PropsOf, Box, Tooltip, Tag as ChakraTag, useColorModeValue} from "@chakra-ui/react"
|
||||
import { Tag } from "src/types/tag"
|
||||
import { ReserveUrls } from "src/data/reserve-urls"
|
||||
import NextLink from "next/link"
|
||||
|
||||
type Props = PropsOf<typeof chakra.div> & {
|
||||
tag: Tag
|
||||
}
|
||||
|
||||
|
||||
export const SimpleTagCard= (props:Props) =>{
|
||||
const {tag} = props
|
||||
return (
|
||||
<Flex justifyContent="space-between" alignItems="center" className="hover-bg" p="2">
|
||||
<NextLink href={`${ReserveUrls.Tags}/${tag.name}`}>
|
||||
<HStack cursor="pointer">
|
||||
<Image src={tag.icon} width="43px" mr="2" borderWidth="1px" className="bordered"/>
|
||||
<Box>
|
||||
<Heading size="sm">{tag.title}</Heading>
|
||||
<Tooltip openDelay={300} label={tag.md}><Text layerStyle="textSecondary" fontSize=".85rem" mt="1" overflow="hidden" textOverflow="ellipsis" whiteSpace="nowrap" width={["100px","100px","200px","300px"]}>{tag.md}</Text></Tooltip>
|
||||
</Box>
|
||||
</HStack>
|
||||
</NextLink>
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
|
||||
export default SimpleTagCard
|
Loading…
Reference in new issue