Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/about/events.tsx
Views: 687
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 { NewsWithFuture } 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;32interface TitleComponentProps {33newsItem: NewsWithFuture;34showHelpTicket?: boolean;35}3637const TitleComponent = ({ newsItem, showHelpTicket }: TitleComponentProps) => (38<Flex justify="space-between" align="baseline" wrap="wrap">39<Flex vertical flex={1}>40<Typography.Title41level={5}42style={{43margin: 0,44}}45>46<span style={{ color: COLORS.GRAY }}>47{`${useDateStr(newsItem, false, "MMM YYYY")}`}48</span>{" "}49{newsItem.title}50{newsItem.tags ? (51<span style={{ float: "right" }}>52<TagList mode="event" tags={newsItem.tags} />53</span>54) : undefined}55</Typography.Title>56</Flex>57{showHelpTicket && (58<Flex flex={0}>59<A60target="_blank"61href={`/support/new?${new URLSearchParams({62body: `Hi there! I'd love to meet at ${newsItem.title}.`,63subject: `Meeting Request: ${newsItem.title}`,64title: "Event Visit",65type: "question",66})}`}67>68<Button69style={{70fontSize: "14px",71}}72>73👋 Come say hi!74</Button>75</A>76</Flex>77)}78</Flex>79);8081interface EventsProps {82customize: CustomizeType;83upcomingEvents: NewsWithFuture[];84pastEvents: NewsWithFuture[];85}8687export default function Events({88customize,89upcomingEvents,90pastEvents,91}: EventsProps) {92const profile = useProfile({ noCache: true });93const isAdmin = profile?.is_admin;9495function eventFooter(eventItem: NewsItem) {96return (97isAdmin && (98<Flex justify="center">99<A100key={`edit-event-${eventItem.id}`}101href={`/news/edit/${eventItem.id}`}102style={{103color: COLORS.ANTD_RED_WARN,104fontWeight: "bold",105}}106>107<Icon name="edit" /> Edit108</A>109</Flex>110)111);112}113114const upcomingEventsDataSource = upcomingEvents.map((upcomingEvent) => ({115link: upcomingEvent.url,116linkText: (117<>118Event Website <Icon name="external-link" />119</>120),121title: <TitleComponent newsItem={upcomingEvent} showHelpTicket />,122description: (123<>124<Markdown value={upcomingEvent.text} style={BODY_STYLE} />125{eventFooter(upcomingEvent)}126</>127),128})) as DataSource;129130const pastEventsDataSource = pastEvents.map((pastEvent) => ({131link: pastEvent.url,132linkText: (133<>134Event Website <Icon name="external-link" />135</>136),137title: <TitleComponent newsItem={pastEvent} />,138description: (139<>140<Markdown value={pastEvent.text} style={BODY_STYLE} />141{eventFooter(pastEvent)}142</>143),144})) as DataSource;145146return (147<Customize value={customize}>148<Head title="Where To Find Us" />149<Layout>150<Header page="about" subPage="events" />151<Layout.Content152style={{153backgroundColor: "white",154}}155>156<div157style={{158maxWidth: MAX_WIDTH,159margin: "15px auto",160padding: "15px",161backgroundColor: "white",162}}163>164<IndexList165title={166<>167<Icon name="global" style={{ marginRight: "30px" }} />168Upcoming Events169</>170}171description={172<>173{isAdmin && (174<Alert175style={{176marginTop: "12px",177marginBottom: "12px",178}}179banner={true}180type="warning"181message={182<>183Admin only:{" "}184<A href="/news/edit/new?channel=event">185Create Event186</A>187</>188}189/>190)}191We are committed to engaging with the scientific community192this upcoming year. Here, you can stay updated with where to193find us "out in the wild." We have recently participated as194exhibitors for CoCalc at popular events such as the Joint195Mathematics Meeting and SIAM's Conference on Computational196Science and Engineering. We are beyond excited to catch up197with you and tell you all about CoCalc's latest features and198our innovative plans for the future!!199</>200}201dataSource={upcomingEventsDataSource}202/>203<Divider>Past Events</Divider>204<IndexList205title={<></>}206description={<></>}207dataSource={pastEventsDataSource}208/>209</div>210<Footer />211</Layout.Content>212</Layout>213</Customize>214);215}216217export async function getServerSideProps(context: GetServerSidePropsContext) {218return await withCustomize({219context,220props: {221upcomingEvents: await getUpcomingNewsChannelItems("event"),222pastEvents: await getPastNewsChannelItems("event"),223},224});225}226227228