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 5 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,25 @@ | ||
| import Giscus from '@giscus/react'; | ||
| import { observer } from 'mobx-react'; | ||
| import { useContext } from 'react'; | ||
|
|
||
| import { I18nContext } from '../../models/Translation'; | ||
|
|
||
| export const CommentBox = observer(() => { | ||
| const { currentLanguage } = useContext(I18nContext); | ||
|
|
||
| return ( | ||
| <Giscus | ||
| repo="Open-Source-Bazaar/Open-Source-Bazaar.github.io" | ||
| repoId="R_kgDOGzCrLg" | ||
| category="Comments" | ||
| categoryId="DIC_kwDOGzCrLs4C0g_6" | ||
| mapping="pathname" | ||
| strict="0" | ||
| reactionsEnabled="1" | ||
| emitMetadata="0" | ||
| inputPosition="bottom" | ||
| theme="preferred_color_scheme" | ||
| lang={currentLanguage.startsWith('zh-') ? currentLanguage : currentLanguage.split('-')[0]} | ||
| /> | ||
| ); | ||
| }); |
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,44 @@ | ||
| import { observer } from 'mobx-react'; | ||
| import { FilePreview } from 'mobx-restful-table'; | ||
| import { FC } from 'react'; | ||
| import { CardProps, Card, Button } from 'react-bootstrap'; | ||
| import { formatDate } from 'web-utility'; | ||
|
|
||
| import { Product } from '../../models/Hackathon'; | ||
|
|
||
| export type ProductCardProps = Product & Omit<CardProps, 'id' | 'title'>; | ||
|
|
||
| export const ProductCard: FC<ProductCardProps> = observer( | ||
| ({ className = '', id, createdAt, name, sourceLink, link = sourceLink, summary, ...props }) => ( | ||
| <Card className={`border-success ${className}`} {...props}> | ||
| <Card.Body className="d-flex flex-column"> | ||
| <Card.Title | ||
| as="a" | ||
| className="text-primary" | ||
| title={name as string} | ||
| target="_blank" | ||
| href={link as string} | ||
| > | ||
| {(name || link) as string} | ||
| </Card.Title> | ||
| <p className="border-bottom p-2 text-muted text-truncate">{summary as string}</p> | ||
| <div className="border-bottom py-2 my-2 flex-fill"> | ||
| <FilePreview className="w-100" path={link as string} /> | ||
|
|
||
| {sourceLink && ( | ||
| <Button variant="success" size="sm" href={sourceLink as string}> | ||
| 🔗 Git | ||
| </Button> | ||
| )} | ||
| </div> | ||
| <time | ||
| className="d-block p-2 text-truncate" | ||
| dateTime={new Date(createdAt as number).toJSON()} | ||
| > | ||
| 📅 | ||
| {formatDate(createdAt as number)} | ||
| </time> | ||
| </Card.Body> | ||
| </Card> | ||
| ), | ||
| ); |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| import { Avatar } from 'idea-react'; | ||
| import { BiTableSchema, TableCellUser } from 'mobx-lark'; | ||
| import { observer } from 'mobx-react'; | ||
| import { cache, compose, errorLogger } from 'next-ssr-middleware'; | ||
| import { FC, useContext, useState } from 'react'; | ||
| import { | ||
| Breadcrumb, | ||
| Button, | ||
| Card, | ||
| Col, | ||
| Container, | ||
| Modal, | ||
| Ratio, | ||
| Row, | ||
| Tab, | ||
| Tabs, | ||
| } from 'react-bootstrap'; | ||
|
|
||
| import { CommentBox } from '../../../../components/Activity/CommentBox'; | ||
| import { ProductCard } from '../../../../components/Activity/ProductCard'; | ||
| import { PageHead } from '../../../../components/Layout/PageHead'; | ||
| import { Activity, ActivityModel } from '../../../../models/Activity'; | ||
| import { | ||
| Member, | ||
| MemberModel, | ||
| Product, | ||
| ProductModel, | ||
| Project, | ||
| ProjectModel, | ||
| } from '../../../../models/Hackathon'; | ||
| import { I18nContext } from '../../../../models/Translation'; | ||
|
|
||
| export const getServerSideProps = compose<Record<'id' | 'tid', string>>( | ||
| cache(), | ||
| errorLogger, | ||
| async ({ params }) => { | ||
| const activity = await new ActivityModel().getOne(params!.id); | ||
|
|
||
| // @ts-expect-error Upstream compatibility | ||
| const { appId, tableIdMap } = activity.databaseSchema; | ||
|
|
||
| const project = await new ProjectModel(appId, tableIdMap.Project).getOne(params!.tid); | ||
|
|
||
| // Get approved members for this project | ||
| const members = await new MemberModel(appId, tableIdMap.Member).getAll({ | ||
| project: project.name as string, | ||
| status: 'approved', | ||
| }); | ||
|
|
||
| // Get products for this project | ||
| const products = await new ProductModel(appId, tableIdMap.Product).getAll({ | ||
| project: project.name as string, | ||
| }); | ||
|
|
||
| return { props: { activity, project, members, products } }; | ||
| }, | ||
| ); | ||
|
|
||
| interface ProjectPageProps { | ||
| activity: Activity; | ||
| project: Project; | ||
| members: Member[]; | ||
| products: Product[]; | ||
| } | ||
|
|
||
| const ProjectPage: FC<ProjectPageProps> = observer(({ activity, project, members, products }) => { | ||
| const { t } = useContext(I18nContext); | ||
| const [showScoreModal, setShowScoreModal] = useState(false); | ||
|
|
||
| const { name: activityName, databaseSchema } = activity; | ||
| const { formLinkMap } = databaseSchema as unknown as BiTableSchema; | ||
| const { name: displayName, summary: description, createdBy, score } = project; | ||
|
|
||
| const currentRoute = [ | ||
| { title: activityName as string, href: ActivityModel.getLink(activity) }, | ||
| { title: displayName as string }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <Container as="main" className="mt-4"> | ||
| <PageHead title={`${displayName} - ${activityName}`} /> | ||
|
|
||
| <Breadcrumb aria-label="breadcrumb"> | ||
| {currentRoute.map(({ title, href }, index, { length }) => { | ||
| const isActive = index === length - 1; | ||
|
|
||
| return ( | ||
| <Breadcrumb.Item key={title} href={isActive ? undefined : href} active={isActive}> | ||
| {title} | ||
| </Breadcrumb.Item> | ||
| ); | ||
| })} | ||
| </Breadcrumb> | ||
|
|
||
| <Row className="mt-4 g-3"> | ||
| <Col xs={12} sm={4}> | ||
| <Card> | ||
| <Card.Header className="bg-white"> | ||
| <h1 className="h3 my-2">{displayName as string}</h1> | ||
| <p className="text-muted">{description as string}</p> | ||
| {score != null && ( | ||
| <div className="text-center mt-3"> | ||
| <Button variant="danger" className="fs-5" onClick={() => setShowScoreModal(true)}> | ||
| {t('score')}: {score as number} | ||
| </Button> | ||
| </div> | ||
| )} | ||
| </Card.Header> | ||
| <Card.Body> | ||
| <h2 className="text-dark fw-bold h6 mb-3">👥 {t('team_members')}</h2> | ||
| <ul className="list-unstyled"> | ||
| {members.map(({ id, person, githubAccount }) => ( | ||
| <li key={id as string} className="d-flex gap-3 align-items-center"> | ||
| {/* @ts-expect-error Upstream compatibility */} | ||
| <Avatar src={(person as TableCellUser).avatar_url} /> | ||
| <div> | ||
| <h3 className="fs-6 m-0 fw-bold">{(person as TableCellUser).name}</h3> | ||
|
|
||
| {githubAccount && ( | ||
| <a | ||
| className="text-muted small" | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| href={`https://github.com/${githubAccount}`} | ||
| > | ||
| @{githubAccount as string} | ||
| </a> | ||
| )} | ||
| </div> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </Card.Body> | ||
| </Card> | ||
| </Col> | ||
| <Col xs={12} sm={8}> | ||
| <Tabs variant="pills" defaultActiveKey="update" id="project-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"> | ||
| {products && products.length > 0 ? ( | ||
| <Row as="ul" className="list-unstyled g-3" xs={2}> | ||
| {products.map(product => ( | ||
| <Col as="li" key={product.id as string}> | ||
| <ProductCard {...product} /> | ||
| </Col> | ||
| ))} | ||
| </Row> | ||
| ) : ( | ||
| <div className="text-center text-muted my-5">{t('no_news_yet')}</div> | ||
| )} | ||
| </Tab> | ||
| </Tabs> | ||
| </Col> | ||
| </Row> | ||
|
|
||
| <Card className="my-4" 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> | ||
|
|
||
| <CommentBox /> | ||
|
|
||
| <Modal size="lg" centered show={showScoreModal} onHide={() => setShowScoreModal(false)}> | ||
| <Modal.Header closeButton> | ||
| <Modal.Title>{t('score')}</Modal.Title> | ||
| </Modal.Header> | ||
| <Modal.Body> | ||
| <Ratio aspectRatio="16x9"> | ||
| <iframe | ||
| className="w-100 h-100 border-0" | ||
| title={t('score')} | ||
| src={Object.values(formLinkMap.Evaluation)[0]} | ||
| /> | ||
| </Ratio> | ||
| </Modal.Body> | ||
| </Modal> | ||
| </Container> | ||
| ); | ||
| }); | ||
|
|
||
| export default ProjectPage; |
Oops, something went wrong.
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.