|
| 1 | +import { AppScreen } from '@stackflow/plugin-basic-ui'; |
| 2 | +import { IoChevronForward } from 'react-icons/io5'; |
| 3 | + |
| 4 | +import { useFlow } from '@/app/stackflow'; |
| 5 | +import { ProfileIcon } from '@/assets/icon'; |
| 6 | + |
| 7 | +import { Button, TitleAppBar } from '@/shared/ui'; |
| 8 | +import { fetchSessionData, logout } from '@/shared/utils'; |
| 9 | +import { PATH } from '@/shared/constants'; |
| 10 | +import type { User } from '@/shared/types'; |
| 11 | + |
| 12 | +export default function UserScreen() { |
| 13 | + const { name, collegeMajorName } = fetchSessionData('userInfo') as User; |
| 14 | + const { push } = useFlow(); |
| 15 | + |
| 16 | + return ( |
| 17 | + <AppScreen backgroundColor="#fff" appBar={TitleAppBar('')}> |
| 18 | + <div className="p-normal flex size-full flex-col"> |
| 19 | + <div className="mb-[35px] flex w-full flex-col items-center justify-center"> |
| 20 | + <img src={ProfileIcon} className="size-25" /> |
| 21 | + <p className="text-m mt-4 text-center text-2xl font-bold">{name}</p> |
| 22 | + <p className="mt-2.5">202311509</p> |
| 23 | + <p>{collegeMajorName}</p> |
| 24 | + </div> |
| 25 | + <div className="shadow-resultItem mb-[15px] flex h-42 w-full gap-x-3 rounded-lg bg-white px-3 py-[17px]"> |
| 26 | + <InfoItem item="3회" label="나의 투표참여 횟수" /> |
| 27 | + <div className="h-full w-[1px] bg-[#ECECEC]" /> |
| 28 | + <InfoItem item="59%" label="전체 투표 참여율" /> |
| 29 | + <div className="h-full w-[1px] bg-[#ECECEC]" /> |
| 30 | + <InfoItem item="51%" label="학과 평균 참여율" /> |
| 31 | + </div> |
| 32 | + <Button |
| 33 | + intent="gradient" |
| 34 | + className="mb-13" |
| 35 | + onClick={() => push(PATH.USER_VOTE_STATUS, {})} |
| 36 | + > |
| 37 | + 내 투표내역 보기 |
| 38 | + </Button> |
| 39 | + <UserScreenButton label="문의하기" onClick={() => {}} /> |
| 40 | + <UserScreenButton |
| 41 | + label="로그아웃" |
| 42 | + onClick={() => { |
| 43 | + logout(); |
| 44 | + }} |
| 45 | + /> |
| 46 | + </div> |
| 47 | + </AppScreen> |
| 48 | + ); |
| 49 | +} |
| 50 | + |
| 51 | +const InfoItem = ({ item, label }: { item: string; label: string }) => ( |
| 52 | + <div className="flex flex-1 flex-col items-center justify-center gap-y-[7px]"> |
| 53 | + <p className="text-m text-2xl font-bold">{item}</p> |
| 54 | + <p className="text-[13px] font-light">{label}</p> |
| 55 | + </div> |
| 56 | +); |
| 57 | + |
| 58 | +const UserScreenButton = ({ |
| 59 | + label, |
| 60 | + onClick, |
| 61 | +}: { |
| 62 | + label: string; |
| 63 | + onClick: () => void; |
| 64 | +}) => ( |
| 65 | + <button |
| 66 | + className="shadow-resultItem mb-4 flex items-center justify-between rounded-md px-[18px] py-5" |
| 67 | + onClick={onClick} |
| 68 | + > |
| 69 | + {label} |
| 70 | + <IoChevronForward size={20} /> |
| 71 | + </button> |
| 72 | +); |
0 commit comments