|
| 1 | +"use client" |
| 2 | + |
| 3 | +import React from "react"; |
| 4 | +import {Layout} from "@code0-tech/pictor/dist/components/layout/Layout"; |
| 5 | +import {useParams} from "next/navigation"; |
| 6 | +import { |
| 7 | + AuroraBackground, |
| 8 | + Avatar, |
| 9 | + Badge, |
| 10 | + Button, |
| 11 | + Col, |
| 12 | + Flex, |
| 13 | + ScrollArea, |
| 14 | + ScrollAreaViewport, |
| 15 | + Spacing, |
| 16 | + Text, |
| 17 | + useService, |
| 18 | + useStore |
| 19 | +} from "@code0-tech/pictor"; |
| 20 | +import {UserService} from "@edition/user/services/User.service"; |
| 21 | +import {useUserSession} from "@edition/user/hooks/User.session.hook"; |
| 22 | +import {User} from "@code0-tech/sagittarius-graphql-types"; |
| 23 | +import {IconMail, IconSparkles, IconUser} from "@tabler/icons-react"; |
| 24 | + |
| 25 | +export const UserPage: React.FC = () => { |
| 26 | + |
| 27 | + |
| 28 | + const params = useParams() |
| 29 | + const userService = useService(UserService) |
| 30 | + const userStore = useStore(UserService) |
| 31 | + |
| 32 | + const userIndex = params.userId as any as number |
| 33 | + const userId: User['id'] = `gid://sagittarius/User/${userIndex}` |
| 34 | + |
| 35 | + const currentSession = useUserSession() |
| 36 | + const currentUser = React.useMemo( |
| 37 | + () => userService.getById(currentSession?.user?.id), |
| 38 | + [userStore, currentSession] |
| 39 | + ) |
| 40 | + |
| 41 | + const user = React.useMemo( |
| 42 | + () => userService.getById(userId), |
| 43 | + [userStore, userId, userService] |
| 44 | + ) |
| 45 | + |
| 46 | + |
| 47 | + const leftContent = <ScrollArea h={"100%"} type={"scroll"}> |
| 48 | + <ScrollAreaViewport> |
| 49 | + <Flex pr={0.7} miw={"17vw"} style={{flexDirection: "column"}}> |
| 50 | + <div style={{position: "relative"}}> |
| 51 | + <Avatar type={"character"} size={150} identifier={user?.username!}/> |
| 52 | + <Badge pos={"absolute"} right={"20%"} bottom={"20%"}> |
| 53 | + <Text size={"md"}>👋</Text> |
| 54 | + </Badge> |
| 55 | + </div> |
| 56 | + <Spacing spacing={"xs"}/> |
| 57 | + <Text size={"xl"} hierarchy={"primary"}>{user?.firstname} {user?.lastname}</Text> |
| 58 | + <Spacing spacing={"xs"}/> |
| 59 | + <Flex style={{flexDirection: "column", gap: "0.7rem"}}> |
| 60 | + <Text display={"flex"} align={"center"} size={"sm"} style={{gap: "0.7rem"}}> |
| 61 | + <IconUser size={16}/> |
| 62 | + @{user?.username} |
| 63 | + </Text> |
| 64 | + <Text display={"flex"} align={"center"} size={"sm"} style={{gap: "0.7rem"}}> |
| 65 | + <IconMail size={16}/> |
| 66 | + {user?.email} |
| 67 | + </Text> |
| 68 | + <Text display={"flex"} align={"center"} size={"sm"} style={{gap: "0.7rem"}}> |
| 69 | + <IconSparkles size={16}/> |
| 70 | + <Badge color={"primary"}>BASIC</Badge> |
| 71 | + </Text> |
| 72 | + </Flex> |
| 73 | + <Spacing spacing={"xs"}/> |
| 74 | + {currentUser?.id === userId && ( |
| 75 | + <> |
| 76 | + <Spacing spacing={"xs"}/> |
| 77 | + <Button w={"100%"} color={"tertiary"}>Edit Profile</Button> |
| 78 | + <Spacing spacing={"xs"}/> |
| 79 | + <Button color={"primary"} w={"100%"}> |
| 80 | + Upgrade to Pro |
| 81 | + <AuroraBackground/> |
| 82 | + </Button> |
| 83 | + </> |
| 84 | + )} |
| 85 | + </Flex> |
| 86 | + </ScrollAreaViewport> |
| 87 | + </ScrollArea> |
| 88 | + |
| 89 | + return <Layout showLayoutSplitter={false} layoutGap={"0"} leftContent={leftContent}> |
| 90 | + <div style={{ |
| 91 | + background: "#070514", |
| 92 | + height: "100%", |
| 93 | + padding: "1rem", |
| 94 | + borderTopLeftRadius: "1rem", |
| 95 | + borderTopRightRadius: "1rem" |
| 96 | + }}> |
| 97 | + <Flex h={"100%"} w={"100%"} align={"center"} justify={"center"}> |
| 98 | + <Col xs={4} style={{textAlign: "center"}}> |
| 99 | + <Text size={"xl"} hierarchy={"primary"}> |
| 100 | + @{user?.username}'s readme |
| 101 | + </Text> |
| 102 | + <Spacing spacing={"xs"}/> |
| 103 | + <Text> |
| 104 | + The user currently does not have a publicly available profile description. |
| 105 | + </Text> |
| 106 | + </Col> |
| 107 | + </Flex> |
| 108 | + </div> |
| 109 | + </Layout> |
| 110 | +} |
| 111 | + |
0 commit comments