Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
chore: lots of wip (#76)
Maximilian Kaske9b9a417de4e0
diff --git a/.gitignore b/.gitignoreindex 95515f61c..94ecd4a82 100644--- a/.gitignore+++ b/.gitignore@@ -47,4 +47,6 @@ packages/db/openstatus.db-walopenstatus.db-walopenstatus.dbopenstatus.db-shm++packages/tinybird/.tinybdiff --git a/apps/web/package.json b/apps/web/package.jsonindex bb0a83fac..3ed1a1758 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -18,6 +18,7 @@"@openstatus/upstash": "workspace:*","@radix-ui/react-accordion": "^1.1.2","@radix-ui/react-alert-dialog": "^1.0.4",+ "@radix-ui/react-checkbox": "^1.0.4","@radix-ui/react-dialog": "^1.0.4","@radix-ui/react-dropdown-menu": "^2.0.5","@radix-ui/react-hover-card": "^1.0.6",diff --git a/apps/web/src/app/app/(dashboard)/layout.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/layout.tsxsimilarity index 100%rename from apps/web/src/app/app/(dashboard)/layout.tsxrename to apps/web/src/app/app/(dashboard)/[workspaceId]/layout.tsxdiff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/action-button.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/action-button.tsxindex 54443cef5..2b7a9fada 100644--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/action-button.tsx+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/action-button.tsx@@ -122,16 +122,18 @@ export function ActionButton(props: Schema) {</AlertDialogFooter></AlertDialogContent></AlertDialog>- <DialogContent>+ <DialogContent className="flex max-h-screen flex-col"><DialogHeader><DialogTitle>Update Monitor</DialogTitle><DialogDescription>Change your settings.</DialogDescription></DialogHeader>- <MonitorForm- id="monitor-update"- onSubmit={onUpdate}- defaultValues={props}- />+ <div className="-mx-1 flex-1 overflow-y-scroll px-1">+ <MonitorForm+ id="monitor-update"+ onSubmit={onUpdate}+ defaultValues={props}+ />+ </div><DialogFooter><Buttontype="submit"diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/create-form.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/create-form.tsxindex cbf8cef39..fd8154734 100644--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/create-form.tsx+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/create-form.tsx@@ -20,6 +20,8 @@ import {} from "@/components/ui/dialog";import { api } from "@/trpc/client";+type MonitorSchema = z.infer<typeof insertMonitorSchema>;+interface Props {workspaceId: number;}@@ -29,7 +31,7 @@ export function CreateForm({ workspaceId }: Props) {const [open, setOpen] = React.useState(false);const [saving, setSaving] = React.useState(false);- async function onCreate(values: z.infer<typeof insertMonitorSchema>) {+ async function onCreate(values: MonitorSchema) {setSaving(true);// await api.monitor.getMonitorsByWorkspace.revalidate();await api.monitor.createMonitor.mutate({ ...values, workspaceId });@@ -43,12 +45,14 @@ export function CreateForm({ workspaceId }: Props) {<DialogTrigger asChild><Button>Create</Button></DialogTrigger>- <DialogContent>+ <DialogContent className="flex max-h-screen flex-col"><DialogHeader><DialogTitle>Create Monitor</DialogTitle><DialogDescription>Choose the settings.</DialogDescription></DialogHeader>- <MonitorForm id="monitor-create" onSubmit={onCreate} />+ <div className="-mx-1 flex-1 overflow-y-scroll px-1">+ <MonitorForm id="monitor-create" onSubmit={onCreate} />+ </div><DialogFooter><Button type="submit" form="monitor-create" disabled={saving}>{!saving ? "Confirm" : <LoadingAnimation />}diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/empty-state.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/empty-state.tsxnew file mode 100644index 000000000..845b0b7bc--- /dev/null+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/_components/empty-state.tsx@@ -0,0 +1,13 @@+import { EmptyState as DefaultEmptyState } from "@/components/dashboard/empty-state";+import { CreateForm } from "./create-form";++export function EmptyState({ workspaceId }: { workspaceId: number }) {+ return (+ <DefaultEmptyState+ icon="activity"+ title="No monitors"+ description="Create your first monitor"+ action={<CreateForm {...{ workspaceId }} />}+ />+ );+}diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/page.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/page.tsxindex 0a30e02cc..2198c630a 100644--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/page.tsx+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitors/page.tsx@@ -7,6 +7,7 @@ import { cn } from "@/lib/utils";import { api } from "@/trpc/server";import { ActionButton } from "./_components/action-button";import { CreateForm } from "./_components/create-form";+import { EmptyState } from "./_components/empty-state";export default async function MonitorPage({params,@@ -23,46 +24,52 @@ export default async function MonitorPage({<Header title="Monitors" description="Overview of all your monitors."><CreateForm {...{ workspaceId }} /></Header>- {monitors?.map((monitor, index) => (- <Container- key={index}- title={monitor.name}- description={monitor.description}- >- <ActionButton {...monitor} />- <dl className="[&_dt]:text-muted-foreground grid gap-2 [&>*]:text-sm [&_dt]:font-light">- <div className="flex min-w-0 items-center justify-between gap-3">- <dt>Status</dt>- <dd>- <Badge- variant={monitor.status === "active" ? "default" : "outline"}- className="capitalize"- >- {monitor.status}- <span- className={cn(- "ml-1 h-1.5 w-1.5 rounded-full",- monitor.status === "active"- ? "bg-green-500"- : "bg-red-500",- )}- />- </Badge>- </dd>- </div>- <div className="flex min-w-0 items-center justify-between gap-3">- <dt>Periodicity</dt>- <dd className="font-mono">{monitor.periodicity}</dd>- </div>- <div className="flex min-w-0 items-center justify-between gap-3">- <dt>URL</dt>- <dd className="overflow-hidden text-ellipsis font-semibold">- {monitor.url}- </dd>- </div>- </dl>- </Container>- ))}+ {Boolean(monitors?.length) ? (+ monitors?.map((monitor, index) => (+ <Container+ key={index}+ title={monitor.name}+ description={monitor.description}+ >+ <ActionButton {...monitor} />+ <dl className="[&_dt]:text-muted-foreground grid gap-2 [&>*]:text-sm [&_dt]:font-light">+ <div className="flex min-w-0 items-center justify-between gap-3">+ <dt>Status</dt>+ <dd>+ <Badge+ variant={+ monitor.status === "active" ? "default" : "outline"+ }+ className="capitalize"+ >+ {monitor.status}+ <span+ className={cn(+ "ml-1 h-1.5 w-1.5 rounded-full",+ monitor.status === "active"+ ? "bg-green-500"+ : "bg-red-500",+ )}+ />+ </Badge>+ </dd>+ </div>+ <div className="flex min-w-0 items-center justify-between gap-3">+ <dt>Periodicity</dt>+ <dd className="font-mono">{monitor.periodicity}</dd>+ </div>+ <div className="flex min-w-0 items-center justify-between gap-3">+ <dt>URL</dt>+ <dd className="overflow-hidden text-ellipsis font-semibold">+ {monitor.url}+ </dd>+ </div>+ </dl>+ </Container>+ ))+ ) : (+ <EmptyState {...{ workspaceId }} />+ )}</div>);}diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/page.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/page.tsxindex 50d246e24..ebeccf1dc 100644--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/page.tsx+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/page.tsx@@ -1,6 +1,6 @@import { redirect } from "next/navigation";-export default function DiscordRedirect({+export default function DashboardRedirect({params,}: {params: { workspaceId: string };diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/action-button.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/action-button.tsxindex 9664da159..f142ffb8f 100644--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/action-button.tsx+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/action-button.tsx@@ -1,12 +1,14 @@"use client";import * as React from "react";-import Link from "next/link";-import { useParams, usePathname, useRouter } from "next/navigation";+import { useRouter } from "next/navigation";import { MoreVertical } from "lucide-react";import type * as z from "zod";-import type { insertPageSchema } from "@openstatus/db/src/schema";+import type {+ insertMonitorSchema,+ insertPageSchema,+} from "@openstatus/db/src/schema";import { StatusPageForm } from "@/components/forms/status-page-form";import { LoadingAnimation } from "@/components/loading-animation";@@ -37,21 +39,34 @@ import {DropdownMenuItem,DropdownMenuTrigger,} from "@/components/ui/dropdown-menu";-import { wait } from "@/lib/utils";import { api } from "@/trpc/client";-type Schema = z.infer<typeof insertPageSchema>;+type MonitorSchema = z.infer<typeof insertMonitorSchema>;+type PageSchema = z.infer<typeof insertPageSchema>;-export function ActionButton(props: Schema) {+// allMonitors+interface ActionButtonProps {+ page: PageSchema;+ allMonitors?: MonitorSchema[];+}++export function ActionButton({ page, allMonitors }: ActionButtonProps) {const router = useRouter();const [dialogOpen, setDialogOpen] = React.useState(false);const [alertOpen, setAlertOpen] = React.useState(false);const [saving, setSaving] = React.useState(false);- async function onUpdate(values: Schema) {+ async function onUpdate({+ monitors,+ workspaceId,+ ...props+ }: PageSchema & { monitors: string[] }) {setSaving(true);- // await api.monitor.updateMonitor.mutate({ id: props.id, ...values });- await wait(1000);+ await api.page.updatePage.mutate({+ id: page.id,+ workspaceId: page.workspaceId,+ ...props,+ });router.refresh();setSaving(false);setDialogOpen(false);@@ -59,8 +74,7 @@ export function ActionButton(props: Schema) {async function onDelete() {setSaving(true);- // await api.monitor.deleteMonitor.mutate({ monitorId: Number(props.id) });- await wait(1000);+ await api.page.deletePage.mutate({ pageId: Number(page.id) });router.refresh();setSaving(false);setAlertOpen(false);@@ -116,16 +130,24 @@ export function ActionButton(props: Schema) {</AlertDialogFooter></AlertDialogContent></AlertDialog>- <DialogContent>+ <DialogContent className="flex max-h-screen flex-col"><DialogHeader><DialogTitle>Update Page</DialogTitle><DialogDescription>Change your settings.</DialogDescription></DialogHeader>- <StatusPageForm- id="status-page-update"- onSubmit={onUpdate}- defaultValues={props}- />+ <div className="-mx-1 flex-1 overflow-y-scroll px-1">+ <StatusPageForm+ id="status-page-update"+ onSubmit={onUpdate}+ defaultValues={page}+ allMonitors={+ allMonitors?.map((m) => ({+ label: m.name || "",+ value: String(m.id) || "",+ })) ?? []+ }+ />+ </div><DialogFooter><Buttontype="submit"diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/create-form.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/create-form.tsxindex 5d1d2f0bb..c6728ce1b 100644--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/create-form.tsx+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/create-form.tsx@@ -4,7 +4,10 @@ import * as React from "react";import { useRouter } from "next/navigation";import type * as z from "zod";-import type { insertPageSchema } from "@openstatus/db/src/schema";+import type {+ insertMonitorSchema,+ insertPageSchema,+} from "@openstatus/db/src/schema";import { StatusPageForm } from "@/components/forms/status-page-form";import { LoadingAnimation } from "@/components/loading-animation";@@ -20,19 +23,27 @@ import {} from "@/components/ui/dialog";import { api } from "@/trpc/client";+type MonitorSchema = z.infer<typeof insertMonitorSchema>;+type PageSchema = z.infer<typeof insertPageSchema>;+interface Props {workspaceId: number;+ allMonitors?: MonitorSchema[];+ disabled?: boolean;}-export function CreateForm({ workspaceId }: Props) {+export function CreateForm({ workspaceId, allMonitors, disabled }: Props) {const router = useRouter();const [open, setOpen] = React.useState(false);const [saving, setSaving] = React.useState(false);- async function onCreate(values: z.infer<typeof insertPageSchema>) {+ async function onCreate({+ monitors, // TODO:+ ...props+ }: PageSchema & { monitors: string[] }) {setSaving(true);// await api.monitor.getMonitorsByWorkspace.revalidate();- await api.page.createPage.mutate({ ...values, workspaceId });+ await api.page.createPage.mutate({ ...props, workspaceId });router.refresh();setSaving(false);setOpen(false);@@ -41,14 +52,25 @@ export function CreateForm({ workspaceId }: Props) {return (<Dialog open={open} onOpenChange={(value) => setOpen(value)}><DialogTrigger asChild>- <Button>Create</Button>+ <Button disabled={disabled}>Create</Button></DialogTrigger>- <DialogContent>+ <DialogContent className="flex max-h-screen flex-col"><DialogHeader><DialogTitle>Create Status Page</DialogTitle><DialogDescription>Choose the settings.</DialogDescription></DialogHeader>- <StatusPageForm id="status-page-create" onSubmit={onCreate} />+ <div className="-mx-1 flex-1 overflow-y-scroll px-1">+ <StatusPageForm+ id="status-page-create"+ onSubmit={onCreate}+ allMonitors={+ allMonitors?.map((m) => ({+ label: m.name || "",+ value: String(m.id) || "",+ })) ?? []+ }+ />+ </div><DialogFooter><Button type="submit" form="status-page-create" disabled={saving}>{!saving ? "Confirm" : <LoadingAnimation />}diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/empty-state.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/empty-state.tsxnew file mode 100644index 000000000..4e04e771b--- /dev/null+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/_components/empty-state.tsx@@ -0,0 +1,42 @@+import Link from "next/link";+import type * as z from "zod";++import type { insertMonitorSchema } from "@openstatus/db/src/schema";++import { EmptyState as DefaultEmptyState } from "@/components/dashboard/empty-state";+import { Button } from "@/components/ui/button";+import { CreateForm } from "./create-form";++type MonitorSchema = z.infer<typeof insertMonitorSchema>;++export function EmptyState({+ workspaceId,+ allMonitors,+}: {+ workspaceId: number;+ allMonitors?: MonitorSchema[];+}) {+ // Navigate user to monitor if they don't have one+ if (!Boolean(allMonitors?.length)) {+ return (+ <DefaultEmptyState+ icon="panel-top"+ title="No pages"+ description="First create a monitor before creating a page."+ action={+ <Button asChild>+ <Link href="./monitors">Go to monitors</Link>+ </Button>+ }+ />+ );+ }+ return (+ <DefaultEmptyState+ icon="panel-top"+ title="No pages"+ description="Create your first page."+ action={<CreateForm {...{ workspaceId, allMonitors }} />}+ />+ );+}diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/page.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/page.tsxindex 25541c192..1b24cef69 100644--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/page.tsx+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/status-pages/page.tsx@@ -5,6 +5,7 @@ import { Header } from "@/components/dashboard/header";import { api } from "@/trpc/server";import { ActionButton } from "./_components/action-button";import { CreateForm } from "./_components/create-form";+import { EmptyState } from "./_components/empty-state";export default async function Page({params,@@ -15,30 +16,41 @@ export default async function Page({const pages = await api.page.getPageByWorkspace.query({workspaceId,});- // iterate over pages+ const monitors = await api.monitor.getMonitorsByWorkspace.query({+ workspaceId,+ });+return (<div className="grid gap-6 md:grid-cols-2 md:gap-8"><Headertitle="Status Page"description="Overview of all your status page.">- <CreateForm {...{ workspaceId }} />+ <CreateForm+ workspaceId={workspaceId}+ allMonitors={monitors}+ disabled={!Boolean(monitors)}+ /></Header>- {pages.map((page, index) => (- <Container- key={index}- title={page.title}- description={page.description}- >- <ActionButton {...page} />- <dl className="[&_dt]:text-muted-foreground grid gap-2 [&>*]:text-sm [&_dt]:font-light">- <div className="flex min-w-0 items-center justify-between gap-3">- <dt>Slug</dt>- <dd className="font-mono">{page.slug}</dd>- </div>- </dl>- </Container>- ))}+ {Boolean(pages.length) ? (+ pages.map((page, index) => (+ <Container+ key={index}+ title={page.title}+ description={page.description}+ >+ <ActionButton page={page} allMonitors={monitors} />+ <dl className="[&_dt]:text-muted-foreground grid gap-2 [&>*]:text-sm [&_dt]:font-light">+ <div className="flex min-w-0 items-center justify-between gap-3">+ <dt>Slug</dt>+ <dd className="font-mono">{page.slug}</dd>+ </div>+ </dl>+ </Container>+ ))+ ) : (+ <EmptyState workspaceId={workspaceId} allMonitors={monitors} />+ )}</div>);}diff --git a/apps/web/src/app/app/page.tsx b/apps/web/src/app/app/page.tsxnew file mode 100644index 000000000..e74dcce7a--- /dev/null+++ b/apps/web/src/app/app/page.tsx@@ -0,0 +1,27 @@+"use client";++import * as React from "react";+import { useRouter } from "next/navigation";++import { Shell } from "@/components/dashboard/shell";+import { LoadingAnimation } from "@/components/loading-animation";++// TODO: discuss how to make that page a bit more enjoyable+export default function Page() {+ const router = useRouter();++ // waiting for the workspace to be created+ setTimeout(() => router.refresh(), 1000);++ return (+ <div className="flex min-h-screen flex-col items-center justify-center">+ <Shell className="mx-auto grid w-auto gap-4">+ <div className="grid gap-1 text-center">+ <p className="text-lg font-bold">Creating Workspace</p>+ <p className="text-muted-foreground">Should be done in a second.</p>+ </div>+ <LoadingAnimation variant="inverse" size="lg" />+ </Shell>+ </div>+ );+}diff --git a/apps/web/src/app/github/page.tsx b/apps/web/src/app/github/page.tsxnew file mode 100644index 000000000..25e2c8d52--- /dev/null+++ b/apps/web/src/app/github/page.tsx@@ -0,0 +1,5 @@+import { redirect } from "next/navigation";++export default function GithubRedirect() {+ return redirect("https://github.com/openstatusHQ/openstatus");+}diff --git a/apps/web/src/components/dashboard/empty-state.tsx b/apps/web/src/components/dashboard/empty-state.tsxnew file mode 100644index 000000000..f73541a20--- /dev/null+++ b/apps/web/src/components/dashboard/empty-state.tsx@@ -0,0 +1,27 @@+import * as React from "react";++import type { ValidIcon } from "@/components/icons";+import { Icons } from "@/components/icons";++interface Props extends React.ComponentProps<"div"> {+ icon: ValidIcon;+ title: string;+ description: string;+ action: React.ReactNode;+}++export function EmptyState({ icon, title, description, action }: Props) {+ const Icon = Icons[icon];+ return (+ <div className="border-border bg-background col-span-full w-full rounded-lg border border-dashed p-8">+ <div className="flex flex-col items-center justify-center gap-4">+ <div className="flex flex-col items-center justify-center gap-1">+ <Icon className="h-6 w-6" />+ <p className="text-foreground text-base">{title}</p>+ <p className="text-muted-foreground">{description}</p>+ </div>+ <div>{action}</div>+ </div>+ </div>+ );+}diff --git a/apps/web/src/components/forms/status-page-form.tsx b/apps/web/src/components/forms/status-page-form.tsxindex 4642b14b8..daeceb72e 100644--- a/apps/web/src/components/forms/status-page-form.tsx+++ b/apps/web/src/components/forms/status-page-form.tsx@@ -1,8 +1,9 @@"use client";+import * as React from "react";import { zodResolver } from "@hookform/resolvers/zod";import { useForm } from "react-hook-form";-import type * as z from "zod";+import * as z from "zod";import { insertPageSchema } from "@openstatus/db/src/schema";@@ -16,23 +17,39 @@ import {FormMessage,} from "@/components/ui/form";import { Input } from "@/components/ui/input";+import { Checkbox } from "../ui/checkbox";-type Schema = z.infer<typeof insertPageSchema>;+// REMINDER: only use the props you need!+const schema = insertPageSchema+ .pick({ title: true, slug: true, description: true })+ .merge(+ z.object({+ monitors: z.string().array().optional(), // HOW TO PASS+ }),+ );++type Schema = z.infer<typeof schema>;interface Props {id: string;defaultValues?: Schema;onSubmit: (values: Schema) => Promise<void>;+ allMonitors?: Record<"label" | "value", string>[];}-export function StatusPageForm({ id, defaultValues, onSubmit }: Props) {+export function StatusPageForm({+ id,+ defaultValues,+ onSubmit,+ allMonitors,+}: Props) {const form = useForm<Schema>({- resolver: zodResolver(insertPageSchema),+ resolver: zodResolver(schema),defaultValues: {title: defaultValues?.title || "",- slug: defaultValues?.slug || "",+ slug: defaultValues?.slug || "", // TODO: verify if is uniquedescription: defaultValues?.description || "",- workspaceId: defaultValues?.workspaceId || 0,+ monitors: [],},});@@ -86,6 +103,57 @@ export function StatusPageForm({ id, defaultValues, onSubmit }: Props) {</FormItem>)}/>+ <FormField+ control={form.control}+ name="monitors"+ render={() => (+ <FormItem>+ <div className="mb-4">+ <FormLabel className="text-base">Monitor</FormLabel>+ <FormDescription>+ Select the monitors you want to display.+ </FormDescription>+ </div>+ {allMonitors?.map((item) => (+ <FormField+ key={item.value}+ control={form.control}+ name="monitors"+ render={({ field }) => {+ return (+ <FormItem+ key={item.value}+ className="flex flex-row items-start space-x-3 space-y-0"+ >+ <FormControl>+ <Checkbox+ checked={field.value?.includes(item.value)}+ onCheckedChange={(checked) => {+ return checked+ ? field.onChange([+ ...(field.value || []),+ item.value,+ ])+ : field.onChange(+ field.value?.filter(+ (value) => value !== item.value,+ ),+ );+ }}+ />+ </FormControl>+ <FormLabel className="font-normal">+ {item.label}+ </FormLabel>+ </FormItem>+ );+ }}+ />+ ))}+ <FormMessage />+ </FormItem>+ )}+ /></div></form></Form>diff --git a/apps/web/src/components/icons.tsx b/apps/web/src/components/icons.tsxindex c7196493c..a48a64cc1 100644--- a/apps/web/src/components/icons.tsx+++ b/apps/web/src/components/icons.tsx@@ -18,4 +18,20 @@ export const Icons = {siren: Siren,"panel-top": PanelTop,table: Table,+ discord: ({ ...props }: LucideProps) => (+ <svg viewBox="0 0 640 512" {...props}>+ <path+ fill="currentColor"+ d="M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"+ />+ </svg>+ ),+ github: (props: LucideProps) => (+ <svg viewBox="0 0 438.549 438.549" {...props}>+ <path+ fill="currentColor"+ d="M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8-33.598-19.607-70.277-29.408-110.063-29.408-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z"+ ></path>+ </svg>+ ),} as const;diff --git a/apps/web/src/components/layout/app-header.tsx b/apps/web/src/components/layout/app-header.tsxindex ce746296a..0d0ee7b8f 100644--- a/apps/web/src/components/layout/app-header.tsx+++ b/apps/web/src/components/layout/app-header.tsx@@ -3,7 +3,10 @@import Link from "next/link";import { UserButton, useUser } from "@clerk/nextjs";+import { socialsConfig } from "@/config/socials";import { Shell } from "../dashboard/shell";+import { Icons } from "../icons";+import { Button } from "../ui/button";import { Skeleton } from "../ui/skeleton";export function AppHeader() {@@ -18,11 +21,28 @@ export function AppHeader() {>openstatus</Link>- {!isLoaded && !isSignedIn ? (- <Skeleton className="h-8 w-8 rounded-full" />- ) : (- <UserButton />- )}+ <div className="flex items-center gap-4">+ {/* can be moved to a different place */}+ <ul className="flex gap-2">+ {socialsConfig.map(({ title, href, icon }) => {+ const Icon = Icons[icon];+ return (+ <li key={title} className="w-full">+ <Button size="icon" variant="ghost" asChild>+ <a href={href} target="_blank" rel="noreferrer">+ <Icon className="h-5 w-5" />+ </a>+ </Button>+ </li>+ );+ })}+ </ul>+ {!isLoaded && !isSignedIn ? (+ <Skeleton className="h-8 w-8 rounded-full" />+ ) : (+ <UserButton />+ )}+ </div></Shell></header>);diff --git a/apps/web/src/components/layout/app-menu.tsx b/apps/web/src/components/layout/app-menu.tsxindex a2b5e2f22..4f56b8e33 100644--- a/apps/web/src/components/layout/app-menu.tsx+++ b/apps/web/src/components/layout/app-menu.tsx@@ -33,8 +33,8 @@ export function AppMenu() {<SheetContent><SheetHeader><SheetTitle className="text-left">Navigation</SheetTitle>- <AppSidebar /></SheetHeader>+ <AppSidebar /></SheetContent></Sheet>);diff --git a/apps/web/src/components/loading-animation.tsx b/apps/web/src/components/loading-animation.tsxindex eca4dcd39..2eac0d67f 100644--- a/apps/web/src/components/loading-animation.tsx+++ b/apps/web/src/components/loading-animation.tsx@@ -1,16 +1,47 @@+import { cva } from "class-variance-authority";+import type { VariantProps } from "class-variance-authority";+import { cn } from "@/lib/utils";-type Props = React.HTMLAttributes<HTMLDivElement>;+const loadingVariants = cva(+ "animate-pulse rounded-full direction-alternate duration-700",+ {+ variants: {+ variant: {+ // we might want to inverse both styles+ default: "bg-primary-foreground",+ inverse: "bg-primary",+ },+ size: {+ default: "h-1 w-1",+ lg: "h-1.5 w-1.5",+ },+ },+ defaultVariants: {+ variant: "default",+ size: "default",+ },+ },+);++interface Props+ extends React.ComponentProps<"div">,+ VariantProps<typeof loadingVariants> {}-export function LoadingAnimation({ className, ...props }: Props) {+export function LoadingAnimation({+ className,+ variant,+ size,+ ...props+}: Props) {return (<divclassName={cn("flex items-center justify-center gap-1", className)}{...props}>- <div className="direction-alternate bg-primary-foreground h-1 w-1 animate-pulse rounded-full duration-700" />- <div className="direction-alternate bg-primary-foreground h-1 w-1 animate-pulse rounded-full delay-150 duration-700" />- <div className="direction-alternate bg-primary-foreground h-1 w-1 animate-pulse rounded-full delay-300 duration-700" />+ <div className={cn(loadingVariants({ variant, size }))} />+ <div className={cn(loadingVariants({ variant, size }), "delay-150")} />+ <div className={cn(loadingVariants({ variant, size }), "delay-300")} /></div>);}diff --git a/apps/web/src/components/ui/auto-form.tsx b/apps/web/src/components/ui/auto-form.tsxnew file mode 100644index 000000000..0f6f69663--- /dev/null+++ b/apps/web/src/components/ui/auto-form.tsx@@ -0,0 +1,473 @@+"use client";++import React from "react";+import { zodResolver } from "@hookform/resolvers/zod";+import type {+ ControllerRenderProps,+ DefaultValues,+ FieldValues,+} from "react-hook-form";+import { useForm } from "react-hook-form";+import type { z } from "zod";++import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { cn } from "@/lib/utils";+import { Button } from "./button";+import { Checkbox } from "./checkbox";+import { DatePicker } from "./date-picker";+import {+ Form,+ FormControl,+ FormDescription,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+} from "./form";+import { Input } from "./input";+import { Switch } from "./switch";++/**+ * Beautify a camelCase string.+ * e.g. "myString" -> "My String"+ */+function beautifyObjectName(string: string) {+ let output = string.replace(/([A-Z])/g, " $1");+ output = output.charAt(0).toUpperCase() + output.slice(1);+ return output;+}++/**+ * Get the type name of the lowest level Zod type.+ * This will unpack optionals, refinements, etc.+ */+function getBaseType(schema: z.ZodAny): string {+ if ("innerType" in schema._def) {+ return getBaseType(schema._def.innerType as z.ZodAny);+ }+ if ("schema" in schema._def) {+ return getBaseType(schema._def.schema as z.ZodAny);+ }+ return schema._def.typeName;+}++/**+ * Search for a "ZodDefult" in the Zod stack and return its value.+ */+function getDefaultValueInZodStack(schema: z.ZodAny): any {+ const typedSchema = schema as unknown as z.ZodDefault<+ z.ZodNumber | z.ZodString+ >;++ if (typedSchema._def.typeName === "ZodDefault") {+ return typedSchema._def.defaultValue();+ }++ if ("innerType" in typedSchema._def) {+ return getDefaultValueInZodStack(+ typedSchema._def.innerType as unknown as z.ZodAny,+ );+ }+ if ("schema" in typedSchema._def) {+ return getDefaultValueInZodStack(+ (typedSchema._def as any).schema as z.ZodAny,+ );+ }+ return undefined;+}++/**+ * Get all default values from a Zod schema.+ */+function getDefaultValues<Schema extends z.ZodObject<any, any>>(+ schema: Schema,+) {+ const { shape } = schema;+ type DefaultValuesType = DefaultValues<Partial<z.infer<Schema>>>;+ const defaultValues = {} as DefaultValuesType;++ for (const key of Object.keys(shape)) {+ const item = shape[key] as z.ZodAny;+ const defaultValue = getDefaultValueInZodStack(item);+ if (defaultValue !== undefined) {+ defaultValues[key as keyof DefaultValuesType] = defaultValue;+ }+ }++ return defaultValues;+}++/**+ * Convert a Zod schema to HTML input props to give direct feedback to the user.+ * Once submitted, the schema will be validated completely.+ */+function zodToHtmlInputProps(+ schema:+ | z.ZodNumber+ | z.ZodString+ | z.ZodOptional<z.ZodNumber | z.ZodString>+ | any,+): React.InputHTMLAttributes<HTMLInputElement> {+ if (["ZodOptional", "ZodNullable"].includes(schema._def.typeName)) {+ const typedSchema = schema as z.ZodOptional<z.ZodNumber | z.ZodString>;+ return {+ ...zodToHtmlInputProps(typedSchema._def.innerType),+ required: false,+ };+ }++ const typedSchema = schema as z.ZodNumber | z.ZodString;++ if (!("checks" in typedSchema._def)) return {};++ const { checks } = typedSchema._def;+ const inputProps: React.InputHTMLAttributes<HTMLInputElement> = {+ required: true,+ };+ const type = getBaseType(schema);++ for (const check of checks) {+ if (check.kind === "min") {+ if (type === "ZodString") {+ inputProps.minLength = check.value;+ } else {+ inputProps.min = check.value;+ }+ }+ if (check.kind === "max") {+ if (type === "ZodString") {+ inputProps.maxLength = check.value;+ } else {+ inputProps.max = check.value;+ }+ }+ }++ return inputProps;+}++export type FieldConfigItem = {+ description?: React.ReactNode;+ inputProps?: React.InputHTMLAttributes<HTMLInputElement>;+ fieldType?: keyof typeof INPUT_COMPONENTS;++ startAdornment?: React.ReactNode;+ endAdornment?: React.ReactNode;+};++export type FieldConfig<SchemaType extends z.infer<z.ZodObject<any, any>>> = {+ [key in keyof SchemaType]?: FieldConfigItem;+};++/**+ * A FormInput component can handle a specific Zod type (e.g. "ZodBoolean")+ */+type AutoFormInputComponentProps = {+ zodInputProps: React.InputHTMLAttributes<HTMLInputElement>;+ field: ControllerRenderProps<FieldValues, any>;+ fieldConfigItem: FieldConfigItem;+ label: string;+ isRequired: boolean;+ fieldProps: any;+ zodItem: z.ZodAny;+};++function AutoFormInput({+ label,+ isRequired,+ fieldConfigItem,+ fieldProps,+}: AutoFormInputComponentProps) {+ return (+ <FormItem>+ <FormLabel>+ {label}+ {isRequired && <span className="text-destructive"> *</span>}+ </FormLabel>+ <FormControl>+ <Input type="text" {...fieldProps} />+ </FormControl>+ {fieldConfigItem.description && (+ <FormDescription>{fieldConfigItem.description}</FormDescription>+ )}+ <FormMessage />+ </FormItem>+ );+}++function AutoFormCheckbox({+ label,+ isRequired,+ field,+ fieldConfigItem,+ fieldProps,+}: AutoFormInputComponentProps) {+ return (+ <FormItem className="flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4">+ <FormControl>+ <Checkbox+ checked={field.value}+ onCheckedChange={field.onChange}+ {...fieldProps}+ />+ </FormControl>+ <div className="space-y-1 leading-none">+ <FormLabel>+ {label}+ {isRequired && <span className="text-destructive"> *</span>}+ </FormLabel>+ {fieldConfigItem.description && (+ <FormDescription>{fieldConfigItem.description}</FormDescription>+ )}+ </div>+ </FormItem>+ );+}++function AutoFormSwitch({+ label,+ isRequired,+ field,+ fieldConfigItem,+ fieldProps,+}: AutoFormInputComponentProps) {+ return (+ <FormItem className="flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4">+ <FormControl>+ <Switch+ checked={field.value}+ onCheckedChange={field.onChange}+ {...fieldProps}+ />+ </FormControl>+ <div className="space-y-1 leading-none">+ <FormLabel>+ {label}+ {isRequired && <span className="text-destructive"> *</span>}+ </FormLabel>+ {fieldConfigItem.description && (+ <FormDescription>{fieldConfigItem.description}</FormDescription>+ )}+ </div>+ </FormItem>+ );+}++function AutoFormDate({+ label,+ isRequired,+ field,+ fieldConfigItem,+ fieldProps,+}: AutoFormInputComponentProps) {+ return (+ <FormItem>+ <FormLabel>+ {label}+ {isRequired && <span className="text-destructive"> *</span>}+ </FormLabel>+ <FormControl>+ <DatePicker+ date={field.value}+ setDate={field.onChange}+ {...fieldProps}+ />+ </FormControl>+ {fieldConfigItem.description && (+ <FormDescription>{fieldConfigItem.description}</FormDescription>+ )}+ <FormMessage />+ </FormItem>+ );+}++function AutoFormEnum({+ label,+ isRequired,+ field,+ fieldConfigItem,+ zodItem,+}: AutoFormInputComponentProps) {+ const values = (zodItem as unknown as z.ZodEnum<any>)._def.values;++ return (+ <FormItem>+ <FormLabel>+ {label}+ {isRequired && <span className="text-destructive"> *</span>}+ </FormLabel>+ <FormControl>+ <Select onValueChange={field.onChange} defaultValue={field.value}>+ <SelectTrigger>+ <SelectValue className="w-full">+ {field.value ?? "Select an option"}+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {values.map((value: any) => (+ <SelectItem value={value} key={value}>+ {value}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </FormControl>+ {fieldConfigItem.description && (+ <FormDescription>{fieldConfigItem.description}</FormDescription>+ )}+ <FormMessage />+ </FormItem>+ );+}++const INPUT_COMPONENTS = {+ checkbox: AutoFormCheckbox,+ date: AutoFormDate,+ select: AutoFormEnum,+ switch: AutoFormSwitch,+ fallback: AutoFormInput,+};++/**+ * Define handlers for specific Zod types.+ * You can expand this object to support more types.+ */+const DEFAULT_ZOD_HANDLERS: {+ [key: string]: keyof typeof INPUT_COMPONENTS;+} = {+ ZodBoolean: "checkbox",+ ZodDate: "date",+ ZodEnum: "select",+};++function AutoFormObject<SchemaType extends z.ZodObject<any, any>>({+ schema,+ form,+ fieldConfig,+}: {+ schema: SchemaType;+ form: ReturnType<typeof useForm>;+ fieldConfig?: FieldConfig<z.infer<SchemaType>>;+}) {+ const { shape } = schema;++ return (+ <>+ {Object.keys(shape).map((name) => {+ const item = shape[name] as z.ZodAny;+ const fieldConfigItem = fieldConfig?.[name] ?? {};+ const zodInputProps = zodToHtmlInputProps(item);+ const isRequired =+ zodInputProps.required ??+ fieldConfigItem.inputProps?.required ??+ false;+ const zodBaseType = getBaseType(item);++ return (+ <FormField+ control={form.control}+ name={name}+ key={name}+ render={({ field }) => {+ const inputType =+ fieldConfigItem.fieldType ??+ DEFAULT_ZOD_HANDLERS[zodBaseType] ??+ "fallback";+ const InputComponent = INPUT_COMPONENTS[inputType];++ return (+ <React.Fragment key={name}>+ {fieldConfigItem.startAdornment}+ <InputComponent+ zodInputProps={zodInputProps}+ field={field}+ fieldConfigItem={fieldConfigItem}+ label={item._def.description ?? beautifyObjectName(name)}+ isRequired={isRequired}+ zodItem={item}+ fieldProps={{+ ...zodInputProps,+ ...field,+ ...fieldConfigItem.inputProps,+ }}+ />+ {fieldConfigItem.endAdornment}+ </React.Fragment>+ );+ }}+ />+ );+ })}+ </>+ );+}++export function AutoFormSubmit({ children }: { children?: React.ReactNode }) {+ return <Button type="submit">{children ?? "Submit"}</Button>;+}++function AutoForm<SchemaType extends z.ZodObject<any, any>>({+ formSchema,+ values: valuesProp,+ onValuesChange: onValuesChangeProp,+ onSubmit: onSubmitProp,+ fieldConfig,+ children,+ className,+}: {+ formSchema: SchemaType;+ values?: Partial<z.infer<SchemaType>>;+ onValuesChange?: (values: Partial<z.infer<SchemaType>>) => void;+ onSubmit?: (values: z.infer<SchemaType>) => void;+ fieldConfig?: FieldConfig<z.infer<SchemaType>>;+ children?: React.ReactNode;+ className?: string;+}) {+ const defaultValues: DefaultValues<z.infer<typeof formSchema>> =+ getDefaultValues(formSchema);++ const form = useForm<z.infer<typeof formSchema>>({+ resolver: zodResolver(formSchema),+ defaultValues,+ values: valuesProp,+ });++ function onSubmit(values: z.infer<typeof formSchema>) {+ const parsedValues = formSchema.safeParse(values);+ if (parsedValues.success) {+ onSubmitProp?.(parsedValues.data);+ }+ }++ return (+ <Form {...form}>+ <form+ onSubmit={form.handleSubmit(onSubmit)}+ onChange={() => {+ const values = form.getValues();+ const parsedValues = formSchema.safeParse(values);+ if (parsedValues.success) {+ onValuesChangeProp?.(parsedValues.data);+ }+ }}+ className={cn("space-y-5", className)}+ >+ <AutoFormObject+ schema={formSchema}+ form={form}+ fieldConfig={fieldConfig}+ />++ {children}+ </form>+ </Form>+ );+}++export default AutoForm;diff --git a/apps/web/src/components/ui/checkbox.tsx b/apps/web/src/components/ui/checkbox.tsxnew file mode 100644index 000000000..0b413450e--- /dev/null+++ b/apps/web/src/components/ui/checkbox.tsx@@ -0,0 +1,28 @@+import * as React from "react";+import * as CheckboxPrimitive from "@radix-ui/react-checkbox";+import { Check } from "lucide-react";++import { cn } from "@/lib/utils";++const Checkbox = React.forwardRef<+ React.ElementRef<typeof CheckboxPrimitive.Root>,+ React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>+>(({ className, ...props }, ref) => (+ <CheckboxPrimitive.Root+ ref={ref}+ className={cn(+ "border-primary ring-offset-background focus-visible:ring-ring data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground peer h-4 w-4 shrink-0 rounded-sm border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",+ className,+ )}+ {...props}+ >+ <CheckboxPrimitive.Indicator+ className={cn("flex items-center justify-center text-current")}+ >+ <Check className="h-4 w-4" />+ </CheckboxPrimitive.Indicator>+ </CheckboxPrimitive.Root>+));+Checkbox.displayName = CheckboxPrimitive.Root.displayName;++export { Checkbox };diff --git a/apps/web/src/components/ui/date-picker.tsx b/apps/web/src/components/ui/date-picker.tsxnew file mode 100644index 000000000..ea40cb342--- /dev/null+++ b/apps/web/src/components/ui/date-picker.tsx@@ -0,0 +1,46 @@+"use client";++import { format } from "date-fns";+import { Calendar as CalendarIcon } from "lucide-react";++import { Button } from "@/components/ui/button";+import { Calendar } from "@/components/ui/calendar";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";+import { cn } from "@/lib/utils";++export function DatePicker({+ date,+ setDate,+}: {+ date?: Date;+ setDate: (date?: Date) => void;+}) {+ return (+ <Popover>+ <PopoverTrigger asChild>+ <Button+ variant={"outline"}+ className={cn(+ "w-full justify-start text-left font-normal",+ !date && "text-muted-foreground",+ )}+ >+ <CalendarIcon className="mr-2 h-4 w-4" />+ {date ? format(date, "PPP") : <span>Pick a date</span>}+ </Button>+ </PopoverTrigger>+ <PopoverContent className="w-auto p-0">+ <Calendar+ mode="single"+ selected={date}+ onSelect={setDate}+ initialFocus+ />+ </PopoverContent>+ </Popover>+ );+}diff --git a/apps/web/src/config/pages.ts b/apps/web/src/config/pages.tsindex e43b0602a..d0f7a3311 100644--- a/apps/web/src/config/pages.ts+++ b/apps/web/src/config/pages.ts@@ -33,6 +33,7 @@ export const pagesConfig: Page[] = [description: "War room where you handle the incidents.",href: "/incidents",icon: "siren",+ disabled: true,},// ...];diff --git a/apps/web/src/config/socials.ts b/apps/web/src/config/socials.tsnew file mode 100644index 000000000..48c63ccc2--- /dev/null+++ b/apps/web/src/config/socials.ts@@ -0,0 +1,21 @@+import type { ValidIcon } from "@/components/icons";++type Social = {+ title: string;+ href: string;+ icon: ValidIcon;+};++export const socialsConfig: Social[] = [+ {+ title: "Discord",+ href: "/discord",+ icon: "discord",+ },+ {+ title: "GitHub",+ href: "/github",+ icon: "github",+ },+ // add cal.com+];diff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.tsindex 53de55e7c..628122556 100644--- a/packages/api/src/router/page.ts+++ b/packages/api/src/router/page.ts@@ -27,6 +27,24 @@ export const pageRouter = createTRPCRouter({with: { monitors: true, incidents: true },});}),+ updatePage: protectedProcedure+ .input(insertPageSchema)+ .mutation(async (opts) => {+ console.log(opts.input);+ const r = await opts.ctx.db+ .update(page)+ .set(opts.input)+ .where(eq(page.id, Number(opts.input.id)))+ .returning()+ .get();+ console.log(r);+ return r;+ }),+ deletePage: protectedProcedure+ .input(z.object({ pageId: z.number() }))+ .mutation(async (opts) => {+ await opts.ctx.db.delete(page).where(eq(page.id, opts.input.pageId));+ }),getPageByWorkspace: protectedProcedure.input(z.object({ workspaceId: z.number() })).query(async (opts) => {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 38b745685..e0cd81f69 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -71,6 +71,9 @@ importers:'@radix-ui/react-alert-dialog':specifier: ^1.0.4version: 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])+ '@radix-ui/react-checkbox':+ specifier: ^1.0.4+ version: 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])'@radix-ui/react-dialog':specifier: ^1.0.4version: 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])@@ -2667,6 +2670,34 @@ packages:react-dom: 18.2.0([email protected])dev: false+ /@radix-ui/[email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected]):+ resolution: {integrity: sha512-CBuGQa52aAYnADZVt/KBQzXrwx6TqnlwtcIPGtVt5JkkzQwMOLJjPukimhfKEr4GQNd43C+djUh5Ikopj8pSLg==}+ peerDependencies:+ '@types/react': '*'+ '@types/react-dom': '*'+ react: ^16.8 || ^17.0 || ^18.0+ react-dom: ^16.8 || ^17.0 || ^18.0+ peerDependenciesMeta:+ '@types/react':+ optional: true+ '@types/react-dom':+ optional: true+ dependencies:+ '@babel/runtime': 7.22.5+ '@radix-ui/primitive': 1.0.1+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-presence': 1.0.1(@types/[email protected])(@types/[email protected])([email protected])([email protected])+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])+ '@radix-ui/react-use-controllable-state': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-use-previous': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-use-size': 1.0.1(@types/[email protected])([email protected])+ '@types/react': 18.2.12+ '@types/react-dom': 18.2.5+ react: 18.2.0+ react-dom: 18.2.0([email protected])+ dev: false+/@radix-ui/[email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected]):resolution: {integrity: sha512-UBmVDkmR6IvDsloHVN+3rtx4Mi5TFvylYXpluuv0f37dtaz3H99bp8No0LGXRigVpl3UAT4l9j6bIchh42S/Gg==}peerDependencies: