|
| 1 | +import { Button, ButtonGroup, Card } from '@blueprintjs/core' |
| 2 | + |
| 3 | +import { ComponentType, useState } from 'react' |
| 4 | +import { useParams } from 'react-router-dom' |
| 5 | + |
| 6 | +import { withGlobalErrorBoundary } from 'components/GlobalErrorBoundary' |
| 7 | +import { OperationList } from 'components/OperationList' |
| 8 | +import { OperationSetList } from 'components/OperationSetList' |
| 9 | +import { OperationDrawer } from 'components/drawer/OperationDrawer' |
| 10 | + |
| 11 | +import { CardTitle } from '../components/CardTitle' |
| 12 | +import { withSuspensable } from '../components/Suspensable' |
| 13 | + |
| 14 | +export const _ProfilePage: ComponentType = () => { |
| 15 | + const { id } = useParams() |
| 16 | + |
| 17 | + // edge case? |
| 18 | + if (!id) { |
| 19 | + throw new Error('ID 无效') |
| 20 | + } |
| 21 | + |
| 22 | + const [listMode, setListMode] = useState<'operation' | 'operationSet'>( |
| 23 | + 'operation', |
| 24 | + ) |
| 25 | + |
| 26 | + return ( |
| 27 | + <div className="flex flex-col md:flex-row px-8 mt-8 max-w-[96rem] mx-auto"> |
| 28 | + <div className="md:w-2/3 order-2 md:order-1 mr-0 md:mr-8"> |
| 29 | + <div className="mb-4 flex flex-wrap"> |
| 30 | + <ButtonGroup className="mr-2"> |
| 31 | + <Button |
| 32 | + icon="document" |
| 33 | + active={listMode === 'operation'} |
| 34 | + onClick={() => setListMode('operation')} |
| 35 | + > |
| 36 | + 作业 |
| 37 | + </Button> |
| 38 | + <Button |
| 39 | + icon="folder-close" |
| 40 | + active={listMode === 'operationSet'} |
| 41 | + onClick={() => setListMode('operationSet')} |
| 42 | + > |
| 43 | + 作业集 |
| 44 | + </Button> |
| 45 | + </ButtonGroup> |
| 46 | + </div> |
| 47 | + |
| 48 | + <div className="tabular-nums"> |
| 49 | + {listMode === 'operation' && ( |
| 50 | + <OperationList limit={10} orderBy="id" uploaderId={id} /> |
| 51 | + )} |
| 52 | + {listMode === 'operationSet' && <OperationSetList creatorId={id} />} |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + <div className="md:w-1/3 order-1 md:order-2"> |
| 56 | + <div className="sticky top-20"> |
| 57 | + <Card className="flex flex-col mb-4 space-y-2"> |
| 58 | + <CardTitle icon="user">用户名</CardTitle> |
| 59 | + </Card> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + |
| 63 | + <OperationDrawer /> |
| 64 | + </div> |
| 65 | + ) |
| 66 | +} |
| 67 | +_ProfilePage.displayName = 'ProfilePage' |
| 68 | + |
| 69 | +export const ProfilePage = withGlobalErrorBoundary( |
| 70 | + withSuspensable(_ProfilePage), |
| 71 | +) |
0 commit comments