Path: blob/master/src/packages/next/pages/about/events.tsx
6036 views
import { Alert, Button, Divider, Flex, Layout, Typography } from "antd";1import { GetServerSidePropsContext } from "next";23import {4getPastNewsChannelItems,5getUpcomingNewsChannelItems,6} from "@cocalc/database/postgres/news";78import { Icon } from "@cocalc/frontend/components/icon";9import Markdown from "@cocalc/frontend/editors/slate/static-markdown";10import { NewsItem } from "@cocalc/util/dist/types/news";11import { COLORS } from "@cocalc/util/theme";1213import Footer from "components/landing/footer";14import Head from "components/landing/head";15import Header from "components/landing/header";16import IndexList, { DataSource } from "components/landing/index-list";17import { CSS } from "components/misc";18import A from "components/misc/A";19import { TagList } from "components/news/news";20import type { NewsWithStatus } from "components/news/types";21import { useDateStr } from "components/news/useDateStr";2223import { MAX_WIDTH } from "lib/config";24import { Customize, CustomizeType } from "lib/customize";25import useProfile from "lib/hooks/profile";26import withCustomize from "lib/with-customize";2728const BODY_STYLE: CSS = {29maxHeight: "max(300px, 75vh)",30overflowY: "auto",31} as const;3233interface TitleComponentProps {34newsItem: NewsWithStatus;35showHelpTicket?: boolean;36}3738const TitleComponent = ({ newsItem, showHelpTicket }: TitleComponentProps) => (39<Flex justify="space-between" align="baseline" wrap="wrap">40<Flex vertical flex={1}>41<Typography.Title42level={5}43style={{44margin: 0,45}}46>47<span style={{ color: COLORS.GRAY }}>48{`${useDateStr(newsItem, false, "MMM YYYY")}`}49</span>{" "}50{newsItem.title}51{newsItem.tags ? (52<span style={{ float: "right" }}>53<TagList mode="event" tags={newsItem.tags} />54</span>55) : undefined}56</Typography.Title>57</Flex>58{showHelpTicket && (59<Flex flex={0}>60<A61target="_blank"62href={`/support/new?${new URLSearchParams({63body: `Hi there! I'd love to meet at ${newsItem.title}.`,64subject: `Meeting Request: ${newsItem.title}`,65title: "Event Visit",66type: "question",67})}`}68>69<Button70style={{71fontSize: "14px",72}}73>74👋 Come say hi!75</Button>76</A>77</Flex>78)}79</Flex>80);8182interface EventsProps {83customize: CustomizeType;84upcomingEvents: NewsWithStatus[];85pastEvents: NewsWithStatus[];86}8788export default function Events({89customize,90upcomingEvents,91pastEvents,92}: EventsProps) {93const profile = useProfile({ noCache: true });94const isAdmin = profile?.is_admin;9596function eventFooter(eventItem: NewsItem) {97return (98isAdmin && (99<Flex justify="center">100<A101key={`edit-event-${eventItem.id}`}102href={`/news/edit/${eventItem.id}`}103style={{104color: COLORS.ANTD_RED_WARN,105fontWeight: "bold",106}}107>108<Icon name="edit" /> Edit109</A>110</Flex>111)112);113}114115const upcomingEventsDataSource = upcomingEvents.map((upcomingEvent) => ({116link: upcomingEvent.url,117linkText: (118<>119Event Website <Icon name="external-link" />120</>121),122title: <TitleComponent newsItem={upcomingEvent} showHelpTicket />,123description: (124<>125<Markdown value={upcomingEvent.text} style={BODY_STYLE} />126{eventFooter(upcomingEvent)}127</>128),129})) as DataSource;130131const pastEventsDataSource = pastEvents.map((pastEvent) => ({132link: pastEvent.url,133linkText: (134<>135Event Website <Icon name="external-link" />136</>137),138title: <TitleComponent newsItem={pastEvent} />,139description: (140<>141<Markdown value={pastEvent.text} style={BODY_STYLE} />142{eventFooter(pastEvent)}143</>144),145})) as DataSource;146147return (148<Customize value={customize}>149<Head title="Where To Find Us" />150<Layout>151<Header page="about" subPage="events" />152<Layout.Content153style={{154backgroundColor: "white",155}}156>157<div158style={{159maxWidth: MAX_WIDTH,160margin: "15px auto",161padding: "15px",162backgroundColor: "white",163}}164>165<IndexList166title={167<>168<Icon name="global" style={{ marginRight: "30px" }} />169Upcoming Events170</>171}172description={173<>174{isAdmin && (175<Alert176style={{177marginTop: "12px",178marginBottom: "12px",179}}180banner={true}181type="warning"182message={183<>184Admin only:{" "}185<A href="/news/edit/new?channel=event">186Create Event187</A>188</>189}190/>191)}192We are committed to engaging with the scientific community193this upcoming year. Here, you can stay updated with where to194find us "out in the wild." We have recently participated as195exhibitors for CoCalc at popular events such as the Joint196Mathematics Meeting and SIAM's Conference on Computational197Science and Engineering. We are beyond excited to catch up198with you and tell you all about CoCalc's latest features and199our innovative plans for the future!!200</>201}202dataSource={upcomingEventsDataSource}203/>204<Divider>Past Events</Divider>205<IndexList206title={<></>}207description={<></>}208dataSource={pastEventsDataSource}209/>210</div>211<Footer />212</Layout.Content>213</Layout>214</Customize>215);216}217218export async function getServerSideProps(context: GetServerSidePropsContext) {219return await withCustomize({220context,221props: {222upcomingEvents: await getUpcomingNewsChannelItems("event"),223pastEvents: await getPastNewsChannelItems("event"),224},225});226}227228229