generated from idea2app/Next-Bootstrap-ts
-
Notifications
You must be signed in to change notification settings - Fork 6
[add] Hackathon Project page & components #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0fe73e3
Initial plan
Copilot f792593
Add team detail page with translations and routing
Copilot ab6d52e
Add MemberModel, ProductModel, and CommentBox component
Copilot e7d9c95
Refactor team page: remove manual filtering and improve code quality
Copilot 7a53794
[add] Product Card & Comment Box components
TechQuery 6d3896c
Apply hackathon homepage styling and enhance ProductCard with cloud I…
Copilot eedf55f
[fix] 2 Lark type bugs
TechQuery 200b18a
Redesign ProductCard with hackathon gradient styling and text buttons
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| import { TableCellUser } from 'mobx-lark'; | ||
| import { observer } from 'mobx-react'; | ||
| import { cache, compose, errorLogger } from 'next-ssr-middleware'; | ||
| import { FC, useContext } from 'react'; | ||
| import { Badge, Card, Col, Container, Row, Tab, Tabs } from 'react-bootstrap'; | ||
|
|
||
| import { LarkImage } from '../../../../components/LarkImage'; | ||
| import { PageHead } from '../../../../components/Layout/PageHead'; | ||
| import { Activity, ActivityModel } from '../../../../models/Activity'; | ||
| import { Person, PersonModel, Project, ProjectModel } from '../../../../models/Hackathon'; | ||
| import { I18nContext } from '../../../../models/Translation'; | ||
|
|
||
| export const getServerSideProps = compose<{ id: string; tid: string }>( | ||
| cache(), | ||
| errorLogger, | ||
| async ({ params }) => { | ||
| const activityModel = new ActivityModel(); | ||
| const activity = await activityModel.getOne(params!.id); | ||
|
|
||
| // @ts-expect-error Upstream compatibility | ||
| const { appId, tableIdMap } = activity.databaseSchema; | ||
|
|
||
| const projectModel = new ProjectModel(appId, tableIdMap.Project); | ||
| const team = await projectModel.getOne(params!.tid); | ||
|
|
||
| const personModel = new PersonModel(appId, tableIdMap.Person); | ||
| const allPeople = await personModel.getAll(); | ||
|
|
||
| // Filter team members from all people based on the team's members field | ||
| const teamMemberNames = (team.members as string[]) || []; | ||
| const teamMembers = allPeople.filter((person) => | ||
| teamMemberNames.includes(person.name as string), | ||
| ); | ||
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return { | ||
| props: { | ||
| activity, | ||
| team, | ||
| teamMembers, | ||
| }, | ||
| }; | ||
| }, | ||
| ); | ||
|
|
||
| interface TeamPageProps { | ||
| activity: Activity; | ||
| team: Project; | ||
| teamMembers: Person[]; | ||
| } | ||
|
|
||
| const TeamPage: FC<TeamPageProps> = observer(({ activity, team, teamMembers }) => { | ||
| const { t } = useContext(I18nContext); | ||
|
|
||
| const { name: activityName } = activity; | ||
| const { name: displayName, summary: description, createdBy, score } = team; | ||
|
|
||
| const currentRoute = [ | ||
| { title: activityName as string, href: `/hackathon/${activityName}` }, | ||
| { title: displayName as string }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <Container as="main" className="mt-4"> | ||
| <PageHead title={`${displayName} - ${activityName}`} /> | ||
|
|
||
| <nav aria-label="breadcrumb"> | ||
| <ol className="breadcrumb"> | ||
| {currentRoute.map(({ title, href }) => | ||
| href ? ( | ||
| <li key={title} className="breadcrumb-item"> | ||
| <a href={href}>{title}</a> | ||
| </li> | ||
| ) : ( | ||
| <li key={title} className="breadcrumb-item active" aria-current="page"> | ||
| {title} | ||
| </li> | ||
| ), | ||
| )} | ||
| </ol> | ||
| </nav> | ||
|
|
||
| <Row className="mt-4"> | ||
| <Col xs={12} sm={4}> | ||
| <Card style={{ minWidth: '15rem' }}> | ||
| <Card.Header className="bg-white"> | ||
| <h1 className="h3 my-2">{displayName as string}</h1> | ||
| <p className="text-muted">{description as string}</p> | ||
| {score !== undefined && ( | ||
| <div className="text-center mt-3"> | ||
| <Badge bg="primary" className="fs-5"> | ||
| {t('score')}: {score as number} | ||
| </Badge> | ||
| </div> | ||
| )} | ||
| </Card.Header> | ||
| <Card.Body> | ||
| <h2 className="text-dark fw-bold h6 mb-3"> | ||
| 👥 {t('team_members')} | ||
| </h2> | ||
| <ul className="list-unstyled"> | ||
| {teamMembers.map((member) => ( | ||
| <li key={member.id as string} className="mb-3"> | ||
| <div className="d-flex align-items-center"> | ||
| <LarkImage | ||
| src={member.avatar} | ||
| alt={member.name as string} | ||
| className="rounded-circle me-2" | ||
| style={{ width: '40px', height: '40px' }} | ||
| /> | ||
| <div> | ||
| <div className="fw-bold">{member.name as string}</div> | ||
| {member.githubLink && ( | ||
| <a | ||
| href={member.githubLink as string} | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| className="text-muted small" | ||
| > | ||
| {t('view_github')} | ||
| </a> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </Card.Body> | ||
| </Card> | ||
| </Col> | ||
| <Col xs={12} sm={8}> | ||
| <Tabs defaultActiveKey="update" id="team-detail-tabs"> | ||
| <Tab className="pt-2" eventKey="update" title={t('latest_news')}> | ||
| <div className="h1 my-5 text-center text-muted">{t('no_news_yet')}</div> | ||
| </Tab> | ||
| <Tab eventKey="teamWork" title={t('team_works')} className="pt-2"> | ||
| <div className="mt-3"> | ||
| {team.products && (team.products as string[]).length > 0 ? ( | ||
| <ul className="list-unstyled"> | ||
| {(team.products as string[]).map((product, index) => ( | ||
| <li key={index} className="mb-2"> | ||
| <Card body> | ||
| <h5>{product}</h5> | ||
| </Card> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) : ( | ||
| <div className="text-center text-muted my-5"> | ||
| {t('no_news_yet')} | ||
| </div> | ||
| )} | ||
| </div> | ||
| </Tab> | ||
| </Tabs> | ||
| </Col> | ||
| </Row> | ||
|
|
||
| {createdBy && ( | ||
| <Row className="mt-4"> | ||
| <Col> | ||
| <Card> | ||
| <Card.Body> | ||
| <h3 className="h5">{t('created_by')}</h3> | ||
| <div className="mt-3"> | ||
| <div className="fw-bold">{(createdBy as TableCellUser).name}</div> | ||
| <a | ||
| href={`mailto:${(createdBy as TableCellUser).email}`} | ||
| className="text-muted" | ||
| > | ||
| {(createdBy as TableCellUser).email} | ||
| </a> | ||
| </div> | ||
| </Card.Body> | ||
| </Card> | ||
| </Col> | ||
| </Row> | ||
| )} | ||
| </Container> | ||
| ); | ||
| }); | ||
|
|
||
| export default TeamPage; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.